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.

Get UI action click count

Developer14
Kilo Expert

I have a requirement to create a UI action on incident form and when the user clicks the button for 3rd time, i need to set the state to resolved and add resolution code and notes.

I created a UI action 'Caller' as form button on incident form. I am stuck at the point where i need to calculate the number of times the UI action button is clicked. 

If any one have worked on this before  could you please help me.

1 ACCEPTED SOLUTION

u_click_count can be a field of String type with default value as 0

if(current.u_click_count == '3'){

current.state = 6;
current.close_code = 'Your_value';
current.close_notes = "Your_value";
current.update();

}else{
//Increment your clicks
current.u_click_count = parseInt(current.u_click_count)+1;
current.update();

}

View solution in original post

7 REPLIES 7

SaiRaviKiran Ak
Tera Guru

What should happen for the first and second time ?

Alikutty A
Tera Sage

Hello,

You need to create a field and store the number of count and use it to determine your trigger.

if(current.u_click_count == '3'){

//Resolve

}else{

current.u_click_count = parseInt(current.u_click_count)+1;

current.update();

}

u_click_count can be a field of String type with default value as 0

if(current.u_click_count == '3'){

current.state = 6;
current.close_code = 'Your_value';
current.close_notes = "Your_value";
current.update();

}else{
//Increment your clicks
current.u_click_count = parseInt(current.u_click_count)+1;
current.update();

}

Developer14
Kilo Expert

I do not want to create any field. Can we not directly get the click count from the action button ?