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: "Primary button clicked" handler doesn't update record

ronro2
Tera Contributor

Hey guys! 

I have a problem with updating the state of a record from a specific table in our instance. It should be dynamic, since there are various cards (in a "Carousel"), so there are various cards which have their own buttons. 

 

Here comes a screenshot of my Primary Button Clicked handler script: 

ronro2_3-1764939618704.png

Here comes the code for you to be able to copy: 

 

/**
*  {params} params
*  {api} params.api
*  {any} params.event
*/
function evaluateEvent({api, event}) {
	return {
		table: "x_vgll_rail_request",
		recordId: api.state.selectedRecord,
		templateFields: "state=7",
		useSetDisplayValue: null
	};
}

 

 

The client script called "Update Record" is empty, like this: 

ronro2_1-1764939419909.png

So is the "Client state parameter":

ronro2_0-1764942619094.png

 

So why doesn't the records' state get updated when I click on the button here in front-end? I cannot see that there is anything wrong. Here is the primary button: 

ronro2_0-1764942866692.png

 

So when "Ja" (Yes) is clicked, the state should change to closed. But nothing happens. 

I hope you can help me. 🙂 

0 REPLIES 0