Idea for how the service parameters could be structured:
Code: Select all
<CreateServiceNodeFromScript>
<Variables>
<Variable IsArray="True" Index="1">
<Name>StrVar</Name>
<Type>String</Type>
<Data>
<!-- (Type="String") XSLT that evaluates to a string -->
<xsl:value-of select="WorkData/GetText/Output/Result/Text"/>
</Data>
</Variable>
<Variable IsArray="True" Index="2">
<Name>NodeVar</Name>
<Type>NodePath</Type>
<Data>
<!-- (Type="NodePath") A node path that results in an array of JSON objects converted from the XML of each node -->
WorkData/GetItems/Output/Result/Item
</Data>
</Variable>
</Variables>
<Script>
<!-- Javascript goes here where each variable name is referencable. -->
let message, success, priceTotal;
if (strVar.length > 10) {
message = strVar.substring(0,10);
success = true;
}
else {
message = "Input must be 10+ characters";
success = false;
}
<!-- NodeVar is an array of JSON objects converted from "Item" XML -->
priceTotal = 0;
NodeVar.forEach((Item) => {
if(Item.Price > 0) {
Item["TotalPrice"] = Item.Price * Item.Quantity
priceTotal += Item.Price * Item.Quantity;
}
});
<!-- if returning single value, then Result of service just the value -->
<!-- if returning JSON object, then Result of service is XML converted from returned JSON -->
return {
"Success": success,
"Message": message,
"Items": {
"TotalPrice": priceTotal,
"ItemList": NodeVar
}
}
</Script>
</CreateServiceNodeFromScript>