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.

UI Builder Client script to set form Field value

SundaramR
Tera Guru

Hello,
I have a UI Builder page with a form component, and the form controller (id=record) is set to use the incident table. I want to update a form field’s value using a client script. I tried two methods based on the documentation, but neither worked. I’m looking for guidance on how to set a form field value using a client script.

document site.

 

both of them throws method not found error.

   api.data.record.setFieldValue('short_description', 'Updated from UI Builder');

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

 

Below snippet works, but I am looking to set the value using api object. 

 

 
/**
* @Param {params} params
* @Param {api} params.api
* @Param {any} params.event
*/
function evaluateEvent({api, event}) {
	return {
		fieldName: "short_description",
		value: "Deploy Scope",
		displayValue: ""
	};

 

Thanks

0 REPLIES 0