Business Rule: gr.next returns false but works fine in 'Scripts Background'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 06:22 AM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 07:52 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 06:48 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2017 07:23 AM
Hi Andy,
Can you try after business rule instead of before business rule.