Creating relation

Hi all, how can i create relation using custom widget? I can create object like: mx.processor.create({ entity: "Staff.TimeInterval", callback: function(obj) { obj.setAttribute("SelectedValues", tempString); obj.setAttribute("StaffId", rowId); obj.setAttribute("DayShiftId", dayShiftIdentifier); mx.processor.commit({ mxobj: obj, callback: function() { console.log('New TimeInterval object was created and saved.'); } }); } }); But what if my Staff.TimeInterval has parent entity? Do i need to update it like this: obj.setAttribute("TimeInterval_parent", parentObject);??
1 answers

Take a look at the Checkbox set selector. It does a lot with references, I'm sure that should give you the insight you need.

Either way, you can use obj.addReference(refname, guid) on the owner obj of the relation.

Remember that all entities/associations/microflows start with their Module_Name as in MyFirstModule/MyMicroflow or MyFirstModule/Object_OtherObject. You should keep hardcoded strings out of your code and set these as parameters in your XML.