Copy records from one table to another in scoped

kiran kumar m1
Tera Contributor

I have two scoped tables in those tables the fields are same  , i want to a functionality such that whenever i click a UI action , the record from table A should be copied from A to B , and inserted into B  , are there any OOB functions to achieve this in scoped 

4 REPLIES 4

KrishnaMohan
Giga Sage

Hi @kiran kumar m1 


No, there are no such Out-of-the-Box (OOTB) functions/UI action in a scoped application that copies information and insert a record from one table (A) to another table(B) which are different scopes . Because how system recognize that target table and it's scope like (insert and stay ui action). I believe you must go with custom script in your UI Action to perform this operations.

 

If this helped to answer your query, please mark it helpful & accept the solution.
Thanks!
Krishnamohan

Ankur Bawiskar
Tera Patron
Tera Patron

@kiran kumar m1 

nothing is present OOTB, you will have to write custom logic for this in your UI action code

what did you start with and where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

M Iftikhar
Kilo Sage

Hi @kiran kumar m1,

There is no OOB “clone record across tables” function so you have to write custom logic.
You can create a UI Action button on Table A. When clicked, the script behind it creates a new record in Table B and copies over field values. Let me know if you need help with script.

A sample script can look like:

(function executeAction(current) {
    try {
        // Target table GlideRecord
        var grB = new GlideRecord('x_scope_table_b'); // replace with your Table B name
        grB.initialize();

        // Copy fields (assuming both tables have the same field names)
        grB.setValue('field1', current.getValue('field1'));
        grB.setValue('field2', current.getValue('field2'));
        // ... repeat for all common fields

     
        var newSysId = grB.insert();

        if (newSysId) {
            gs.addInfoMessage('Record copied to Table B successfully.');
        } else {
            gs.addErrorMessage('Failed to copy record.');
        }
    } catch (ex) {
        gs.error('Error copying record: ' + ex.message);
        gs.addErrorMessage('Error occurred while copying.');
    }
})(current);

 

Thanks & Regards, 
Muhammad Iftikhar

 

If my response helped, please mark it as the accepted solution so others can benefit as well. 

Shashank_Jain
Kilo Sage

@kiran kumar m1 ,

If this is end-user facing → prefer Flow Designer (low code, maintainable).

If this is developer/admin only → scripted UI Action with GlideRecord is simpler and faster.

For recurring bulk copy → use Transform Maps.

 

 

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain