g_form.submit in Workspace Client Script not working

Community Alums
Not applicable

Hi all,

 

I'm trying to add the ability for users to create/manage change requests within the CSM/FSM Dashboard and I added some of the UI actions to the workspace (Request Approval, Implement, Review, Close).

Within the UI actions, I have the following code in the Workspace Client Script:

function onClick(g_form) {
    var actionName = g_form.getActionName();
    console.log("Action name: " + actionName);
    g_form.setValue("state", <state>);
    g_form.submit(actionName);
}
 
When I press the UI Action the first time (for example, Implement), the state field is set to the appropriate state but the g_form.submit is displaying the following within Developers tools (console):  
 
[NOACTION] Could not find UI Action: none
 
When I press the UI action again, it submits the form.  It should submit the form the first time I click on the button.
 
I've tried hardcoding the action within g_form.submit() and I am getting the same behavior.
 
Anyone else experiencing this issue?
 
 
1 ACCEPTED SOLUTION

Community Alums
Not applicable

I figured out the problem.  It was with a customized onSubmit client script that uses GlideAjax.  Within the callback function, the line g_form.getActionName() was returning "none" so within the onSubmit() function, I added a line var action = g_form.getActionName() and used the action variable within the callback function.  That seems to work.

 

View solution in original post

3 REPLIES 3

Anand Kumar P
Giga Patron
Giga Patron

Hi @Community Alums ,

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0726499

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Community Alums
Not applicable

Thanks @Anand 

I saw that KB and was hoping the issue I'm seeing was different/resolved.

 

Community Alums
Not applicable

I figured out the problem.  It was with a customized onSubmit client script that uses GlideAjax.  Within the callback function, the line g_form.getActionName() was returning "none" so within the onSubmit() function, I added a line var action = g_form.getActionName() and used the action variable within the callback function.  That seems to work.