UI Action for Assets creation

vinod6
Tera Contributor

I have selected five records in related List. then I created a new UI Action button(Button Name: TO Process).

After selected the five records i am using the above button for five records create on another new form .

Can you please help on the UI Action script selected records created on the new from.

 

I am using this script but not working

 

(function executeAction() {
    var gr = new GlideRecord('alm_asset'); // Asset Table

    var selectedRecords = g_list.getChecked(); // Get the selected Asset IDs

    if (selectedRecords.lenght > 0) {
        for (var i = 0; i < selectedRecords.lenght; i++) {
            gr.get(selectedRecords[i]);

            //create a new request for each selected asset
            var request = new GlideRecord('sc_req_item');
            request.initialize();
            request.description = 'Test';
            request.name = gr.sys_id; // Link to the asset
            request.insert();

        }
    }


})

 

 

1 REPLY 1

Abhishek_Thakur
Mega Sage

Hello @vinod6 ,

You can try to use the below code it might help you.

(function executeAction() {
    var gr = new GlideRecord('alm_asset'); // Asset Table

    var selectedRecords = g_list.getChecked(); // Get the selected Asset IDs

    if (selectedRecords.length > 0) {
        for (var i = 0; i < selectedRecords.length; i++) {
            gr.get(selectedRecords[i]);

            //create a new request for each selected asset
            var request = new GlideRecord('sc_req_item');
            request.initialize();
            request.description = 'Test';
            request.name = gr.sys_id[i]; // Link to the asset
            request.insert();

        }
    }


})

 

Please mark my answer as accepted solution and give thumbs up, if it helps you.