Set Variable Order on RITMs via Script

Ken83
Mega Guru

Hello Community,

I need some help with catalog item variable order when the RITM is generated programatically. When submitting a catalog item following the normal steps : Service Catalog > Fill out the form > Submit : everything is fine. When you view the RITM, the variable order is set as expected. 

The problem happens when I submit a catalog item, and a script in my workflow generates a separate RITM record containing the variables and values. The variable order is completely out of order and looks terrible. For comparison, I've included images below of each scenario. How can I enforce the same variable order in both scenarios?

CORRECT SCENARIO : 

find_real_file.png

INCORRECT SCENARIO (NEED SOLUTION)

find_real_file.png

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

I have to dig into your script. Though can already mention: we faced similar lay-out issues on the Platform UI with the Variable Editor. Caused by incorrect usage of containers. On the Service Portal this is not noticible, because only a left and right column are accepted. Though on the Platform UI, this could occur as you cans use nested containers there.

To identify where the containers go wrong, you could check the sc_item_option table. Search for the records belonging to a sc_req_item with incorrect variable lay-out, check the order values of the sc_itme_option records. This will give you easy insight in which variables are causing you issues.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

@Mark

I had done this before to no avail. However, revisiting this highlighted something that I had previously misunderstood. Here → https://docs.servicenow.com/bundle/helsinki-it-service-management/page/product/service-catalog-manag... ← the way that the variables are ordered by the system. I had updated my variables and variable sets previously. Apparently still not correctly. So, to fix the ordering, I updated the order of the variable set in the related list of the catalog item and the order once you actually open the variable set. Then proceeded to sequence the variables in the variable set to be sequential after the actual order of the variable set itself. Now between the two catalog items, the variable order is in sync and looks normal now once I generate it. Thanks for the insight. Now I just need to figure out why my UI policies are firing.