Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

TypeError: api.data.gform.setValue is not a function

Tadz
Kilo Sage

Hi,

 

I'm doing a development work on UI Builder and I stumbled on this issue.

TypeError: api.data.gform.setValue is not a function

 

As per documentation we can setValue for the ui builder form via api -api.data.<data_resource_id>.setValue(Object payload)

 

 

https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/...

 

However its throwing this error "TypeError: api.data.gform.setValue is not a function" when I do a try catch to check why it was not working.

6 REPLIES 6

Mark Manders
Giga Patron

Can you share your exact script?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

api.data.gform.setValue({fieldName: 'short_description', value: 'short description'});
The name of the controller is gform
Tadz_0-1737993302646.png

 

Hi @Tadz ,

 

Try giving keywords in single quotes as well.

api.data.gform.setValue({'fieldName': 'short_description', 'value': 'short description'});

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Kevin83
ServiceNow Employee

I believe the function is `setFieldValue`

Screenshot 2025-01-27 at 1.47.40 PM.png


try:

`api.data.gform.setFieldValue('short_description', 'short description');`