How to test the below on Before insert Business Rule Script and please explain ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 07:15 AM
function onBefore(current, previous) {
var gr_cf = new GlideRecord('u_causal_factors');
gr_cf.addQuery('u_task_reference',current.u_problem);
//gr_cf.addNullQuery('u_rca');
gr_cf.query();
while(gr_cf.next()) {
gr_cf.u_rca = current.sys_id;
gr_cf.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 07:27 AM
Hi,
What is the use case here? What are you trying to achieve?
Looking at the BR looks like BR is only updating a field "u_rca " on the Table "u_causal_factors". That's it.
Now when this will be updating depend on the BR condition i.e. look in the screenshot below which will tell you how you can test it.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 07:29 AM
It should be an After Business Rule, not a Before, as you are not updating the current object, but another record.
On the testing part:
For this to work you need a record in the u_causal_factors tables to have the field u_task_reference populated with the same record you intend to have on the table where the Business Rule is running.
How you would test is to insert a record with data in the field u_problem on the table the Business Rule is running on. The field u_problem should be the same as the one in your u_causal_factors table.
It should then update the record(s) on the u_causal_factors with setting the u_rca field with the record from your current table! 🙂
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 08:31 AM
I recommend reading
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 07:12 PM
Hi All,
The above BR Script was written On RCA[u_rca] table. it was working under before insert operation and There no filter condition for this BR. But my 1st use case is here I want to Check or Test , How it is working by keeping gr_cf.update(); method in the script.
2nd use case is By block commenting (//) the gr_cf.update() method also whether it is working same like 1st use case or not?.
But My question is i am unable test this code How like it is working ?
Plz find snapshots for the reference .
Thanks,
Thanu