Tuesday, March 12, 2019

Dynamic Script Validation passing multiple parameters

Here is a small example where i am trying to find if a node exists in alternate hierarchies. if not list which hierarchies it does not exist.

Note: SJ_PropList is a hierarchy level property of list group type. this property stores list of alternate hierarchy that the validation needs to check.

----- Begin -----
var AltHiers =node.Hier.PropValue("Custom.SJ_PropList");
var NodeExistsin = node.PropValue("Core.References");
var missingHiers;
for(i=0;i<AltHiers.length;i++)
{
    if(NodeExistsin.indexOf(AltHiers[i]) == -1)
    {
        if(missingHiers == null)
        {
        missingHiers=AltHiers[i];
        }
        else
        {
            missingHiers=missingHiers+","+AltHiers[i];
        }
    };
};
return{
        success:false,
    parameters:[node.Abbrev,missingHiers]
   // parameters:[1,2] => {0}{1}
}
----- End -----

in the above example i am returning two values in the parameters section of return statement. 
first parameter will be returned to {0} and second will be returned to {1} so on and so forth.

No comments:

Post a Comment