Search code examples
javascriptservicenowservicenow-rest-api

Service Now: Uncaught ReferenceError: func is not defined


I have an issue when I order/add to card on one catalog service item . In fact, I am using a custom 'Catalog Client Script' on the onSubmit action to control if the customer added or not a attachment. Please find below my client script: client script

Script configuration: Script Configuration

The error when I order/add to card: Error order

I already targeted the cause, it's when I check the 'Applies on a Catalog Item view' (second image), but i need this to trigger the order and execute my script.

Do you know how to solve this?

Thank you.


Solution

  • Solution: 'gel' is just a shortcut for " document.getElementById ", it's javascript function. But and unfortunately, to manipulate my form, i need to use GlideForm client-side API which provides methods for managing form. So I replaced:

    var cat_id = gel('sysparm_item_guid').value;

    by

    var cat_id = g_form.getValue('sysparm_item_guid');

    It works now.