- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 11:28 AM
Hi,
I want to write a BR that counts previously opened requests from the same requester and doesn't allow them to open more requests if they already have 7 or more open.
Here's what I have
(function executeRule(current, previous /*null when async*/) {
var requester = current.u_requester;
var gr = new GlideRecord('u_chromatech_customer_queries');
gr.addQuery('u_requester', requester);
gr.query();
// gs.addInfoMessage(gr.getRowCount());
// gs.addInfoMessage(requester.getDisplayValue());
// gs.addInfoMessage(requester);
})(current, previous);
the info messages show that I am not getting a value for var requester, I've tried a few methods like getValue and getDisplayValue and cannot seem to populate the requester variable.
No matter what I try the info messages for requester are always blank
Thanks for your time
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 12:10 PM
Hi,
I tried and it worked as follow.
I tried to create 5th record and I got the error. I have provided the code used. Please try yourself.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var count = 0;
var grD = new GlideRecord('u_demo_table');
grD.addQuery('u_requestor',current.u_requestor);
grD.query();
while(grD.next())
{
count = grD.getRowCount();
}
if (count >= 4 )
{
gs.addErrorMessage("Cannot creater more requests");
current.setAbortAction(true);
}
})(current, previous);
If you found my response helpful or relevant to your query, please consider clicking the "Helpful" button or giving it a "Like". This not only helps others identify useful replies but also encourages contributors like me to continue assisting the community. Thank you for your support!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 12:10 PM
Hi,
I tried and it worked as follow.
I tried to create 5th record and I got the error. I have provided the code used. Please try yourself.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var count = 0;
var grD = new GlideRecord('u_demo_table');
grD.addQuery('u_requestor',current.u_requestor);
grD.query();
while(grD.next())
{
count = grD.getRowCount();
}
if (count >= 4 )
{
gs.addErrorMessage("Cannot creater more requests");
current.setAbortAction(true);
}
})(current, previous);
If you found my response helpful or relevant to your query, please consider clicking the "Helpful" button or giving it a "Like". This not only helps others identify useful replies but also encourages contributors like me to continue assisting the community. Thank you for your support!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2023 12:27 PM
Thank you very much that works great