Abort on catalog request submission

Sebastien C
Tera Expert

Hi,

 

I need to abort a submission of a request.

 

The submission must be aborted if a variable List collector contains a substring

 

I added a catalog Client Scripts - printscreen in attachment.

 

Issue:

even if the list collector contains "CyberArk", the request submission is not aborted.

Also, I need to display a message when submission is aborted

 

Kind regards,

6 REPLIES 6

Robbie
Kilo Patron
Kilo Patron

Hi @Sebastien C,

 

You're not far off, this can be easily tweaked to work as required.

FYI - the getDisplayValue() method is not valid. Instead, to get the value from a reference field, use the method g_form.getDisplayBox('your_field_name').value;

 

Here's a sample script you can adapt for you use that works as required:

function onSubmit() {
    var value = g_form.getDisplayBox('your_field_name').value;
    var contains = value.indexOf("string_to_match");
	if (contains != '-1') {
        g_form.clearMessages();
        g_form.showErrorBox('your_field_name', 'Error message to display here');
        return false;
    } else {
        return true;
    }
}

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

 

Hi Robbie,

 

I have that issue by use your code:

 

function onSubmit() {
 //Type appropriate comment here, and begin script below
    var value = g_form.getDisplayBox('select_the_application_s').value;
    var contains = value.indexOf("CyberArk");
    if (contains != '-1') {
        g_form.clearMessages();
        g_form.showErrorBox('select_the_application_s', 'Error message to display here');
        return false;
    } else {
        return true;
    }
}
 
Info Message
This catalog client script is not VA supported due to the presence of the following variables in the script: g_form.getDisplayBox.value
New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure this form and add the "Isolate script" field. To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false.
 
And during the submission I have that alert:
 
"There is a JavaScript error in your browser console"