Business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 09:25 AM
How can I create a Business Rule to update incident state based on comments?
- 799 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 09:33 AM
You can look at OOB business rules in your instance, to start. Read:
Create a new BR to run for 'Insert' and 'Update', set When to 'Before'. and use Conditions to set the incident_state as desired. If a condition like "Comments", "Contains", "some value" won't work, then use javascript to contain the logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 09:40 AM
Hi @thullurishalini ,
Please Reuse This script Business rule
(function executeRule(current, previous /*null when async*/) {
if (current.comments.changes()) {
current.state = 2; // Example: Set state to 'In Progress'
}
})(current, previous);
Should my answer prove to be helpful, kindly mark it as such by clicking "Accept as Solution" and "Helpful."
Regards,
Manikanta. Kota
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 10:10 AM - edited ‎09-30-2024 10:15 AM
It may helps to you follow the steps:
1.Go to Application Navigator
All>System Definition>Bussiness Rule
and click on business rule
2. After List view opened ,Click on New
3. After the clicking on New Tab, configure the details like name etc according to requirement
4. Give Table : incident
5. In when to run
Apply the condition filter
Comments changes
Enable Update select box
6. Apply in action Tab the following filter condition:
state changes to In progress/on hold/resolved
7. Save it and Run.
Thank you, please make helpful if you accept the solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 10:19 AM
@thullurishalini What exactly your requirement here? If you are updating incident state based on the comment added by the user then there is something wrong with your approach here. Ideally, incident state should not be updated based on comment.
In case if you still want to persue this idea then you can plan to create an onBefore update business rule which changes state of the incident whenever the comment field changes.