How to fetch available for records from the service catalog

Ashok32
Tera Contributor

Hi All,

 

I want to fetch the list of "available for"  from the service catalog table. Whenever "Available for" is not empty, then the default user (test_user) need to be added in the "available for".

For Example, X user is added into the "Available for" at the time, test_user also need to be added along with X user for that catalog. 

 

Thanks in advance 

 

2 REPLIES 2

BharathChintala
Mega Sage

@Ashok32 I hope you already know how available for works. If you create a user criteria we can use it same criteria for n number of items. so it will impact other who using that user criteria if you implement this.

 

So get clarity on requirement first with team. I am giving you script to get sys_id of cat item and sysid of user criteria added for it. I have filtered only items where there is at least one available for only

BharathChintala_1-1676395262833.png

 

If you want to add test_user to all them. I suggest you,  not to add user to all criteria's instead create 1 new user criteria manually  and with simple script you can add that criteria to list of cat items (using sysids ) you get from script. and add that criteria.

 

So existing criteria will be there and new one also will be added. You can add multiple user criteria to a item and anyone met it will be available for that criteria.

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

Laszlo Balla
Mega Sage
Mega Sage

The 'Available For' related list is showing user criteria records, not user records (that would be the "legacy" 'Available For User' related list). Is this what you are referring to?

If so, you can simply query the 'sc_cat_item_user_criteria_mtom' table. You can create a business rule to run after an Insert action, check if there are already records on the table for the same Catalog Item, and if no, create a new record with the same Catalog Item and the test_user user criteria (sys_id of the user criteria record).

 

In case you are looking do this on the old 'Available For User' table, the process is the same, only the table is different: sc_cat_item_user_mtom.