The answer for this question is: it picks up the document’s “Title” property to display the name in iPad. I am not sure, why Colligo shows it differently for different definition of libraries. I have no idea what makes Colligo decide to take the title property for the display.
Document’s Title property can be viewed by clicking on File Tab (or right click on the document and click on properties , visit Details tab to view the properties):
How do we solve this problem. Below are 2 options which maybe used until Colligo releases an upgrade version with resolution to this problem.
- Do not create List definition if we do not really need it. Instead create library instances from the default Library template (we can do this programmatically as well).
- Create an event handler to update the “Title” property of the document after upload. We can have this event handler associated with content type so that we need not add it to every single library. Associating and dissociating of the event handler can be done on feature activation and deactivation respectively. This would enable us to remove the event handler without having to deploy the code if Colligo comes up with a solution for this problem.
static void Main(string[] args)
{
SPSite site = new SPSite(“http://YourSiteURL;“);
SPWeb web = site.OpenWeb();
string filePath = “path of the file to be updated”;
SPFile file = web.GetFile(filePath);
string itemTitle = file.Title;
Stream streamItemDoc = file.OpenBinaryStream();
Package packageDoc = Package.Open(streamItemDoc, FileMode.Open, FileAccess.ReadWrite);
packageDoc.PackageProperties.Title = file.Name.Substring(0, file.Name.LastIndexOf(‘.’));
packageDoc.PackageProperties.Subject = “Sample Subject”;
PackagePartCollection packageCollection = packageDoc.GetParts();
PackagePart part = packageCollection.FirstOrDefault();
Uri uriProps = part.Uri;
XmlDocument xmlDocPP = null;
PackagePart curPP = packageDoc.GetPart(uriProps);
using (Stream streamProps = curPP.GetStream())
{
xmlDocPP = new XmlDocument();
xmlDocPP.Load(streamProps);
}
xmlDocPP.Save(packageDoc.GetPart(uriProps).GetStream(FileMode.Create, FileAccess.Write));
packageDoc.Flush();
file.SaveBinary(streamItemDoc);
file.Properties["vti_title"] = itemTitle;
file.Update();
}
|
Points to remember:
- Whenever, we update the package Title property it updates the List Item Title as well and therefore in the penultimate line, the title is updated back to what it was originally.
- Windows.Base is the reference required to be added (maybe required only for client projects such as Console Application, Windows Application)