Accessing variables from a given user's cart (before REQ or RITM is created)?

andrew_lawlor
Giga Expert

Is there any way to access a given request item's variables in the Service Catalog via script, before that user checks out (that is, before the REQ and RITMs are created)? I want to perform some validation, but I need to grab a value from one of the mandatory reference field variables   that belongs to a Catalog Item.

I've looked through all of the OOB Script Includes involving Service Catalog cart manipulation, as well as the sc_cart_item table and various other tables. No leads yet. Is anyone willing to shed some light on this issue?

I know the values are stored somewhere -- as they can be displayed from the 'Edit Cart' page. Are these values accessible via script, or is the code to access these values at this point not exposed?

Thanks!

1 ACCEPTED SOLUTION

russell_miller
Kilo Guru

Hi Andrew,



You should be able to get at them, the items in the cart are linked to the sc_cart records.



If you look at one of these (on sc_cart_item) they have the variables for the item listed and they reside on sc_item_option.



These sc_item_option records are linked back to the cart item via the "cart_item" field (display value is the sys_id of the cart item record)



You should be able to put a query together that will grab the cart, find the item, and get the variable value.



Hope that helps.



R


View solution in original post

7 REPLIES 7

This was very helpful, thanks for sharing!


Thanks Russell and Andrew.   I had the exact same need and combined both of your answers into a working solution for my needs.   It works perfectly!



Thanks for sharing.


bernyalvarado
Mega Sage

Hello, it sounds like you can accomplish the validation that you want to perform through an OnSubmit "Catalog Client Script".


You can access the catalog item variable by doing a:



g_form.getValue('your_variable_name');



Hope it helps!



Thanks,


Berny