Solved

NWC and Salesforce - Rename an attachment from SF without removing file type extension?

  • 2 September 2020
  • 2 replies
  • 143 views

Hello All,

 

I have a component workflow where users complete a task form and attach files to the form. Then those files are added to a record in Salesforce. After the files are attached to the record, we also use the Nintex Workflow to rename the files. However, doing so removes the file extension in Salesforce.

 

The file attachment on the form can be several different types, including .png, .pdf, .xlsx, .docx...

 

Is there a way to identify the file type extension of these files attached to the form task, so that I may use that in the workflow?

 

Example: User completes the form and attaches File.docx and File2.xlsx. They are added to Salesforce record.

Workflow renames to Payroll Document 1 and Payroll Document 2. This loses the file type extension in Salesforce.

Would like to rename to Payroll Document 1.docx and Payroll Document 2.xlsx.

 

Thanks in advance for any help!

icon

Best answer by jwCbank 3 September 2020, 17:32

View original

2 replies

Actually, what I believe will solve this issue is a regex pattern that I can use with the "Apply a Regular Expression" action to retrieve the file extension of a file name.


 


I can retrieve the name of the file from Salesforce in the workflow. However, my attempts at a regex pattern to retrieve the extension names have been unsuccessful. If I can get the file extension and store it in a workflow variable, then I can simply add that to the end of the file name when I rename it in the workflow! 


 


I've looked at a few regex patterns from google but some of the results I've found mention that they seem to be javascript specifc, or python specific etc. I'm not sure what type of pattern would work in the Nintex Workflow action. Any help would be greatly appreciated!

Well just in case anyone comes across this in the future, I was able to use the 'Retrieve a record' action to retrieve the attachment record from Salesforce. Then, with the attachment file name, I was able to extract the extension with this regex pattern: .[0-9a-z]+$


 


Ex filename - Testfile.pdf -> the Regex pattern will output ---> .pdf


 


Nintex regex follows the .Net format for regular expressions. After that, simply store the file extension as a variable and add it to the the end of whatever text is being used to re-name the file!!!

Reply