How to add action Clone/Copy button for Variable Set

Nirmala B
Giga Contributor

Kindly help in how to add Clone or Copy action button for Variable Set in Record Producer.

I need to copy the records or values of one row of variable set and create a new row entry in same variable set. this action must happen before submission of main record producer.

Thanks in advance

 

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Nirmala,

you will have to use some custom code to copy; or else what you can do is use onSubmit catalog client script and set the mrvs value as below

One more option is to have a macro variable and have button name as Copy; on click of it get the value; and copy

function onSubmit(){

var value = g_form.getValue('mrvs_variable');

var parser = JSON.parse(JSON.stringify(value));

var obj = parser[0];

arr.push(obj);

g_form.setValue("mrvs_variable",JSON.stringify(arr));

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Akshata jamdar
Mega Guru

Hello Nirmala,

 

Please refer below link,

https://www.servicenowguru.com/system-ui/ui-actions-system-ui/copy-ui-action-change-requests/

Just make a change with table name. 

 

 

Hope this will help you to resolve your query.

Kindly mark the answer correct and helpful if it will resolved your query.

Regards,
Akshata
(ServiceNow Developer).

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Nirmala,

you will have to use some custom code to copy; or else what you can do is use onSubmit catalog client script and set the mrvs value as below

One more option is to have a macro variable and have button name as Copy; on click of it get the value; and copy

function onSubmit(){

var value = g_form.getValue('mrvs_variable');

var parser = JSON.parse(JSON.stringify(value));

var obj = parser[0];

arr.push(obj);

g_form.setValue("mrvs_variable",JSON.stringify(arr));

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Thank you for reply. I need a checkbox to be added to variable set so that I can copy that specific record only. I have tried your code that is working fine but its creating duplicate of all the rows which are in variable set. I need for selected rows only.

Is it possible to add checkbox and get id of that selected row in variable set.

Kindly help if you have solution. Thanks in advance.

Hi Nirmala,

So you are saying one more checkbox variable you want to create which says whether to copy or not

please check below links:

https://community.servicenow.com/community?id=community_question&sys_id=ae08a088dbbe7b801cd8a345ca96...

https://community.servicenow.com/community?id=community_question&sys_id=9b4d5a84dbc1cc14d82ffb243996...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader