Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Catalog item visibility criteria

Anagha Pradeep1
Tera Contributor

Hi Team,
The requirement is that a particular catalog item should not be available to a particular title.

That is NOT Visible if job title CONTAINS "xyz".
Have implemented this using the "not available for" with the following code-

 

var rec = new GlideRecord("sys_user");
rec.addEncodedQuery("sys_idSTARTSWITH" + user_id + "^titleLIKExyz");
rec.query();
if (rec.next()) {
    answer = true;
} else {
    answer = false;
}

 

 

 

Now the ask is- unable to submit this request for a user with xyz title (tested as individual who is not a user with xyz title, added user who is user with xyz title in requested for).

 

If anyone could provide insights on this.

 

Thank you

4 REPLIES 4

Community Alums
Not applicable

Hi @Anagha Pradeep1 ,

Did you try with "CONTAINS" instead of "STARTSWITH"?

 

Hi @Community Alums ,
The starts with is sys id starts with and not the title start with. For the title its title contains itself.

Community Alums
Not applicable

Hi @Anagha Pradeep1 ,

Then you script looks good to me .

use cache.do to clear the cache and try again.

Here is a support article on the caching of user criteria https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0790108.

 

Community Alums
Not applicable

Hi @Anagha Pradeep1 ,

 

If you have any field of type Requested for then Available for/Not Available for criteria will apply to this field and you will not be able to submit request for that user. On selecting the user it will show "Item is unavailable for this user".

Use Reference field to avoid this.

 

If this solves your query mark this as correct and helpful.

Thanks

Anand