How to pass custom parameter in cart checkout into request?

Felix20
Mega Guru

Hi everybody,

I want to pass an own ID while checking out my cart. That ID should be saved in my request table.

I have an customer asset, that is shown on a page in serviceportal. I have an inventory action on that customer asset -> for example "Retire". So I click on that button on my asset detail page and are forwarded to an intermediate page where i can see all information of that inventory action -> for example what it means to retire that customer asset. When the user checks out, an Retire catalog item is added to my cart and when i checkout that cart, i want to save the customer asset id in my request table so that i know -> its an retire catalog item but which customer asset should be retired. 

I have already copied and extended the catalog checkout form widget. And i see that there are additionalparameter which are passed to "spScUtil.orderNow". I added an addtional column to request table "u_ca" which should be used to save that customer asset id. So i also added u_ca: "12312312" to that additionalparameter array but it is not save while ...ordnerNow is executed. 

Where do i need to map that parameter from ...spScUtil.orderNow to my request table? The other additionalparameter 'like special_instructions' are also saved on my request.

Best regards,

1 ACCEPTED SOLUTION

This should help you

https://www.servicenowguru.com/scripting/client-scripts-scripting/parse-url-parameters-client-script/

View solution in original post

10 REPLIES 10

Kalaiarasan Pus
Giga Sage

Let me try to understand what you currently have. You have an retire button, on clicking which you are redirecting the user to a catalog? I

f yes, the easiest way would be to pass that extra parameter along with catalog URL and read the parameter from the URL using a onload client script and set it in the variable that you want. That is the simplest solution that I can suggest without complicated editing of macro/widgets.

Hi iamkalai,

I already have done it you way. My extra parameter is already on the redirected catalog page, but I also need to persist it in database. This extra parameter need to be used in the workflow configured in my Retire Catalog Item.

Best regard

So why can't add a onload catalog client script , read and set the parameter in a variable on form? This way you can access the variable anywhere you want and persist that in database either in the same variable or copy that to a field if that is what you are after.

hmm, that would be a solution but this extra parameter is some important ID for me and it would be better to see it as part of the request table. So do you see a possiblity for this case as well?