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.

wants to set the variable value with end of the month date like (31/01/2025)

akankshak15
Tera Guru

I have a target timeline date once item is submitted i have to set that variable value with submitted month last date suppose form is submitted on 14 jan or any date of the month . target timeline variable value should be 31/01/2025

9 REPLIES 9

Hi @Ankur Bawiskar 

I have tried with the BR but the BR is not wokring the script i have written working in the background script but not in BR .

Could you please suggest something

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

    // Add your code here
    var  dates = current.sys_created_on;
    var createdDate = new GlideDateTime(dates);
    gs.log(createdDate + 'akanskhak');
    var year = createdDate.getYear();
    var month = createdDate.getMonth(); // 0-based month (0 = January, 11 = December)
    gs.log(month + 'akanskha_k');

  
    var lastDay = new GlideDateTime();
    lastDay.setValue(year + '-' + (month) + '-01');  // Set the first day of the next month
    lastDay.addMonths(1);  // Move to the next month
    lastDay.addDays(-1);  // Subtract one day to get the last day of the original selected month
   
    current.target_complitation_date =lastDay ;
    gs.log(current.target_complitation_date + 'akanskhakk' );

   




})(current, previous);

@akankshak15 

so what's not working?

what debugging have you done so far?

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

Hi @Ankur Bawiskar 

the other BR was stopping the my Business rule so i added the code to flow designer and working as expected 

 

Thank you for your quick response and help

@akankshak15 

Glad to help.

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