getFields is not available in scoped apps

verdakosnett
Tera Expert

I would like to duplicate a record before further processing it but I don't want to create it by hand identifying each field name and copying it over.   Instead, I would like to iterate through all the items.

In non-scoped apps you can use getFields function to perform this task but this is not available in scoped apps. How does one go about looking into the code of such script?

1 ACCEPTED SOLUTION

sebastian_g_snc
ServiceNow Employee
ServiceNow Employee

Hi Verda,



you could try this simple trick - no worries...there is a new sys_id generated upon insert.



the examle uses the incident table


var t = new GlideRecord("incident");


t.get(" [your sys_id here] ");


t.insert();



Kind regards



Sebastian


View solution in original post

6 REPLIES 6

sebastian_g_snc
ServiceNow Employee
ServiceNow Employee

Hi Verda,



you could try this simple trick - no worries...there is a new sys_id generated upon insert.



the examle uses the incident table


var t = new GlideRecord("incident");


t.get(" [your sys_id here] ");


t.insert();



Kind regards



Sebastian


Is the sys_id on the second line the id of the record from which I will copy all fields?


Works great:



      var gr = new GlideRecord('myTableName');


      gr.initialize();



gr.get(current.sys_id);  


gr.insert();  


When you say duplicate do you want to duplicate the record number too?