Business Rule: gr.next returns false but works fine in 'Scripts Background'

andy_dufresne
Tera Expert

Hello Gurus,

There is no other business rule that is interfering with it.

When I debugged it the gr.next() was returning false

(function executeRule(current, previous /*null when async*/) {

id=current.sys_id;

var gr = new GlideRecord('contact');

//var eq = 'document='+ id +'^type=sys_user';

var eq = "type=sys_user^document="+ id;

gr.addEncodedQuery(eq);

gr.query();

while (gr.next()){

current.u_mojusersemailaddressholder += gr.user.email +',';

//gs.print(gr.user.email);

}

})(current, previous);

If I run in scripts background, gr.next is true.

What am I doring wrong?

Thanks,

12 REPLIES 12

Sorry for short answer:


First I tried this in before insert:   var id = current.getUniqueValue();


which resulted on the above error message.



if I put this 'current.setWorkflow(false);'   after the current.update();   it does not update the 'current.u_mojusersemailaddressholder' field which is what I wanted.



So I added "if (current.u_mojusersemailaddressholder == '')" [this code is in my last post] so that it does not update again.



I know its not great way to do, but I ran out of ideas 😞



Thanks for all your commitment, Chuck!  



PS: As always, your comments are precious!


Jack
Tera Guru

Not sure, But it can be ACL/Domain issue. You can check again the ACL/Domain on this table if you are using Domain separation.




Hope this is useful.  


vinothkumar
Tera Guru

Hi Andy,



Can you try after business rule instead of before business rule.