• Method getPropertyGroupProperties only returns elements

  • 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.
 #48008  by zaans2
 
According to the Knowledge Center Page for the method `getPropertyGroupProperties` it should return all the elements for the group and node and its values (see https://docs.openkm.com/kcenter/view/sd ... Properties). It only returns the elements without their values.

The following code is what I expected to be able to do
Code: Select all
For Each group In metadataGroups
  Dim properties = ws.getPropertyGroupProperties(selectedDoc.path, group.name)
    For Each prop In properties
      TextBox6.AppendText(prop.label + vbCrLf)
      For Each value In prop.values
        TextBox6.AppendText("- " + value + vbCrLf)
      Next
  Next
Next
However the `getPropertyGroupProperties` returns a `List<FormElement>`. The class `FormElement` doesn't even contain a `values` or `value` field. It onlys has fields for `label`, `name`, `width`, `height`.

The `getPropertyGroupPropertiesSimple` does return values besides the names, but these are the names they are given within OpenKM and are those are not usefull for my application. I want the labels of the elements and values, which I expected to get with `getPropertyGroupProperties`

I am using the 1.2.2. .NET SDK with Visual Basic.NET
 #48039  by saulhidalgo
 
Good afternoon.

You need to check to what subclass the FormElement belongs to. Here is the API description.

https://docs.openkm.com/apidoc/com/okm/ ... ement.html

As you can see, FormElement has some subclasses, like Input, TextArea, etc. You need to check what instance you have in each element of the list, and then cast it accordingly. Inside those classes you will find the "getValue()" method wanted.

Please check it, and if you have any question or advice you can contact me:

Mail: saulhidalgoaular@gmail.com.
Skype: saulhidalgoaular@outlook.com
Phone: +58 426 517 94 59.

Best Regards.
Saul Hidalgo.
 #48045  by zaans2
 
Hi,

As you could have seen in my post I am talking about the v1.2.2 .NET SDK, not the internal Java API which you have linked to.

Here is a link to the `FormElement` doc of the SDK https://docs.openkm.com/apidoc/com/sdk/ ... ement.html

If I cast to for instance an `Select` element (https://docs.openkm.com/apidoc/com/sdk/ ... elect.html) it does have a field value. However this field has no actual value. For every `FormElement` it is empty.

If you check a later .NET SDK, lets say the latest v3.1.0, you can see that the actual method no longer returns a `List<FormElement>` but a `Dictionary<String, String>`, the same as the method `getPropertyGroupPropertiesSimple` does right now (https://docs.openkm.com/apidoc/pro/sdk/ ... e995871ffb)

I can't use the `getPropertyGroupPropertiesSimple` method from v1.2.2 of the .NET SDK because that only returns the name's of the properties and values, not the labels (which is what I need)
 #48056  by jllort
 
You will have value in case of Input or TextArea, but in case of Select you have a list of options and one of them or several will be selected

https://docs.openkm.com/apidoc/com/okm/ ... elect.html
https://docs.openkm.com/apidoc/com/okm/ ... ption.html
https://docs.openkm.com/apidoc/com/okm/6.3.6/
 #48310  by zaans2
 
If I check the values of the Select with a debugger it doesnt have any. the `List<Option>` called `options` has a single option without any values. I think this method wasn't implemented properly in the version if the .NET SDK I am using.
 #48314  by jllort
 
You are using SDK version 1.2.2 with what OpenKM version?
Take a look at this table https://docs.openkm.com/kcenter/view/sdk4net/

For what I understood, the method always returns an empty list of options. Can you share us the XML definition for testing from our side?
 #48333  by zaans2
 
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.0//EN"
        "http://www.openkm.com/dtd/property-groups-2.0.dtd">
<property-groups>
    <property-group label="FooBar" name="okg:foobar">
        <select label="Foo" name="okp:foobar.foo" type="simple" >
            <option label="FooInternal" value="foo.intern"/>
            <option label="FooExternal" value="foo.extern"/>
        </select>
        <select label="Bar" name="okp:foobar.bar" type="multiple" >
            <option label="BarHR" value="bar.hr"/>
            <option label="BarIT" value="bar.it"/>
            <option label="BarMT" value="bar.mt"/>
            <option label="BarHD" value="bar.hd"/>
        </select>
    </property-group>
</property-groups>
So the siuation is that if I assign this group to a document and select values, lets say "FooInternal" for the "Foo" property and "BarHR" and "BarMT" for the "Bar" property if I call "getPropertyGroupProperties" I only get list with the "FormElement" for the different properties (In this case it would be two, one for "Foo" and one for "Bar"). The options list is empty, the value is empty etc.
 #48351  by zaans2
 
Here you go
Code: Select all
For Each prop In ws.getMetadataGroupProperties(selectedDoc.path, "okg:foobar")
	Console.WriteLine(prop.label + ":" + vbCrLf)
	Dim options = CType(prop, [Select]).options
	
	For Each value In options
		If value.selected Then
			Console.WriteLine("- " + value.label + vbCrLf)
		End If
	Next
Next
 #48424  by zaans2
 
This SDK version unfortunately doesn't solve the problem. The class 'FormElement' still only has the properties 'label', 'name', 'width' and 'height'. There is no property for the value(s) of the element
 #48434  by pherrera
 
Hi,

As mentioned in previous comments...
"You need to check what instance you have in each element of the list, and then cast it accordingly."
https://docs.openkm.com/apidoc/com/sdk/ ... ement.html

If I'm not wrong, for example:
Code: Select all
            For Each fe In ws.getPropertyGroupProperties("942516de-3fd9-4506-b7e4-9d01796dee57", "okg:technology")
                Dim t = fe.GetType()
                Console.WriteLine(fe.label + ":")
                If t.Equals(GetType([Select])) Then
                    Dim item = CType(fe, [Select])
                    For Each value In item.options
                        If value.selected Then
                            Console.WriteLine("- " + value.label)
                        End If
                    Next
                ElseIf t.Equals(GetType([TextArea])) Then
                    Dim item = CType(fe, [TextArea])
                    Console.WriteLine("- " + item.value)
                ElseIf t.Equals(GetType([Input])) Then
                    Dim item = CType(fe, [Input])
                    Console.WriteLine("- " + item.value)
                End If
            Next

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.