If "Time SVC Restored" field is empty when state is resolved that field is update with resolve field

mania
Tera Contributor

Hi,

 

I have a field called "Time SVC Restored" so If "Time SVC Restored" field is empty when state is resolved, then "Time SVC Restored" field should update with resolve field in incident form, How to achive.

 

Can you please help on this. It willl be helpful.

mania_1-1710920118715.png

 

mania_0-1710920066185.png

 

Thanks in Advance!

1 ACCEPTED SOLUTION

Deepak Shaerma
Kilo Sage

Hi @mania 

Here’s how you can set up the Business Rule:

1. Navigate to System Definition > Business Rules and click on New to create a new Business Rule.

2. Fill out the fields for the new Business Rule as follows:
Name: Give your Business Rule an intuitive name, such as “Auto Populate Store Date on Resolution”.
Table: Select Incident [incident] from the dropdown. This specifies that the Business Rule applies to the Incident table.
Advanced: Check the box to enable advanced scripting.
When to run:
When: Select “after” Update.

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

	if (current.state == '6' && !current.u_time_svc_restored) { // Assuming ‘6’ is the state value for Resolved and ‘u_store_date’ is the API name of your custom field
            current.u_time_svc_restored = current.resolved_at; // Assuming ‘resolved_at’ is the field storing resolution date and time
            current.update(); // Saves the record with the updated ‘store date’
        }

})(current, previous);


Please replace the "Time SVC Restore" backend name with the actual name of your field and Save the Business Rule.

Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help us a lot.
Thanks & Regards 
Deepak Sharma

DeepakShaerma_0-1710922178500.pngDeepakShaerma_1-1710922211323.pngDeepakShaerma_2-1710922232900.png

 

 


View solution in original post

1 REPLY 1

Deepak Shaerma
Kilo Sage

Hi @mania 

Here’s how you can set up the Business Rule:

1. Navigate to System Definition > Business Rules and click on New to create a new Business Rule.

2. Fill out the fields for the new Business Rule as follows:
Name: Give your Business Rule an intuitive name, such as “Auto Populate Store Date on Resolution”.
Table: Select Incident [incident] from the dropdown. This specifies that the Business Rule applies to the Incident table.
Advanced: Check the box to enable advanced scripting.
When to run:
When: Select “after” Update.

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

	if (current.state == '6' && !current.u_time_svc_restored) { // Assuming ‘6’ is the state value for Resolved and ‘u_store_date’ is the API name of your custom field
            current.u_time_svc_restored = current.resolved_at; // Assuming ‘resolved_at’ is the field storing resolution date and time
            current.update(); // Saves the record with the updated ‘store date’
        }

})(current, previous);


Please replace the "Time SVC Restore" backend name with the actual name of your field and Save the Business Rule.

Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help us a lot.
Thanks & Regards 
Deepak Sharma

DeepakShaerma_0-1710922178500.pngDeepakShaerma_1-1710922211323.pngDeepakShaerma_2-1710922232900.png