This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UIX - getting property values from selected item

I am relatively new to using UIX and am wondering if there is any way that I can get the property values for the selected item within m-files.

An example of what we are trying to do is basically, when you select a person we are using UIX to display certain information about the person selected in a more user friendly format. So far we have run into difficulty with how we can retrieve/display specific properties from the person selected.

Can anyone help with any code on how we can achieve this?

  • The ObjectVersionAndProperties instance also has a property named "Properties" which is effectively a collection you can use to retrieve the object's metadata.  You would need to use the appropriate methods on that to retrieve the information you need.

  • Ok so if I use ObjectVersionAndProperties how would get the string from a specific property. would I use the ID of the property or the alias?

  • How would you do it without ObjectVersionAndProperties?

    var objectVersionAndProperties = selectedItems.ObjectVersionAndProperties[0];
    var objectVersion = objectVersionAndProperties.VersionData;
    var properties = objectVersionAndProperties.Properties;
    
    // Now work with the available information that the properties class exposes,
    // ref: https://developer.m-files.com/APIs/COM-API/Reference/#MFilesAPI~PropertyValues.html
    
    var nameOrTitlePropertyValue = getPropertyValueById(properties, 0);
    if(null != nameOrTitlePropertyValue)
    {
      shellFrame.ShowMessage("Object is named: " + nameOrTitlePropertyValue.GetValueAsLocalizedText());
    }
    
    var classPropertyValue = getPropertyValueById(properties, 100);
    if(null != classPropertyValue)
    {
      shellFrame.ShowMessage("Object is in class: " + classPropertyValue.GetValueAsLocalizedText());
    }
    
    // Some helpers.
    function getPropertyValueById(pv, id)
    {
      var index = pv.IndexOf(id);
      if(index == -1)
        return null;
      return pv[index];
    }
    function getPropertyValueByAlias(pv, alias)
    {
      var index = pv.IndexOfByAlias(id);
      if(index == -1)
        return null;
      return pv[index];
    }

  • Thankyou so much. We have gotten the results we were looking for