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

Peter Bodelier
Giga Sage

Hi @Pascal P,

 

Uncheck cliënt checkbox and use gs.addInfoMessage('text') instead.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Thanks for the answer but I really need it to be Client-side. I wanted to simplify the situation by omitting details, but my UI Action also does other things, like opening a UI Page and asking user's input. As I said, It worked on the Tasks tables... so I know it is possible. I just don't know how.

You can try these bellow codes, and modify them as per your need:

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
 }
}
//Code that runs without 'onclick'

if(typeof window == 'undefined')

 runPricingBusRuleCode(); // call Server code

//Server-side

function runPricingBusRuleCode(){

 current.phase = "In Definition";

 current.u_backed_out = "true";

 current.u_cab_approved = "false";

 action.setRedirectURL(current);
}

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');