Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to test the below on Before insert Business Rule Script and please explain ?

PTR
Tera Expert

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();

}
}

5 REPLIES 5

shloke04
Kilo Patron

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.

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Sebastian L
Mega Sage

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

Maik Skoddow
Tera Patron

PTR
Tera Expert

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