How to constrain by context and can needEntityContext be optional ?

5
I have two questions: (1) I have a widget that takes an entity and has needEntityContext='true'. How would I constrain the entity by the context I get ? Domain model: Applicant 1 - * AppProductConfig * - 1 Product. XML entity has path='no'. Will my xpath call look something like: var contextConstraint = this.entity + '/' + context.trackClass + '/id = ' + context.trackId, xpath = "//" + this.entity + '[' + contextConstraint + ']'; I looked at setting my entity with path='yes' and pathType='reference', this allows me to access the 'owner' and 'changedBy' associations->entites of the context entity the widget is in. I looked at setting my entity with path='yes' and pathType='referenceSet', this allows me to only select the contexted entity I am in. Was looking for a way to select the path as one would with a datagrid that is in a context. (2) Is it possible to set needEntityContext to be optional ? As I want my widget to be constrained by the context if chosen to and not have 2 seperate widgets. Thank you in advance.
asked
1 answers
2

(1) You need to substite currentobject in your xpaths with the context your widget is retrieving, for example

update : function(data) {
/* context applied */
    if (data)   
       this.dataguid = data.getGUID();
},

yourexistingfunction : function() {
  var xpath = //what you already have
  xpath = xpath.replace(/\[\%CurrentObject\%\]/gi, this.dataguid);
  //retrieve stuff
}

(2) No, that is not possible. You do not need to duplicate the code however, you can use the same javascript for two different xml configs. I think the confirm microflow widget is an example for how that can be doen. .

answered