Question
How to export files using file source name from UiPath?
Answer
- Create a Service Field in the Document Definition and name it for example as "ImageSource":
- Open field's properties and in the tab Data Source select Source: Image Source:
- Open Export profile settings in the Document Definition.
- Set Filename template as <RegParam:ImageSource>:
- Save and publish Document Definition.
- Open Workflow settings for the Project or BatchType (depends on what is used).
- Set it as an Advanced workflow scheme and right before Export Stage create Automatic stage (Create Processing Stage > Automatic > OK).
- Open stage properties and then Script tab.
- Select Type: Document Processing and click Edit Script…
- In the script editor select C# .Net language and put the following script:
using System.IO;
string s = Document.Field("Invoice Layout\\ImageSource").Value.ToString();
s = Path.GetFileNameWithoutExtension(s);
Document.Properties.Set("ImageSource", s);
11. It is required to change the text in bold to the full path of service field you created in the Document Definition in the script at the following line:
string s = Document.Field("Invoice Layout\\ImageSource").Value.ToString();
12. Save settings and try to perform export again.
The script will take the ImageSource value from the Service field and then will set the registration parameter for the document with the value of the field. At the Export stage, the value of the registration parameter will be used to name exported file.
Comments
0 comments
Please sign in to leave a comment.