I'm running into a problem and was wondering if I could get some guidance.
I am receiving an order via a web to print system. I am attempting to extract delivery information from it's XML.
Sometimes the customer does not include a company name, in which case we just default to a hard coded string.
Here is a very basic example of where the company name would be situated in the XML:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<Order>
<ShippingAddress>
<CompanyName></CompanyName>
</ShippingAddress>
</Order>Code: Select all
async function calculateScriptExpression(s: Switch, flowElement: FlowElement, job: Job): Promise<string> {
const company = await job.getVariableAsString('[Metadata.Text:Dataset="XML",Model="XML",Path="//Order/ShippingAddress/CompanyName",Space="trim"]')
const companyString = (company.length ? company : 'Company Name')
return companyString
}If I interrogate the result of company directly, I can see that it is returning the string 'undefined' and I'm not really sure as to why.
The manual doesn't mention returning undefined upon failure. I've also checked the logic of
Code: Select all
[Metadata.Text:Dataset="XML",Model="XML",Path="//Order/ShippingAddress/CompanyName",Space="trim"]On top of this, I'm sure I've used this pattern in other flows without this issue presenting itself.
Can anyone shed some light on why this is happening?
Thanks in advance,
Dan