Auto Populate date and time field value from anothe table date time field value

Krishna101
Tera Contributor

Hi Everyone,
Good Day!
I have field as near_meeting_date (Field type as Date/Time) in change request table and having another field
as meeting_start_date (Field type as Date/Time) in meeting table, I want to auto populate nearest date value of meeting_start_date  to 'near_meeting_date' in change request form. Could you please give suggest how we can get this requirement.
Thanks,
Krishna

20 REPLIES 20

Hi Kilo Sage,
I ahve created before business rull in change request table as below and its not working please review

(function executeRule(current, previous /*null when async*/ ) {
    var gr = new GlideRecord("cab_meeting");
    gr.addEncodedQuery('board_groups=82faef5adb28cf0029253220ad96192a');
    gr.addQuery('change_request', current.sys_id);
    gr.query();
    if (gr.next()) {
        current.near_meeting_date = gr.meeting_start_date; // Replace with your field names

    }

})(current, previous);

@Krishna101 

business rule is on CHG but what's the trigger?

are you sure your BR ran?

is it going inside that IF and query is getting satisfied?

did you add gs.info() and see?

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

@Krishna101 

what's the relationship between those 2 tables?

it's an easy  requirement.

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

Hi Ankur, 

Thanks for your response , meeting table having only meeting information like meeting start date , meeting end date and cab manager information.
i have created before BR on change request like below

(function executeRule(current, previous /*null when async*/ ) {
    var gr = new GlideRecord("cab_meeting");
    gr.addEncodedQuery('board_groups=82faef5adb28cf0029253220ad96192a');
    gr.addQuery('change_request', current.sys_id);
    gr.query();
    if (gr.next()) {
        current.u_the_nearest_cab_date = gr.start; // Replace with your field names

    }

})(current, previous);


Its not working.... please assist on this

 

@Krishna101 

what's the BR trigger condition?

Is that BR triggering?

Is there a record in cab meeting table satisfying the query?

Did you add gs.info() and see?

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