How to export files using file source name from UiPath

Question

How to export files using file source name from UiPath?

Answer

  1. Create a Service Field in the Document Definition and name it for example as "ImageSource":
    • mceclip0.png
  2. Open field's properties and in the tab Data Source select Source: Image Source:
    • mceclip2.png
  3. Open Export profile settings in the Document Definition.
  4. Set Filename template as <RegParam:ImageSource>:
    • mceclip1.png
  5. Save and publish Document Definition.
  6. Open Workflow settings for the Project or BatchType (depends on what is used). 
  7. Set it as an Advanced workflow scheme and right before Export Stage create Automatic stage (Create Processing Stage > Automatic > OK).
  8. Open stage properties and then Script tab.
  9. Select Type: Document Processing and click Edit Script…
  10. 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. 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed