
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 12-17-2021 07:48 PM
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
DO Mark Helpful, Bookmark if you find it Appropriate.
Gaurav Shirsat
https://www.linkedin.com/in/gauravshirsat/
- 11,246 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you Gaurav, very helpful content.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
It Helped a lot,Great Content!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Helped a lot,thanks Gaurav!

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks a Lot.
I would Request you to Try this in your PDI, if you are Virtual Agent Person.
Refer other stuffs too
Mark my Response as Correct or Helpful, if you find it Appropriate.
Gaurav Shirsat
https://www.linkedin.com/in/gauravshirsat/
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very helpful content.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice content, very Helpful
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice , thank you!!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Gaurav,
I tried following the flow in the PDF attached, but not sure whats inside each block.
Could you please share your update set where you have done this customizations?
I will import it to my personal instance and have a look on the Topic Block which you have created, so that i get a idea step by step.
Thanks
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Gaurav,
Can you please tell me where should we write the above code .i mean where should implement this code
please provide navigation
can i write this code in business rule or in topic block else some where .
please let me know I dont know about cart jS

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello @servicenow trrr
You can write this code in Topic of Virtual Agent. use Script Action Activity for Writing Code.
Thanks
Gaurav
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks gaurav for quick reply . i will try in script activity in topic of virtual agent. I will Update you.
Thank you so much
my requirement is order a catalog item in VA. it has client scripts so variables are not passing in VA
It might helps me. if any solution is there please let me know
Thank you

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Keep me Posted. If not done, will see.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
hey gaurav i have requirement order software via VA .in my software catalog item I have 5 variables
name refers to sys_user and device refers device table
device table has more than 7000 variables and
does this cart js helps me to solve this issue
can you please let me know how to write a code in script action
as of now oob i just used serch catalog item and request catlog item blocks its working fine if item has not any client scripts and records below 7k. im getting cant find valid record
im new to virtual agnet i tried a lot but not getting any solution
can you please help me on this
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Gaurav!
This solution helps me a lot. All the catalog variables are setting up properly.
I just have one query.
I have the date variable in my catalog item which is in the MM-DD-YYYY format. So I am taking the date input from the user in the virtual agent. But as you can see in the below image its taking the date in the YYYY-MM-DD format.
So my catalog item date variable is not getting up fill properly.
To format the Date I have written the code as below, but still its not giving me proper output.
Can you please give me the proper solution for this?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Gaurav ,
Wanted to check is it possible that the service catalog items which are shown to the user should be according to the permissions they have to access that item?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Ritesh,
May I know if you found anything on your question, on how to show catalog items based on user permissions, please let me know, I am really looking for the answer.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @Gaurav Shirsat
thanks for sharing this content.
How did you add all that data Like the RITM number and all to the card at the end?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
hello @Gaurav Shirsat can you please tell me how you are retrieving the variables of your catalog item in the virtual agent? Because I have a requirement of attaching only particular variables of catalog item not all variables , I used the OOTB "request catalog item" topic block but it is giving me all the variables