How can we check the requested for user, if he has already raised request subsequently popup message needs to be displayed underneath respective field??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2022 05:13 AM
Hi,
How can we check if requested for user has already raised request? How can we stop submission of form if request is already existed for user who has been selected in requested for field. I tried with hidden field but I wanted to understand best approach for this requirement.
Since DOM manipulation if used in client script and will not be possible from portal and synchronous also will not be working from portal and Gliderecord should not be used in client script.
I would like to know the best approach for this.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2022 06:17 AM
Hello,
Below thread has solution , please check
https://community.servicenow.com/community?id=community_question&sys_id=e30a4d45dbe014505129a851ca96197b
Regards
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2022 08:11 AM
Hi,
try this
onSubmit Catalog Client Script
function onSubmit() {
var catitem = gel('sysparm_id').value; //This works in the native Service Catalog UI only, not Portal (getUniquieValue or something like that)
//note that gel is not best practice, but necessary in this case. Ensure the Isolate script field on the catalog client script is unchecked
var user = g_form.getValue('Requester');//assuming you have a reference variable with this name (case-sensitive);
if(g_form.getValue('ConfirmInfoReqName') != ""){
user = g_form.getValue('ConfirmInfoReqName');
}
var ga = new GlideAjax('RITMLookup'); //Name of the Script Include
ga.addParam('sysparm_name', 'getRITM'); //name of function in script include
ga.addParam('sysparm_catitem', catitem);
ga.addParam('sysparm_user', user);
ga.getXMLWait(); //generally not best practice, but necessary in this case to wait on the server result before processing the request
var answer = ga.getAnswer ();
if (answer != ''){
alert("This person already has pending request " + answer + " in the system. Only one request for a person may be open at a time.");
return false;
}
}
Next you will need to create a script include with the name referenced in the client script, ensuring that the Client callable box is checked.
var RITMLookup = Class.create();
RITMLookup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRITM: function() {
var answer = '';
var user = this.getParameter('sysparm_user');
var catitem = this.getParameter('sysparm_catitem');
var check = new GlideRecord('sc_req_item');
check.addQuery('stage', 'IN', 'Awaiting Approval, Awaiting Fulfillment');
check.addQuery('request.requested_for', user);
check.addQuery('cat_item', catitem);
check.query();
while(check.next()){
answer = answer += check.number + " ";
}
return answer;
},
type: 'RITMLookup'
});
Checkout this link: https://community.servicenow.com/community?id=community_question&sys_id=e30a4d45dbe014505129a851ca96197b
Thanks,
Yousaf
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2022 02:55 PM
Hi Lakshmiprasanna if i helped you in any way can you mark my answer helpul or correct.
Thanks,
Yousaf
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2022 06:08 AM
Hi ,
The above solution doesn't work from portal.Could you suggest how can I make it effectively to work even from portal end as well?