Help with widgets: Associations in widgets

I was wondering is it possible to set or change associations in a widget. I would like to set an association of Object A that is selected by the needsEntityContext to Object B which is selected in the widget. How could i set this relation in the widget? Another question i had about associations in widgets is that I would expect a type "association" in the XML file or an attributeType "association" but according to the XML reference guide these do not exist. Are these coming, or are they just not documented? On a side note, it apears that all attributeTypes have to be added separately to one attribute i.e. <attributeTypes> <attributeType name="AutoNumber"/> <attributeType name="Binary"/> <attributeType name="Boolean"/> <attributeType name="Currency"/> <attributeType name="DateTime"/> <attributeType name="Enum"/> <attributeType name="Float"/> <attributeType name="HashString"/> <attributeType name="Integer"/> <attributeType name="Long"/> <attributeType name="String"/> </attributeTypes> Is there any specific reason why this has to be done? Otherwise it would be nice to have an "all" attributeType
3 answers

You can use the isPath and pathType properties for this (both valid for entity and attribute properties). Note that currently only outgoing associations are selectable. pathType is either reference or referenceSet, isPath can be yes, no or optional.

<property key="ownerattribute" type="entity" entityProperty="entity" isPath="yes"  pathType="reference" required="true">

Pieter, concerning your previous comment,

you can use the functions initContext(), applyContext(), object.getAttribute() (returns the GUIDs of the referenced objects) and mx.processor.getObjectsById. (we are working on documenting these functions)

The image viewer, inline object creator, dynamic microflow trigger and explorer pane widgets for example use those functions. You might inspect their source by extracting the .mpk files (which are found in the widgets directory).


For retrieving the Dataview context, I suggest you take a look here: Using the Dataview context object.

You can retrieve a reference using:


Where assocPath is a string like "System.User_Image", it will return the GUID of the referenced object, which you can then retrieve using a simple getObject:

mx.processor.getObjectsById(["" + assocID], dojo.hitch(this, this.showButton));

Good example of this is in the DynamicMicroflowTrigger, which uses this exact same method.


To add a reference, you can use this:

mxobj.addReference("User_Tags", "123123123");

First parameter is the association, second part is the GUID.