Skip user input from Submit a service request

Bharath38
Tera Guru

When user types utterance system identifies the Submit a service request topic and confirm if it is correct topic and if user confirm yes system asks user again to provide what they want to submit, can we instead get the previous input and display search results ?

 

Below image I want system to show results for Submit Okta request utterance instead of asking again what they are looking for.

Bharath38_1-1728579539941.png

 

I have tried vaSystem.getSearchText() before Search Input node but topic is failing.

 

Any idea @Mark Roethof @Victor Chen @Chris D 

 

 

 

5 REPLIES 5

Chris D
Mega Sage
Mega Sage

What do you mean by "topic is failing"? vaSystem.getSearchText() should be exactly what you need. We do something virtually identical in a topic: it starts with a search_text user input with a Hide condition if vaSystem.getSearchText().length < 20 (you could also just skip this node if an utterance exists). And then in the following search input (it's actually the Contextual Search topic block), it's just a simple script:

 

(function execute() {
    //if the search text was not provided, use the VA utterance
    var search = (vaInputs.search_text) ? vaInputs.search_text : vaSystem.getSearchText();
    return search;
})()

 

This is where that script is for context:

ChrisD_1-1728594319230.png

 

 

Thank you for the reply, this is what I have done but topic goes to infinite loop with empty search.

 

Bharath38_1-1728612559789.png

Bharath38_2-1728612566784.png

 

Bharath38_3-1728612578600.png 

Bharath38_4-1728612699067.png

Node gets skipped however search term is not set and blank name is sent to Request catalog item topic block.

 

Not sure what I'm missing. Thank you!

I'm a bit unsure what you're doing with four text inputs in a row that all seem to be getting a search term from the user - whether or not it is related to this issue, it seems you're complicating things more than they may need to be...

 

I presume that last script you're showing (part of) is from "Set Search Term" script action? Can you share that complete script? And also show us what the "search" (or whatever it's called) input of the "Search Catalog Item" topic block is.

That's the OOB script  🙂 on Submit a request topic,  all that I'm trying to do is skip Search Input node and pass vaSystem.getSearchText() as input and display results.

 

Bharath38_0-1728654380432.png

 

complete script from OOB for Set Search term

(function execute() {

    vaVars.search = vaInputs.search.toString();
    vaVars.search_catalogitem = vaInputs.search_catalogitem;
    vaVars.search_hardware = vaInputs.search_hardware;
    vaVars.search_software = vaInputs.search_software;

    if (vaInputs.search != ''){
        vaVars.direct_search = true;
        return;
    }
        

    if (vaContext.getRequesterLang() == 'en') {
        var gr = new GlideRecord('sc_cat_item');
        gr.addActiveQuery();
        gr.addQuery('name', vaInputs.search_catalogitem);
        gr.query();

        while (gr.next()) {
            vaVars.catalog_item_id = gr.getValue('sys_id');
            vaInputs.catalog_item_id = vaVars.catalog_item_id;
        }
        
    } else {

        var gr = new GlideRecord('sys_translated_text');
        
        gr.addQuery('value', vaInputs.search_catalogitem);
        gr.addQuery('tablename', 'sc_cat_item');
        gr.addQuery('language', vaContext.getRequesterLang())
        gr.addQuery('fieldname', 'name')
        gr.query();

        while (gr.next()) {
            var gr2 = new GlideRecord('sc_cat_item');
            gr2.addActiveQuery();
            gr2.addQuery('sys_id', gr.getValue('documentkey'));
            gr2.query();
            if (gr2.next()) {
                vaVars.catalog_item_id = gr.getValue('documentkey');
                vaInputs.catalog_item_id = vaVars.catalog_item_id;
            }
        }
    }

    if (vaVars.search_catalogitem != null) {
        if (vaVars.search_hardware == '' && vaVars.search_software == '')
            vaVars.hardware_software_entity_mapped = false;

        else
            vaVars.hardware_software_entity_mapped = true;
    }
})()