Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Background script to update custom table's field from RITM

Ankita9793
Tera Contributor

Hi All,

 

My requirement is to update the custom table's (u_intralinks_vdr_request_database) fields with the corresponding RITM's variables. Can someone please suggest what is wrong with it, it doesn't update the custom tables fields.

Please refer below script and screenshots.

 

 

var ritm = new GlideRecord('sc_req_item');
ritm.addEncodedQuery("cat_item.nameSTARTSWITHIntralinks VDR - Create Workspace/Exchange^sys_created_onBETWEENjavascript:gs.dateGenerate('2024-07-29','00:00:00')@javascript:gs.endOfToday()");
ritm.query();

gs.print('Count' + ritm.getRowCount());

while (ritm.next()) {

    gs.print('Number' + ritm.number);
    var data = new GlideRecord('u_intralinks_vdr_request_database');
    data.addQuery("u_servicenow_id", ritm.number);

    gs.print('ritm.number' + ritm.number + data.addQuery("u_servicenow_id", ritm.number));

    data.query();
    if (data.next()) {

        gs.print('if');
        data.u_calculate_show_annual_cost = ritm.variables.calculate_show_annual_cost;
        gs.print('var' + data.u_calculate_show_annual_cost + ritm.variables.calculate_show_annual_cost);
        data.u_estimated_volume_size_of_workspace_in_gb = ritm.variables.estimated_volume_size_of_workspace_in_gb;
        data.u_is_this_workspace_part_of_a_ctb_change_the_bank_or_rtb_run_the_bank_project = ritm.variables.is_this_workspace_part_of_a_ctb_change_the_bank_or_rtb_run_the_bank_project;
        data.u_number_of_participants = ritm.variables.number_of_participants;
        data.update();
    }

}





Capture.PNGCapture1.PNG

 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankita9793 

script looks fine

if the field u_servicenow_id holds RITM sysId then your query should be this

    data.addQuery("u_servicenow_id", ritm.sys_id);
 

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankita9793 

script looks fine

if the field u_servicenow_id holds RITM sysId then your query should be this

    data.addQuery("u_servicenow_id", ritm.sys_id);
 

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Ankita9793 

as per screenshot it's working fine

what's not working?

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