- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 11:29 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 12:02 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 11:53 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 12:01 AM
I am using with business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 12:12 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 12:02 AM
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