"Catalog Item Inputs (string)" field in Flow Action - How to Format This String?

Prinssi
Mega Sage

Hello Everyone,

When using the Record Producer Flow Action in Virtual Agent, how do you structure the text in "Catalog Item Inputs (string)" field?

I've tried expressing the data via JSON format, both typed and using the script option, but have not been successful in creating a record with data passed from VA.

find_real_file.png

1 ACCEPTED SOLUTION

Prinssi
Mega Sage

 

We adjusted our workflow a little bit to accomplish our goal.

 

Our intended design was to create an Incident when someone reports a broken printer through our virtual agent. Instead of using the record producer action, we used the create record action instead:

 

Prinssi_0-1707259728067.png

 

Fields (template_value) requires a string formatted as an encoded query string.  Here is the script to generate the string to pass the variables to the action:

 

(function execute() {
    var incTemplate = '';

    incTemplate += 'caller_id='; 
    incTemplate += vaInputs.user.getValue();
    incTemplate += '^u_primary_contact=';
    incTemplate += vaInputs.contact_info;
    incTemplate += '^contact_type=virtual_agent';
    incTemplate += '^category=hardware';
    incTemplate += '^u_affected_location=';
    incTemplate += vaInputs.specific_location;
    incTemplate += '^short_description=';
    incTemplate += vaVars.short_desc;
    incTemplate += '^description=';
    incTemplate += vaVars.full_desc;
    incTemplate += '^EQ';

    return incTemplate;
})()


(Note for anyone not familiar with scripting in VA: vaInputs object includes any input values from the user in the conversation, and vaVars object contain script variables).

View solution in original post

9 REPLIES 9

For me, the reason of failure was that the catalog item had variables that are not supported. If I understand it correctly, there's just a few variable types supported. If the cat item have any variable of a non-supported type it will not work.

I tested with our most basic form, which is just three variables, Single Line Text, Multi Line Text, and Select Box (without pricing).  All of which are supported types, but it still did not work.

The topic block does support 20 variable types but there are other limitations for example, Service Portal catalog client scripts can cause issues. Here are the details:

 

https://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/product/service-catalog-management...

 

The behavior of the topic block is dynamic based on the validations in the link above. If VA can support it, the bot will continue, if VA cannot support it, the bot will provide a SP link to the catalog item and end the conversation.  

Ok, I had hoped this was the way to set the cat item variables and it would have solved it all for me... 

Prinssi
Mega Sage

 

We adjusted our workflow a little bit to accomplish our goal.

 

Our intended design was to create an Incident when someone reports a broken printer through our virtual agent. Instead of using the record producer action, we used the create record action instead:

 

Prinssi_0-1707259728067.png

 

Fields (template_value) requires a string formatted as an encoded query string.  Here is the script to generate the string to pass the variables to the action:

 

(function execute() {
    var incTemplate = '';

    incTemplate += 'caller_id='; 
    incTemplate += vaInputs.user.getValue();
    incTemplate += '^u_primary_contact=';
    incTemplate += vaInputs.contact_info;
    incTemplate += '^contact_type=virtual_agent';
    incTemplate += '^category=hardware';
    incTemplate += '^u_affected_location=';
    incTemplate += vaInputs.specific_location;
    incTemplate += '^short_description=';
    incTemplate += vaVars.short_desc;
    incTemplate += '^description=';
    incTemplate += vaVars.full_desc;
    incTemplate += '^EQ';

    return incTemplate;
})()


(Note for anyone not familiar with scripting in VA: vaInputs object includes any input values from the user in the conversation, and vaVars object contain script variables).