Copy Sctask Variables to custom table

Mahesh033
Tera Contributor

Hi All,

 

I would like to copy sctask variables to custom table ,what would be best practice to do it and any example script will be helpful.

 

2 REPLIES 2

Samaksh Wani
Giga Sage
Giga Sage

Hello @Mahesh033 

 

plz refer this example script :-

 

var catVar = current.variables.select_all_tw_software_needed.toString();

var catVar2 = current.variables.select_all_3rd_party_software_needed.toString();

var finalVal= catVar+','+catVar2; //combine both the list collector values


var res = finalVal.split(',');
var len = res.length;

if(len>0)
{
for( var i=0; i<len;i++) 
{

//creates record for each value selected on both the list collector fields

var table= new GlideRecord('u_asr_apps_to_users');
table.initialize();
table.u_nameid_servicenow_applicaion = res[i];

 

table.insert();
}

}

 

}

 

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

 

Regards,

Samaksh

Ankur Bawiskar
Tera Patron
Tera Patron

@Mahesh033 

What's the business requirement here?

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