The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Gaurav Shirsat
Mega Sage

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.

find_real_file.png

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:-

find_real_file.png

Here is our Topic, which we have created.

find_real_file.png

then we have provided him the details about the Catalog item and asking him/her if he/she want to proceed.

find_real_file.png

based on his Yes, we are proceeding.

question is for logged in user or any of his office mates:-

find_real_file.png

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.

find_real_file.png

below we are following one by one catalog item variable information gathering.

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

adding more users, details are hidden.

find_real_file.png

find_real_file.png

find_real_file.png

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/

 

 

Comments
Ajaykumar1
Tera Guru

Thank you Gaurav, very helpful content.

Code Edit
Mega Explorer

It Helped a lot,Great Content!

Shivam Pawar
Tera Contributor

Helped a lot,thanks Gaurav!

Gaurav Shirsat
Mega Sage

Thanks a Lot.

I would Request you to Try this in your PDI, if you are Virtual Agent Person.

Refer other stuffs too

https://community.servicenow.com/community?id=community_article&sys_id=2750d18ddb85a0109e691ea668961...

https://community.servicenow.com/community?id=community_article&sys_id=8ffacb6ddb18f010414eeeb5ca961...

Mark my Response as Correct or Helpful, if you find it Appropriate.
Gaurav Shirsat
https://www.linkedin.com/in/gauravshirsat/

Rohit045
Tera Contributor

Very helpful content.

Shailesh Bachha
Tera Expert

Nice content, very Helpful

Savita vilas ka
Mega Explorer
Nice content helpful ty😊
Paritosh
Giga Expert

Nice , thank you!!

Renuka7
Giga Explorer
Very helpful, Thanks Gaurav
Harsha M V
Tera Contributor

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

servicenow trrr
Tera Contributor

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

Gaurav Shirsat
Mega Sage

Hello @servicenow trrr 

You can write this code in Topic of Virtual Agent. use Script Action Activity for Writing Code.

Thanks

Gaurav

servicenow trrr
Tera Contributor

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

Gaurav Shirsat
Mega Sage

Keep me Posted. If not done, will see.

servicenow trrr
Tera Contributor

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

Shubham Zanwar
Tera Contributor

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.

 

shubham333_0-1702892282560.png

 


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. 

var rawDate = vaInputs.date_of_service_2.getDisplayValue();
var formattedDate = gs.dateGenerateFormat(rawDate, 'MM-dd-yyyy');
catItem.setVariable(myCatalog, 'date_of_service', formattedDate);

Can you please give me the proper solution for this?



ritesh_k18
Tera Contributor

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?

Ramya Neelam1
Mega Guru

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.

Version history
Last update:
‎12-17-2021 07:48 PM
Updated by: