GlideDateTime

faraaz
Tera Contributor

Hi, 

I am trying to set the date of CAB date field in the change_request record using before business rule and it is not working, nothing is populating in the field. Below is my script:

(function executeRule(current, previous /*null when async*/ ) {

    try {
        var gdt = new GlideDateTime(gs.beginningOfNextWeek());
        gdt.addDaysLocalTime(2);
        current.setvalue('cab_date_time', gdt);
    } catch (err) {
        gs.error("A runtime error occured:" + err);
    }

})(current, previous);
2 ACCEPTED SOLUTIONS

Vishal Jaswal
Giga Sage

Hello @faraaz 

 

use setValue

 

uppercase V


Hope that helps!

View solution in original post

Juhi Poddar
Kilo Patron

Hello @faraaz 

Try this:

(function executeRule(current, previous /*null when async*/) {

    try {
        var gdt = new GlideDateTime(gs.beginningOfNextWeek()); // Gets Sunday of next week
        gdt.addDaysLocalTime(2); // Add 2 days to get Tuesday
        current.setValue('cab_date_time', gdt); // Make sure "setValue" is camelCase
    } catch (err) {
        gs.error("A runtime error occurred: " + err);
    }

})(current, previous);

Hope this helps!

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

View solution in original post

5 REPLIES 5

Thank you!