Re-open counter for Problems records and Due Date Update Counter on Problem Tasks

sureshp89882164
Tera Contributor

I need help on below two scenarios.

 

1)"Due Date Update Count" field should increment by 1 each time the due date of a Problem Task is updated.When the Due_Date_Update_Count is greater than 0, display this count as a read only field (non editable) in the Problem Task form.


2)"Reopen count" field should increment by 1 each time when Problem record is re-opened for the purpose is track the number of times opened.

1 ACCEPTED SOLUTION

Rajesh Chopade1
Mega Sage

hi @sureshp89882164 
Due Date Update Count on Problem Tasks: 
Add new field on problem task table as 'Due Date Update Count' or utilize if you created already.
Create before update Business rule on problem task table. Use following script to increase count.

if (current.due_date.changes()) {
    if (!current.due_date_update_count) {
        current.due_date_update_count = 0;
    }
    current.due_date_update_count++;
}

Create UI Policy on problem task table and add following condition to make field read only:

due_date_update_count > 0

 

2) Reopen Count on Problem:

Create new field 'reopen_count' on Problem table or utilize if you created already.

Create before update Business rule on problem table 

var closedStates = ['3', '4']; // Adjust based on your setup

if (previous.state && closedStates.indexOf(previous.state.toString()) > -1) {
    // if current state is an open state
    if (current.state != previous.state && closedStates.indexOf(current.state.toString()) === -1) {
        if (!current.reopen_count) {
            current.reopen_count = 0;
        }
        current.reopen_count++;
    }
}

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh

 

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@sureshp89882164 

so what script did you start with and where are you stuck?

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

I am using with business rule

@sureshp89882164 

so what's the script and what didn't work

what debugging did you perform?

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

Rajesh Chopade1
Mega Sage

hi @sureshp89882164 
Due Date Update Count on Problem Tasks: 
Add new field on problem task table as 'Due Date Update Count' or utilize if you created already.
Create before update Business rule on problem task table. Use following script to increase count.

if (current.due_date.changes()) {
    if (!current.due_date_update_count) {
        current.due_date_update_count = 0;
    }
    current.due_date_update_count++;
}

Create UI Policy on problem task table and add following condition to make field read only:

due_date_update_count > 0

 

2) Reopen Count on Problem:

Create new field 'reopen_count' on Problem table or utilize if you created already.

Create before update Business rule on problem table 

var closedStates = ['3', '4']; // Adjust based on your setup

if (previous.state && closedStates.indexOf(previous.state.toString()) > -1) {
    // if current state is an open state
    if (current.state != previous.state && closedStates.indexOf(current.state.toString()) === -1) {
        if (!current.reopen_count) {
            current.reopen_count = 0;
        }
        current.reopen_count++;
    }
}

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

Rajesh