ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 06:52 AM
The problem requires creating a UI Action in ServiceNow that automatically updates the status of a record in the vpm_activity_instance table based on changes made to the Achieved Date or Expiration Date fields. The status should be updated according to the following rules:
If both Achieved Date and Expiration Date are filled in and the current date falls between them, set the status to "Achieved".
If both Achieved Date and Expiration Date are filled in and the current date is after the Expiration Date, set the status to "Expired".
so i tried with ui action and business rule but not working
Please provide best approach
add a screenshot of the form below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2024 12:03 PM
Hi @rognomolta ,
Can you try the below script in the UI Action.
if(current.achieved_date != '' && current.expiration_date != ''){ // Check the condition whether two fields are filled
// Check if today date falls after achieved date and before expiration date
if(todayDate > current.achieved_date && todayDate < current.expiration_date){
current.status = 'Achieved'; // set status value to Achieved
}else if(todayDate > current.expiration_date){
current.status = 'Expired'; // set status value to Expired
}
}
current.update();
action.setRedirectURL(current);
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.