How do you set the CI of a catalog item?

geek1
Kilo Contributor

I am trying to set the configuration_item for a catalog form. I figured all I'd have to do is create a new field on my form named configuration_item and it'd feed it's way through after the form is submitted. That doesn't appear to be the case.

 

How would I get my form field configuration_item to populate that field on the requested item?

10 REPLIES 10

Hi Wendy,


Yes, we did.   Sorry for not posting.   My script was pointing to the wrong field.   We added configuration item field to the Catalog Item and then added a Run Script to the workflow being used by the catalog item.



current.configuration_item = current.cat_item.u_configuration_item;



Let me know if you need more information.


Thanks I can actually do that what I thought you were doing is updating it with a variable which i want to do. I can add it at the request level but it's letting them pick from a variety and then I want it to update the configuration item with the item they pick in the catalog request. By doing what you did I would need to do an order guide and then have them pick the variable and then have it open each of the requests. I thought there might be an easier way. Thanks


Sorry, maybe I misunderstood.   By adding the field on the Catalog Item, the CI is specific to that Item and the user never sees it on the catalog request.   We chose not to use a variable for the user to select.  


Bhavesh Jain1
Giga Guru

I agree with Mike. One small change in the code.


In the run script actiity, write below code :



current.configuration_item = current.variable_pool.v_configuration_item;


current.update();


variables needs to be replaced with variable_pool for server side scripting.


Actually you do not have to use variable_pool for server side scripting.   You can use current.variables in a workflow "Run script" activity


http://wiki.servicenow.com/index.php?title=Scriptable_Service_Catalog_Variables


Server Scripting > Scriptable Service Catalog Variables


You can use scripting to reference any variables used by a request item from any table, referencing them as:


current.variables.<variable_name>



Also, there is no need to use current.update() in a workflow "Run script" activity.


Utility Activities - ServiceNow Wiki


Note: All changes to current are automatically updated. There is no need to call current.update()