Make comments mandatory when incident state changes resolve to reopened in service portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 11:38 PM
Make comments mandatory when incident state changes resolve to reopened in service portal.
here I am adding a image.
Here there is a action button we can open incident state to reopen here.
Please suggest your solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 12:23 AM
To make comments mandatory when Incident state changes from "Resolved" to "Reopened" in Service Portal, use a UI Policy + Client Script combo:
✅ Solution
1. UI Policy on incident table
Condition: State changes from Resolved to In Progress (or appropriate "Reopened" state)
Set Additional Comments → Mandatory
2. Client Script (type: onSubmit, UI Type: All)
function onSubmit() { if (g_form.getValue('state') == '2' && g_form.getValue('state').changedFrom('6')) { if (!g_form.getValue('comments')) { g_form.showFieldMsg('comments', 'Comments are required when reopening', 'error'); return false; } } return true; }
Replace 2 = In Progress, 6 = Resolved as per your instance state values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 01:01 AM
Changes is not available in UI Policy.
Could you please help me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 12:57 AM
Hi Nitya,
I tried it is not working, could you please help me any other way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 10:27 PM
To make comments mandatory when an Incident is reopened (Resolved → In Progress) in Service Portal, you need to work around how the Service Portal doesn't always handle onSubmit scripts reliably — especially when it comes to changedFrom() logic.
✅ Approach That Works in Service Portal
1. Create a hidden field
Add a new hidden field to the incident table. Call it something like state_changed_from_resolved (type: true/false).
Set default value: false.
2. Business Rule (Server-side)
Create a before Business Rule on the Incident table:
if (current.state == 2 && previous.state == 6) { // 2 = In Progress, 6 = Resolved current.state_changed_from_resolved = true; } else { current.state_changed_from_resolved = false; }
This marks the record when transitioning specifically from "Resolved" → "In Progress".
3. UI Policy
Table: incident
Condition: state_changed_from_resolved is true
Action: Make comments field mandatory
✅ Note: In Service Portal, comments refers to "Additional Comments", not "Work Notes".
4. Client Script (optional validation backup)
Type: onChange, Field: state
function onChange(control, oldValue, newValue, isLoading) { if (isLoading || newValue != '2' || oldValue != '6') return; g_form.setValue('state_changed_from_resolved', true); // This ensures the UI policy kicks in real-time }
⚠ Why previous Didn’t Work
changedFrom() doesn't work client-side in Service Portal.
g_form.getValue('state').changedFrom('6') is invalid JS — getValue() returns a string, not an object.
SP does not enforce onSubmit the same way classic UI does.