business rule to prevent closing of a record if child task records are not closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 08:01 AM
hi all,
In a custom scoped app "Feedback", I have a custom table (extended off Task) for feedback records (let's call this the parent table). I have a 2nd custom table (also extended off Task) for the tasks assigned to a feedback record (let's call this the child table). I configured the 2nd table to be a related list on the records of the 1st table...so that tasks can be created and assigned associated with a feedback record. I need a business rule to make it so the State of the parent feedback record cannot be closed if any of the associated tasks in the related list on a particular record are not closed.
I'm struggling a little with the script...thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 08:06 AM
Hello Patrick,
Create a business rule on parent table with script as. Adjust it accordingly.
Also apply filter condition in the Business rule as appropriate so that the rule is triggered only in that case.
var gr = new GlideRecord('pass child table name');
gr.addQuery('parent', current.sys_id); //Repalce parent with exact field column name of field on child table which referencs parent table
gr.addQuery('state', '!=', 1); //Here replace state with exact column name of state on child table and with exact value
gr.query();
while(gr.next()){
current.setAbortAction(true); //abort the record
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 08:09 AM
thanks Pradeep, I'll give it a shot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 08:13 AM
couple quick questions...I'm new creating business rules. Step by step, please let me know if I've got this correct.
System Definition>Business rules
create New
create name, and select the table, which for this will be my parent "Feedback" table
check the "Advanced" box
under the "Advanced" tab, that's where I enter the code you sent.
correct so far?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2017 08:23 AM
You are correct so far. Also make sure insert and update checkbox set to true.