If a form is not available to a user then any other person cannot raise a request on his behalf

Garima Tripath1
Tera Contributor

Hi,

I have a requirement wherein when a person is creating a request and the requested for is some other person for whom the form is not available, I need to alert the user that a request cannot be raised for this person since the form is not available for him. Please advise on how to proceed with this.

Thanks,

Garima

1 ACCEPTED SOLUTION

Shruti
Mega Sage
Mega Sage

Hi,

If Requested for is a field on the form, try to use 'Requested For' variable type instead of reference type

find_real_file.png

 

If the Requested for user doesn't fall under the user criteria, below error message will be displayed and form won't get submitted.

find_real_file.png

View solution in original post

10 REPLIES 10

Hi,

then you can use this logic

1) onChange of that user variable use GlideAjax and pass that user

2) then in script include function use User Criteria Loader Script

use this script to get the user criteria that user satisfies; then search in that the sysId of the User criteria which is present to your catalog item

var arr = new sn_uc.UserCriteriaLoader.getAllUserCriteria(<passSysIdHere>);


var sysIdToSearch = ''; // give the sysId here

if(arr.indexOf() > -1){
return 'valid';
}
else{
return 'invalid';
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Shruti
Mega Sage
Mega Sage

Hi,

If Requested for is a field on the form, try to use 'Requested For' variable type instead of reference type

find_real_file.png

 

If the Requested for user doesn't fall under the user criteria, below error message will be displayed and form won't get submitted.

find_real_file.png

Hi Thanks a lot @StarK , this helped, could you also help me customise this error message?

Hi, 

Navigate to System UI -> Messages. Create a message entry with below values

Key -> Item is unavailable for this user

Language -> English

Message -> Enter desired text here

find_real_file.png

Hi, 

What if I want the message to be dynamic according to the requested for user.