Disbale Implementation button till planned start date window arrives

sravya03
Tera Contributor

Logic  to Disbale Implementation button till planned start date window arrives.

I have written below on load client script but it is not working

 

function onLoad() {
  // Get the planned start date
  var plannedStartDate = g_form.getValue('planned_start_date');
  // Get the current date and time
  var now = new Date();
  // Convert planned start date to a Date object
  var plannedStart = new Date(plannedStartDate);
  // Check if the current date is before the planned start date
  if (now < plannedStart) {
    // Disable the Implement button
    g_form.setActionDisabled('implement', true);
  }
}
28 REPLIES 28

Hello @sravya03 

 

Please share screenshot of what it was before. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY.

sravya03_0-1742478369294.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

@sravya03 

why not add UI action condition in that UI action like this so that once the date/time crosses then only that button will be visible.

new GlideDateTime(current.start_date).getTime() >= new GlideDateTime().getTime()

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 

OOB UI action already has condition,can you please tell exactly where i need to paste this

@sravya03 

towards the end of the existing condition

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