count how many times a button is clicked from portal

Sanchita02
Tera Contributor

Hi ALL,

 

I have a requirement that I have a button on my portal when we click on button there is a popup asking to fill some ID. When we fill the ID if check from the table if the ID i have filled is correct or not. If it is wrong it shows the error message Till here i have developed. I need help for my further requirement which is if the used is typing wrong ID more than three time a task should be generated. So, How can we track the number of times the user has given the wrong ID. Please help me with the code 

1 ACCEPTED SOLUTION

1) you can declare one count variable on top i.e c.count=0;

2)  In else part of code just do

  c.count++; // and after this compare with number you would like to have

  if(c.count == 3)

{

var gr = new GlideRecord("CTASK");

gr.initialize();

gr.some_field="working"; // you can use here your field to pre populate some value if needed.

var sysID = gr.insert(); // It will return sysId of task created;;

console.log(sysID+" sysId of record");

}

 

please mark this correct if it is helpful!

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Sanchita02 

how is that button created? is that a UI action or some html button?

please share some screenshots and details

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sanchita02
Tera Contributor

Hello @Ankur Bawiskar ,

 

This button is created in portal using widget.

 


<button ng-click="c.pop(key.sys_id, key.asset_tag)"
uib-tooltip="Click here to verify the asset." style="background-color:#006400;color:white"
type="button" class="btn verify-button">Verify</button>

 

 

hi @Ankur Bawiskar 

 

This button is created in portal using widget.

 


<button ng-click="c.pop(key.sys_id, key.asset_tag)"
uib-tooltip="Click here to verify the asset." style="background-color:#006400;color:white"
type="button" class="btn verify-button">Verify</button>

@Sanchita02 

is that a catalog form which user will submit?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader