Order a Catalog Item via Virtual Agent
Order a Service Catalog Item via Virtual Agent:-
Currently we don't have the OOB Provision to order a catalog item directly through virtual agent.
I have customized it for with the help of cart API and chat modules that we have.
Below I showing first the use case of Creation of Distribution List Catalog Item.
You can see all the variables which need to be mandatory or also as per UI Policy, how they are visible or Customized auto population all will be taken care.
Now we will see below one by one how we have configured the Service Catalog Item View in conversational manner in Virtual Agent.
we are greeting the user and asking him for the topic choice:-
Here is our Topic, which we have created.
then we have provided him the details about the Catalog item and asking him/her if he/she want to proceed.
based on his Yes, we are proceeding.
question is for logged in user or any of his office mates:-
will go for selected user correct or not? here we are provided text input for taking input followed by reference input searches for detailed received.
below we are following one by one catalog item variable information gathering.
adding more users, details are hidden.
PFA for Overall View of Topic we have created.
(function execute() {
var arrVariable=vaVars.sysID.split(",");
var size=arrVariable.length;
//Cart API is below var cat=GlideGuid.generate(null); var catItem=new Cart(cat); var myCatalog=catItem.addItem('3781627adb50a34026db80ab0b96197f',1); if(vaInputs.self_or_on_behalf=="someone") { catItem.setVariable(myCatalog,'u_reqfor_name',vaInputs.user_); catItem.setVariable(myCatalog,'u_reqfor_email',vaInputs.user_.email); catItem.setVariable(myCatalog,'u_reqfor_location',vaInputs.user_.location.getDisplayValue()); catItem.setVariable(myCatalog,'u_reqfor_department',vaInputs.user_.department.getDisplayValue()); catItem.setVariable(myCatalog,'u_subject_request','Distribution list'); catItem.setVariable(myCatalog,'u_req_type','New'); catItem.setVariable(myCatalog,'name_destribution_list',vaInputs.distribution_list); catItem.setVariable(myCatalog,'distribution_name',vaInputs.distribution_list); catItem.setVariable(myCatalog,'u_new_email',vaInputs.user.first_name+"."+vaInputs.user.last_name+"@"+vaInputs.domain_select+".com"); catItem.setVariable(myCatalog,'u_distribution_required',"global"); catItem.setVariable(myCatalog,'u_desired_domain',vaInputs.domain_select); catItem.setVariable(myCatalog,'u_new_owner',vaInputs.owner_for_distribution_list); catItem.setVariable(myCatalog,'u_all_business_justification',vaInputs.business_justification); catItem.setVariable(myCatalog,'u_new_access',arrVariable[1]); //catItem.setVariable(myCatalog,'u_new_access',vaInputs.access_given);//sysID var rc =catItem.placeOrder(); //catItem.setVariable(myCatalog,'u_all_business_justification',vaInputs.business_justification); // var rc =catItem.placeOrder(); var grRITM = new GlideRecord("sc_req_item"); grRITM.addQuery("request", rc.sys_id+""); grRITM.query(); while(grRITM.next()) { vaVars.ritm_sysID = grRITM.sys_id;} } else (vaInputs.self_or_on_behalf=="self") { catItem.setVariable(myCatalog,'u_reqfor_name',vaInputs._user); catItem.setVariable(myCatalog,'u_reqfor_email',vaInputs._user.email); catItem.setVariable(myCatalog,'u_reqfor_location',vaInputs._user.location.getDisplayValue()); catItem.setVariable(myCatalog,'u_reqfor_department',vaInputs._user.department.getDisplayValue()); catItem.setVariable(myCatalog,'u_subject_request','Distribution list'); catItem.setVariable(myCatalog,'u_req_type','New'); catItem.setVariable(myCatalog,'name_destribution_list',vaInputs.distribution_list); catItem.setVariable(myCatalog,'distribution_name',vaInputs.distribution_list); catItem.setVariable(myCatalog,'u_new_email',vaInputs.user.first_name+"."+vaInputs.user.last_name+"@"+vaInputs.domain_select+".com"); catItem.setVariable(myCatalog,'u_distribution_required',"global"); catItem.setVariable(myCatalog,'u_desired_domain',vaInputs.domain_select); catItem.setVariable(myCatalog,'u_new_owner',vaInputs.owner_for_distribution_list); catItem.setVariable(myCatalog,'u_new_access',arrVariable[1]); catItem.setVariable(myCatalog,'u_all_business_justification',vaInputs.business_justification); var rc=catItem.placeOrder(); var grRITM = new GlideRecord("sc_req_item"); grRITM.addQuery("request", rc.sys_id+""); grRITM.query(); while(grRITM.next()) { vaVars.ritm_sysID = grRITM.sys_id.getValue();} }
Feel free to ask in case of Query
https://www.servicenow.com/community/virtual-agent-nlu-articles/order-a-catalog-item-via-virtual-agent/ta-p/2306732