need help in the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 11:36 AM
Before creation of the new queries in ‘custom application ' i have to check total how many records are present in the table for the same person who selected as requester in this current record has pending open issues, yet and i have to check if total no of records present in the system is 7 or greater then 7,i have put an alert to person who is creating this request and message should be ‘Already 7 queries are present for this requester, Please delete any previous query then try to create new one for this requester’.
i wrote onsubmit client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 12:28 PM
You'll want to move your GlideRecord query into a script include and call the script include from your client script. GlideRecord is a server side script API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 01:26 PM
Hi Pyira,
You are missing a closing "}" for the 'if' code block. But otherwise your script should work. (I have done similar GlideRecord() query in Client Scripts.) It is supported, but limited. Since you are only counting records, there is no problem. Here's an example onChange Client script for incident and the Caller field.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
// now check for active child incidents
var incr = new GlideRecord('incident');
incr.addQuery('parent', g_form.getUniqueValue());
incr.addQuery('active', true);
incr.query();
var noRecords = incr.rows.length;
if (incr.next()) {
alert("There are " + noRecords + " open child incidents.");
}
else
alert("There are no open child incidents.");
}
See how the number of records meeting the query is done above.