• Using document properties in VB.NET

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #47983  by zaans2
 
I am working on a desktop client for in-house use. I am writingit inVisual Basic.NET using the .NET SDK 1.2.2.

I have the following code (where `ws` is an `OKMWebservice` instance)
Code: Select all
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim search = TextBox1.Text
        Try
            For Each result In ws.findByContent(search)
                Dim doc = ws.getDocumentProperties(result.node.path)
                ListView1.Items.Add(doc.title)
            Next
        Catch exc As System.Exception
            Console.WriteLine(exc)
        End Try
    End Sub
I want to show the title of the documents that are the results of a search. However because of how the fields in the class `Document` are named I get the following error message:
Code: Select all
'title' is ambiguous because multiple kinds of members with this name exist in class 'Document'.
This would be easily solved if I used C# instead of VB.NET, but I have to use VB.NET as everything we do is written in VB.NET.
This could be easily solved if I used C# instead of VB.NET or directly used the REST services. However I would like to keep using the SDK and I have to use VB.NET as everything we do is written in VB.NET.

Is there a way I can still access the title/properties while still using the VB.NET and the SDK?
 #47996  by jllort
 
You get a property named path -> /okm:root/folder/file.docx -> what you might convert to file.docx
 #48005  by zaans2
 
Yeah I can work with that. It is still annoying that an SDK made for .NET doesn't work properly for VB.NET. Especially because it can easily be fixed.
 #48112  by zaans2
 
I am no VB expert either, just started working with it. I am indeed using the SDK dll, which is marketed as a .NET SDK (and VB.NET is part of the .NET framework)

The issue is that VB.NET is case insensitive, where C# is case sensitive. So in C# the fields "TITLE" and "title" are different fields. In VB.NET both of these cannot be used as VB.NET sees them as the same and doesn't know which one to use.

This can be easily solved by naming the constant "TITLE" something like "_TITLE". This way it would also work in VB.NET as it sees it as different than "TITLE" and "title". So far this issue is the only one I found in compatibility with VB.NET (which again is also part of the .NET framework) and it is not limited to just this property (Node author is another one)
 #48386  by zaans2
 
It now works fine for author, but not for title. I no longer get the error message but title is just an empty string for every document.
 #48402  by pherrera
 
By default when you upload a document to the repository it does not have a title, so it returns an empty string, you must add it from the OpenKM UI or using the setProperties method from sdk.net, for example:
https://docs.openkm.com/kcenter/view/sd ... Properties

After this if it works with the title, we will work on this to launch a new version of the sdk.

Thanks for the observation, greetings.
 #48403  by zaans2
 
Okay understood. So if i understand correctly there is currently now way to get just the name of the document directly from the object?

The change does work for the 'author' field. I couldn't access that before and I now can.
 #48416  by jllort
 
What is trying to explain is when you upload a document you set the name attribute but not the title. You must call an additional method after uploading the document for setting the attribute. That's the reason why after uploading the document you get an empty title because uploading document and setting title are split methods ( the title is not set in the document creation process, but might be done later ).

If we understood, with the change in the SDK, now you are getting the name. Confirm this point and we will rebuild a new SDK version.
 #48417  by zaans2
 
That I have to set the title manually after I understood.

About getting the name. With the alpha version of the SDK provided there is no property called 'name'. Only a static field called 'NAME' with the value "okm:name" so currently I can't get a name via the SDK
 #48423  by pherrera
 
At the moment you can get the name of the document by extracting it from document.path

For example:

Imports System.IO
Code: Select all
	    Dim doc = New Document()
            doc = ws.getDocumentProperties("942516de-3fd9-4506-b7e4-9d01796dee57")
            Dim name = Path.GetFileName(doc.path)
 #48425  by zaans2
 
Yeah that is how I currently get the name. I just would have expected it to also be a property of the class `Document` since it is part of the document in the user interface of the web application.
 #48454  by pherrera
 
The name is not a property of the document object, but the only property that exists in the core is the path.
The document object of the sdk is the same as the one of the core for us a variable name does not make sense if the name already forms part of the path it is duplicating data and from the side of the core we would have to calculate it equally.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.