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.

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

throwing error if i paste at end

@sravya03 

please share existing UI action condition and screenshots

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

sravya03_0-1742740303087.png

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @sravya03 

I understand your use case, but instead of hiding the entire UI action, you can add a condition to ensure it only works when the plan start date has arrived. If I'm not mistaken, there is an existing validation, but it is not active, allowing users the flexibility to make changes at any time.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Atul can you pls tell the existing validation