- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2022 05:02 PM
I need to create a Case through a server script where I need to set variables and a multi row variable set. I am unable to set the variables on the Case. How do I set the variables on the Case ?
Here is the sample code:
var gr = new GlideRecord("sn_customerservice_case");
gr.initialize(); gr.contact = contactId;
gr.account = accountId;
gr.category = 3;
gr.assignment_group = groupId;
gr.short_description = "test";
gr.description = "test"; // I have tried the following, but the mrvs and account variables aren't being set.
gr.variables.mrvs= "[{'c': 3}, {'d':4}]"; // There is a variable set with 2 numeric variables called c and d
gr.variables.account = "83a33530db31f810b7178d37489619e1";
gr.insert();
I tried to follow the service now documentation here but it just doesn't work: Service Now Documentation here isn't helpful (https://docs.servicenow.com/en-US/bundle/sandiego-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html
I also tried to just create records in a sc_multi_row_question_answer table after the case is created, but it didn't work as well.
Any guidance is appreciated !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2022 06:12 AM
Hello, After some research i found that this isn't possible to do! However there is a work around that works even better. Hope it is helpful.
I create a record producer which will create the multi row variable set variable in the Case record. Now i can call the record prducer using REST api using Service Catalog Rest APIs here like this:
1. Navigate to Rest API explorer
2. Pick sn_sc Namespace, Service Catalog API as the Api Name and Latest for the version
3. There is a Save a Record Producer POST api. Use the sys_id of the record producer.
4. For the payload, just navigate to the record producer catalog item on your service portal, View the network trace when you submit it. You can copy the multi row variable set payload from there and test it out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2022 08:51 PM
Hi
This article would help you with some ideas to fulfil your requirement:
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2022 10:14 PM
Hello Sandeep, In my case; I don't have a record producer or a record producer script. The scenario is that there is a UI widget that needs to create a Case upon some action in the widget. I have the option to create a case on Client Side or Server Side script; I prefer to create a Script Include that can be re-used at multiple places to create a case with some additional data within variables in that case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2022 06:12 AM
Hello, After some research i found that this isn't possible to do! However there is a work around that works even better. Hope it is helpful.
I create a record producer which will create the multi row variable set variable in the Case record. Now i can call the record prducer using REST api using Service Catalog Rest APIs here like this:
1. Navigate to Rest API explorer
2. Pick sn_sc Namespace, Service Catalog API as the Api Name and Latest for the version
3. There is a Save a Record Producer POST api. Use the sys_id of the record producer.
4. For the payload, just navigate to the record producer catalog item on your service portal, View the network trace when you submit it. You can copy the multi row variable set payload from there and test it out!