- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 11:13 AM
Dear Team,
There is a Close Incident button on Service Portal
There is a field- Major Incident State (name: major_incident_state; Type: String; Choices: Accepted (value-accepted), Rejected (value-rejected)) on the INC table which is displayed on INC records.
The requirement is when the user clicks on the 'Close Incident' button, it checks on the record whether that INC record has major_incident_state is 'accepted' or not, if found 'accepted' then it displays the info msg and restricts the closure of that respective INC record else allows the successful closure of the INC record.
I have modified the OOB provided UI Action: Close Incident (see below screenshot)
This is working fine but only in the Desktop view NOT on Service Portal, I want this to work on both. So I analysed further and found this 'Close Incident' button which appears in Service Portal is coming through a Custom Widget, I tried to modify the widget's Server Script to achieve the requirement but failed.
Below are the 'Body HTML Template' and 'Server Script' for this custom widget which contains this 'Close Incident' button in service Portal.
Body HTML Template:
Server Script:
I am not good at Service Portal-related widgets scripting, I tried this from lines 17 to 27 but had no luck, please help me to modify this widget's responsible scripts or advise the steps to achieve the requirement.
Thanks in advance
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 05:15 PM
Here's an example but you'll have to add the condition of Major Incident state = accepted to this. I don't know if that's a custom field but it's not one that was on my PDI:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 01:44 PM
Have you tried putting the logic/check into a Business Rule instead? Then you don't have to worry about modifying each UI action and there's one place to update the code if it ever needs to change, instead of trying to apply the same logic in multiple UI Actions/configurations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 01:57 PM
Thanks @Nia McCash mam for the suggestion, this seems great but I really have no idea about such a requirement to be achieved from the Business Rule part. If possible requesting your help to get this done.
If this works for service portal as well then will be great, kindly help further.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2023 05:15 PM
Here's an example but you'll have to add the condition of Major Incident state = accepted to this. I don't know if that's a custom field but it's not one that was on my PDI:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 06:16 AM
Thanks @Nia McCash Mam, this worked as expected (when=major incident state is accepted it restricted the Incident closure else allows its closure) in the Service portal when clicking on 'Close Incident' but there is a small issue which needs to be rectified. please see the screenshot below now for the INC records which have major incident state= accepted is not closing which is fine but there is a common message 'Incident INCXXXXX has been permanently closed'. I do not want to show this message for those INC records which have Major Incident State is accepted.
Please help to restrict this message for such INC records else this message should display