Fix Script:- Need to update date field on the record as date filed on the related record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2023 11:49 PM
Dear Team, I have requirement to update date filed on bulk records same as their related record and i need fix script for this, how ever i tried writing the script to update single record and it is working fine as expected.
I need a logic to achieve same functionality on bulk records , please find the below script and help..thank in advance !!
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id','74638e021b720890e0e2fff7dc4bcb2d');
gr.query();
if(gr.next()){
var gr1 = new GlideRecord('sn_vdr_risk_asmt_assessment');
gr1.addQuery('sys_id','e433480387c6e51082390e59cebb3523');
gr1.query();
if(gr1.next()){
gr.u_rating_valid_to = gr1.risk_rating_valid_to;
gr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2023 11:54 PM
@Chiranjeevi K Can you confirm what type of fields those both?
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2023 12:44 AM
both the filed types are "Date"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2023 10:07 PM
Try below script
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id','74638e021b720890e0e2fff7dc4bcb2d');
gr.query();
if(gr.next()){
var gr1 = new GlideRecord('sn_vdr_risk_asmt_assessment');
gr1.addQuery('sys_id','e433480387c6e51082390e59cebb3523');
gr1.query();
if(gr1.next()){
var dat = new GlideDateTime(gr1.risk_rating_valid_to);
gr.u_rating_valid_to =dat.getDate();
gr.update();
}
}
Bharath Chintala

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2023 12:05 AM
Hello @Chiranjeevi K ,
You can use as below
var gr = new GlideRecord('core_company');
gr.addQuery('sys_id','74638e021b720890e0e2fff7dc4bcb2d'); // you can remove this line or you can use any filter condtion if you want
gr.query();
while(gr.next()){
var gr1 = new GlideRecord('sn_vdr_risk_asmt_assessment');
gr1.addQuery('sys_id', gr.getUniqueValue() ); // beleiving this is refering to gr
gr1.query();
if(gr1.next()){
gr.u_rating_valid_to = gr1.risk_rating_valid_to;
gr.update();
}
}
Kindly mark correct and helpful if applicable