Set value of field not present on form using client script.

ganeshexpert
Kilo Contributor

Is it possible to set the value of field which is not present on form but on table using client script.

 

Thanks in advance.

8 REPLIES 8

pavan_poul
Kilo Expert

Hi Ganesh,



Using g_form object we can set the value at client end but the field must be on form.


We are not able to set the value of field which is not on form at client end as this process is related to saving the data in database so it should be done at server side.(we can use the ajax call also at client end)



Thanks,


Pavan


harikrish_v
Mega Guru

Hi Ganesh,



I am not sure if this is the right way to do it. But you can update the field in a UI action and then call the action from the client script using:-



gsftSubmit(document.getElementById('action_name'));




Also, I am not sure what your requirement is exactly, but if you are trying to do this from an onLoad client script, I would recommend that you use a display Business Rule. It is exactly like an onLoad script, but runs at the server side, so you can set value for any field on your table easily




Hope this helps Please mark this post as answered if this solves your problem




Thanks & Regards,


Hari


rajiv069
Kilo Expert

Hi Ganesh,



You can set the value of the field available on the form by using the g_form object defined for client side scripting and the syntax would be


g_form.setValue('field_name', 'value');



If you are looking to set the same value on some other form then simply need to define a script include or a global business rule and then need to call same script from your client script using the GlideAjax call and can set this where ever you want to.



Thanks!


lawrence_eng
Administrator
Administrator

Hi,



For better visibility, I moved this thread out of the Community Updates & Feedback space and into the Support sub-community.



thanks,


Lawrence


-


Online Community Program Manager, ServiceNow