Simple renaming question
Posted: Fri Dec 03, 2021 2:16 pm
Hello, I am new to Switch and am learning about scripting within Switch. I have a very basic "tutorial" flow I made for myself where I am importing some XML and related PDF files. I know that I can leverage data within the XML to rename my PDF files. I did that and it works great. But I was trying to learn about renaming the PDF files by using scripting. We have the scripting and metadata modules installed.
I added the Rename Job tool to the flow and set the Action 1 to Act on = Filename proper and Replace by = Script Expression Defined. I then added what I thought was very simple code but the PDF filename refuses to change at all. I have some example of my code below.
First attempt:
When that wasn't working I tried to just go simple with this:
In both cases and with each of the commented out sections attempted, I get absolutely nothing in terms of any name changing. Can someone let me know what I am doing wrong?
Thanks!
-Mike
I added the Rename Job tool to the flow and set the Action 1 to Act on = Filename proper and Replace by = Script Expression Defined. I then added what I thought was very simple code but the PDF filename refuses to change at all. I have some example of my code below.
First attempt:
Code: Select all
var orderid = job.getVariableAsString('[Metadata.Text:Path="/cXML/Request/JobTicketDetail/ItemOut/Extrinsic",Dataset="Xml",Model="XML"]');
var sku = job.getVariableAsString('[Metadata.Text:Path="/cXML/Request/JobTicketDetail/ItemOut/ItemID/SupplierPartAuxiliaryID",Dataset="Xml",Model="XML"]');
// var pdfname += orderid + '_' + sku;
var pdfname = orderid + '_' + sku;
pdfname;
Code: Select all
var pdfname = 'Testing';
return pdfname;
//pdfname;
Thanks!
-Mike