- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2020 05:32 AM
Hi All, I have been working on the inbound actions in CSM and encountered one issue.
Let's say there are multiple contact records with the same email id abc@xyz.com, the user only has snc_external role in all the records. When the user sends the email, we want to check that this user has multiple contacts and then process something.
Now, we wrote a glide record on the contact table in the inbound action(tried business rule as well), then based on the row count we get, we are processing the rest of the things. Sounds straight forward, right?
But the problem we are facing is, it always returns only 1 record no matter how many contacts there are with the same email id. On exploring further we found it to be an access issue such that the user can only read their own record.
As per guidelines, on the GlideRecord query, ACLs don't apply, but somehow it is being applied in our scenario.
We found alternative solutions to it, like using impersonation in the BR or updating the ACLs.
But I was wondering why the OOB function is not working in this case.
All of this is happening in the scoped app CSM.
It will be really great if someone can please help us with this.
Thanks
Code is as below:
Running as before business rule in the sn_customerservice_case table
var contactID = new GlideRecord ('customer_contact');
contactID.addQuery('email', current.u_email);
contactID.query();
var newCount = contactID.getRowCount();
if (newCount == 1 ){
contactID.next()
gs.log('********Only 1 record');
}
else
{
gs.log('********more than 1 record');
}
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2020 06:09 AM
Hi Swadesh,
Yes query business rules restrict the query and may affect the rowCount
best practice is to add following condition in query business rule so that it runs only during interactive sessions and not when some script queries the table
gs.getSession().isInteractive()
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2020 07:44 AM
Try changing, "if" to "while" - if will terminate upon the first success, whereas while will continue the query activity to the final record.
if (newCount == 1 ){
contactID.next()
Also, I recommend using a variable incremented with each loop success as a diagnostic verification tool, although I am a mere novice developr. see, i can't even spell it yet...
Kind Regards,
Woody