ui action

rognomolta
Tera Contributor

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

rognomolta_0-1729086122537.png

 

@Sandeep Rajput ,

1 REPLY 1

Najmuddin Mohd
Mega Sage

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.