Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

addFormMessage doesn't work in UI Action for custom tables

Pascal P
Kilo Guru

Hi,

I am trying to do a simple UI Action, visible in Lists, running on the Client Side, that displays a simple message. 
I tried it on the Task table, and any extended table, like Incident, and it worked perfectly. (See image below)

When I put the UI Action on a custom table I created, I get the message "Uncaught ReferenceError: addFormMessage is not defined".

 

I also tried using g_form functions, and still get an error saying g_form is not defined.

 

Is there an attribute on a configuration we need to put on our custom tables to have access to these functions ?

Thanks !

PascalP_0-1695999467301.png

 




1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Seems like something is missing on your custom table/app.  Absent finding that, try defining g_form before using it:

var g_form=new GlideForm();
g_form.addInfoMessage('Test');

View solution in original post

8 REPLIES 8

Pascal P
Kilo Guru

Hello Brad, 
It worked ! Many thanks !!

Awesome!  You are welcome!

 

 

Connect with me https://www.linkedin.com/in/brad-bowman-321b1567/

abrouf
Kilo Sage

onClick - submitForm()

abrouf
Kilo Sage

You just need the codes with onClick option:

function submitForm(){

 if(confirm(getMessage("TEST TEST TEST."))){

   // run Server Action
   gsftSubmit(null, g_form.getFormElement(), 'sysverb_insert'); // this refers to the "Action name"

 }
 else{
   return false// cancel action if confirm response is false/cancel
 }
}