I'm creating a JS function which does some things depending on whether the target entity "Collection" is associated to active records of another entity "Library". The entities are associated by an N:N relationship.
I wrote the following fetchXML, but I'm not sure if it's the right approach to query a N:N relationship, can you help me to check it please?
// I look for "stores"... // ...which are associated to "collections" // ("from" indicates the entity I'm querying for, // "to" indicates the attribute of the other entity in the relation) ...
I stored the fetchXML query inside a variable which I'm gonna use to filter the result and set the conditions:
function myFunction(executionContext) { var formContext = executionContext.getFormContext(); // I store the value for the id of this collection: var collectionid = executionContext.getAttribute("collectionid").getValue(); // I sotre the value if the FetchXML inside a variable: var resultStores = " " foreach (s in resultStores){ // some actions here } else{ // show alert } }