Abort on catalog request submission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 08:34 AM
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,
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 09:14 AM
Hello @Sebastien C ,
Lets rewrite the code as below and give a try,
function onSubmit() {
// Get the List Collector field value (comma-separated sys_ids)
var listCollector = g_form.getValue('list_collector_variable_name'); // Replace with your List Collector variable name
// Check if the list collector contains any values
if (listCollector) {
// Get the display values of the List Collector
var displayValues = g_form.getField('list_collector_variable_name').getDisplayValue().toString();
// Check if the display values contain the substring "CyberArk"
if (displayValues.indexOf('CyberArk') !== -1) {
// Display error message and abort submission
g_form.addErrorMessage('Submission aborted: List contains CyberArk.');
return false; // Abort submission
}
}
// Allow submission if no match found
return true;
}
Please like and accept the solution if that helps.
Thanks & Regards,
Pradeep
Regards,
Pradeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 11:45 PM
Hi Pradeep610,
I have that information on catalog client scripts after put your code:
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" Kind regards, Sebastien |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 03:12 AM
Hi @Sebastien C,
Can I clarify a few points if possible please.
First off, where exactly is this script running or expected to be called - for example, the Service Catalog (Back end and native view) or Portal / both?
You've mentioned- VA - are you referring to the Virtual Agent - again assume so.
Just as an FYI - I tested the script I provided on my PDI using the Service Catalog and native view / Portal only - not via VA.
With regards to the first message (Message 1 below and screen shot 1) - this message is displayed on every Client Script as standard, so don't let that send you down a rabbit hole.
Message 2 however: "There is a JavaScript error in your browser console" - This is of concern. g_form.getDisplayBox.value
It looks like we need to address this.
And if get getDisplayBox().value cannot be leveraged, your going to have to tweak your Script Include slightly and rather that pass and check using the display value, you'll have to use the the sys_id and and check based on this in the Script Include.
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
Screen shot 1 and message 1:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 07:05 AM - edited 09-17-2024 07:24 AM
Hi Robbie,
The submission is done exclusively on the portal.
The catalog client script is written in the request.
The test is not done only in the portal.
Could you please tell me which changes I have to operate ?
Why is it work for you and not on my platform ?
Here my version:
Build name: Washingtondc
Build date: 08-19-2024_0842
Build tag: glide-washingtondc-12-20-2023__patch4-hotfix1b-08-05-2024
Kind regards,
Sebastien