How to use g_form.save() in client script

RAMANA MURTHY G
Mega Sage
Mega Sage

Hello community,

 

I wanted to use g_form.save() in onLoad catalogue client script for one scenario

 

Variable data populated from third party integration. But variables unable to read in flow. If we save the RITM form for one more time after immediate  data population from integration, flow is able to read the variables.

 

So that, I wanted to use g_form.save() in onLoad client script. But after using this it went in a loop. I wanted to know is there any best approach to use g_form.save() 

 

Or is there any approach to able to read variables in a flow after variable data populated from third party integration.

 

Thank you in advance.

 

 

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer
6 REPLIES 6

Community Alums
Not applicable

Hi @RAMANA MURTHY G ,

 

Instead of using g_form.save() in the onLoad catalog client script, you can use a GlideAjax call to asynchronously save the form data after the variables are populated from the third-party integration. This will allow the variables to be committed to the database without causing a loop.

Helli @Community Alums ,

Thank you for your quick response. Can u suggest any sample code snippet for how to save records without causing a loop using the GlideAjax call?

If we call GlideAjax from the onLoad client script, GlideAjax saves the record, then the form is again loaded, then the onLoad client script again calls GlideAjax. Again it causes a loop. 

 

Thank you

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer