Developing dynamic properties

I am trying to create a dynamic property plugin that will take a String containing a location, from a dropdown menu that contains a controlled vocabulary (“AH/8.01/1/203”, for example), and after splicing the location by “/”, it will fill four more properties with the four parts of the String. Having this situation, I have 2 questions:

  1. How can I take the selected value from a ControlledVocabulary? (In the documentation is just specified how to take the index, but not the value, and there is no method to obtain this)

  2. How can I set the value of the other properties, that will be filled using the parts of the location string?

The main problem is that I think that the documentation about DynamicProperties is really outdated, I do not know if there is a possible solution for this, but it will be great to have the last version :smile:

Thank you very much!

Digging into the methods and classes of the SamplePropertyPE tree, I managed to find a method (using the dir() method on every object and trying ever method associated to it) to obtain the value of the ControlledVocabulary selected label, so I leave it here, in case that it could be useful for the community:

prop = e.property(//property code here, string defining the property//)
result = prop.getPropertyPE()
return result.getVocabularyTerm().label 

Really easy to obtain, but hard to find from scratch; so please update the documentation with this, that I think could be very useful for developing purposes. Thank you very much! :face_holding_back_tears:

Hey @cmadaria,
in case your second question is still open regarding how to set the value of the other properties: In order for this to work you need to assign the dynamic property plugin to the property type. You can do this via the openBIS NG Admin mask when creating the mask and adding the property types. The calculate() function inside the dynamic property should return a value which is then set as the value of the property type. I hope this helps. :slight_smile:

Thank you very much! I have figured out how to do it by developing an individual script for each of the dynamic properties. However, when checking all the methods and functions of the classes, I wonder if it could (or should) be done from other properties, since from a script you can get the desired property, and then modify it using the setValue() method. Would this be a good approach? Or should it be done following the methodology of one script by dynamic property? Thank you very much in advance.