Variables in an XML location path
Posted: Fri Dec 14, 2018 3:09 pm
Hi,
I'm trying to create a script to find the value of a PrivateDataKey and use it as a variable in an XML location path.
PrivateDataKey will be 01, 02, etc.
This is to get the value of /ItemOut[01], /ItemOut[02], etc.
Tried the below script, but getting error "error - no matching slot found"
var theVariable = job.getPrivateData("Original");
var xpathString = "[Metadata.TextIndexed:Path=\"/cXML/Request/OrderRequest/ItemOut[theVariable]/ItemID/SupplierPartAuxiliaryID\",Dataset=\"Xml\",Model=\"XML\"]";
var theValue = job.getVariableAsString(xpathString);
theValue;
Can anyone tell me where I'm going wrong?
Once this is working I would like expand it by getting the ItemOut lineNumber value, so that I can rename the file going through a flow, with the value of Extrinsic "Filename".
No idea how to reference the 'lineNumber' value, though. (example XML below)
<ItemOut lineNumber="001" quantity="10000"><ItemDetail><Extrinsic name="section.General"><Extrinsic name="Filename">FILE_NAME.pdf</Extrinsic>
All hint and tips greatly appreciated.
Richard
I'm trying to create a script to find the value of a PrivateDataKey and use it as a variable in an XML location path.
PrivateDataKey will be 01, 02, etc.
This is to get the value of /ItemOut[01], /ItemOut[02], etc.
Tried the below script, but getting error "error - no matching slot found"
var theVariable = job.getPrivateData("Original");
var xpathString = "[Metadata.TextIndexed:Path=\"/cXML/Request/OrderRequest/ItemOut[theVariable]/ItemID/SupplierPartAuxiliaryID\",Dataset=\"Xml\",Model=\"XML\"]";
var theValue = job.getVariableAsString(xpathString);
theValue;
Can anyone tell me where I'm going wrong?
Once this is working I would like expand it by getting the ItemOut lineNumber value, so that I can rename the file going through a flow, with the value of Extrinsic "Filename".
No idea how to reference the 'lineNumber' value, though. (example XML below)
<ItemOut lineNumber="001" quantity="10000"><ItemDetail><Extrinsic name="section.General"><Extrinsic name="Filename">FILE_NAME.pdf</Extrinsic>
All hint and tips greatly appreciated.
Richard