Record not found
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2023 02:20 PM
Hi All,
I have one before query BR in which I am restricting view cases if user is not part of the assignment group.
If user is not part for the assignment group then I am getting "Record not found" message.
I want to show my custom error message with 'Record not found' but it is showing multiple times on screen like below.
1)Form View
2) List view
3)When user is not part of the assignment group.
I am not sure why it showing multiple times and I want to show only 3rd case (When user is not part of the assignment group.). Please suggest how we can achieve this.
Below is my before query BR.
(function executeRule(current, previous /*null when async*/ ) {
if (gs.hasRole('admin') || gs.hasRole('auditor_procurement_auditor') || !gs.getSession().isInteractive()) return;
var grMember = new GlideRecord('sys_user_grmember');
grMember.addNotNullQuery('group');
grMember.addQuery('user', gs.getUserID());
grMember.query();
var groupIDS = [];
while (grMember.next()) {
groupIDS.push(grMember.getValue('group'));
}
var flag = true;
for (var i = 0; groupIDS.lenght; i++) {
flag = false;
}
if (flag == false) {
current.addQuery('requested_by', gs.getUserID()).addOrCondition('assignment_group', 'IN', groupIDS.toString());
} else {
current.addQuery('assignment_group', 'IN', groupIDS.toString());
gs.addErrorMessage('Error for not having access to this record');
}
})(current, previous);
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2023 01:01 AM
Hi @Brijmohan
The Query Business Rule is triggered not only when accessing the table through the user interface but also during any operations that involve reading the table using Glide Record Query in scripts.
So you will have multiple executions of the Query Business Rule since there would be many scripts that are reading the table via GlideAjax calls, g_from.reference calls or Display Business Rules
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2023 03:27 AM
Hi Manmohan,
Thanks for your response, is there any other way to show that message with record not found message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2023 03:39 AM
You can create an load client script and use GlideAjax to run same logic in script include. Based on result returned from script include, you can show the error message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2023 04:23 AM
Yeah I have use the on submit client script and populating the message from there but is showing only 1 second and then record not found because OOTB Query BR have more preference. Even I cannot able to find that OOTB Query BR to override that "Record not found" message.