Issue with creating order guide request using script

Sukhbir Singh2
Giga Guru

Hi 
I am using the below script to create an order guide request using scripting. It creates a request as well as the RITM according to the rule base, but it is not assigning values to the variables in the RITM. See Screenshot. What is wrong here? As per the script, phone type on the RITM should have "Samsung" in it.
Please and thanks in advance.

var inputs = {
"opened_by": "some_sys_id_of_a_user",
"requested_for": "some_sys_id_of_a_user",
"phone_or_computer": "computer",
"items": [{
"sys_id": "sys_id_of_a_cat_item",
"variables": {
"phone_type": "samsung"
}
}]
};

var sog = new SNC.ScriptableOrderGuide("sys_id_of_an_order_guide");
var result = sog.process(new JSON().encode(inputs));
gs.print("result: " + result);
if (!result) {
gs.print("Processing the scriptable order guide failed with message: " + sog.getMessage());
} else {
var request = sog.getRequest();
gs.print("Request created - " + request.number);
}

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Hi,

Have you verified that the variable name as well as the choice name are spelling/used correctly?


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi 

I updated the variable phone_type using the below script and it worked, so i don't think its a spelling issue, see screenshot below:

 

var gr = new GlideRecord("sc_req_item");
gr.get("sys_id_of_ritm");
gr.variables.phone_type = "samsung";
gr.update();

koliva
Tera Expert

I'm having the same issue.  Have you gotten a resolution to this yet?

I raised a ticket with SN, they said variables can't be populated with SNC.ScriptableOrderGuide. So we adopted the approach to create separate catalog item request using cartJS API. A flag is used to distinguish the RITMs created from portal and integration and multi-row variables are populated in the workflow. The idea to use an order guide is more of a help in the front end. In the backend, it really doesn't matter whether to use individual catalog item request or order guide. If you still need that separation, a variable as a flag can be used. Let me know if that helps.