Sai Shravan
Mega Sage

Hi @Community Alums ,

 

To update the date field on bulk records, you will need to use a loop to iterate over each record that needs to be updated. Here is an example of how you could modify the script to update the "u_rating_valid_to" field on all "core_company" records that have a related "sn_vdr_risk_asmt_assessment" record with a matching sys_id:

 

var gr = new GlideRecord('core_company');
gr.query();

while (gr.next()) {
    var gr1 = new GlideRecord('sn_vdr_risk_asmt_assessment');
    gr1.addQuery('sys_id', gr.sys_id);
    gr1.query();

    if (gr1.next()) {
        gr.u_rating_valid_to = gr1.risk_rating_valid_to;
        gr.update();
    }
}

Note that this script assumes that the "sys_id" field on the "core_company" table corresponds to the "sys_id" field on the "sn_vdr_risk_asmt_assessment" table, and that there is a one-to-one relationship between these two tables. If this is not the case, you will need to modify the script accordingly.

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you