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

Abhinay,


In this case yes, but i guess that is easy to fix if alternative is required.


If you want a different record number, then you will have to use this code



var gr= new GlideRecord(current.getTableName());


gr.get(current.getValue('sys_id'));


gr.number=new NumberManager().getNextNumber();


gr.insert();