Explanation needed on mxObj.getReferences(attribute)

4
I have an entity that has a relation (reference) to a second entity. In my custom widget I want to retrieve the related object. In the widget I have an object called helpObject, this contains the GUID of the first object. Now I want to use helpObject.getReferences(attribute), bu am not sure what goes in the attribute. The documentation states: attribute String: the attribute from which the GUIDs are requested. I have tried to use different strings for the attribute: 'entity1_entity2/entity2/attribute' 'entity2' 'module.entity1/entity1_entity2/entity2' 'module.entity1/entity1_entity2/entity2/attribute' All of these option will return an empty array. I would greatly appriciate if anyone has an example or explanation of how to use this function or how to retrieve the reference in a different way.
asked
1 answers
4

It is actually 'Module.entity1_entity2'. The function only returns GUID's so it doesn't need to know the entity or attributes.

If you want to use these together with the attribute name on the newly retrieved referenced objects, use a split like this:

var splits = this.nameAttr.split("/");
this.assoc = splits[0];          // 'MyFirstModule.Order_OrderLine'
this.referredEntity = splits[1]; // 'MyFirstModule.OrderLine'
this.myAttribute = splits[2];    // 'DisplayName'

For an example, you can check the Checkbox Selector widget on the AppStore.

I'll update the documentation with the extra information as well.

answered