How to upload a file and rename an attachment using a UI action?

Ed23
Tera Contributor

Hello,

 

I want to upload a file and after uploading the file, change the file name to "Doc" + file extension.

 

I have this script but when I add something after "saveAttachment(g_form.getTableName(), g_form.getUniqueValue());" it doesn't run.

cap.png

 

Regards.

6 REPLIES 6

Samaksh Wani
Giga Sage
Giga Sage

Hello @Ed23 

 

 

       var name = "Doc" // You can set the value as per your requirement
	var extensionName = current.getValue("file_name").split(".")[1]; //Retrieves the extension of file your are uploading
	current.file_name = name + "." + extensionName // Renaming the uploaded file along with it's extension

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

 

 

 

 

Hello @Samaksh Wani ,

 

Thanks for your reply, how can I get it to run on the UI Action after line 3? "saveAttachment(g_form.getTableName(), g_form.getUniqueValue());"?

 

I want to create a UI Action to upload files and that all files uploaded through that UI Action are automatically renamed to "DOC".

 

Regards.

Hello @Ed23 

 

You need to add the above mentioned script in the script box of UI Action Thats it.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

Hello @Ed23 

 

Uncheck the Box of Client in UI Action and Copy paste the above mention code as it in Script box of your UI Action, Erase everything what you wrote.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh