Creating a counter Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2024 04:52 AM
Hi Everyone,
How do i create a Counter field and Ui Action, that starts with 0 and each time i click on a Custom UI action, it increments its value by 1, so if we click on the UI action 5 times, it increases its value by 5.
Thanks,
Kartikey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2024 05:08 AM
Hi @kartikey ,
I tried your problem on my PDI and I got the solution for that, currently I'm populating the value in short description you can change it to any field.
var counter = 0;
alert("Outside Func");
function counterInc(){
counter++;
alert("Inside Func = " + counter);
g_form.setValue('short_description', counter)
g_form.update();
}
Please mark my answer helpful and correct if it helps you.
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2024 05:31 AM - edited ‎04-09-2024 05:43 AM
Hi @Community Alums
it does not quiet work properly, because if i save a form at count 2, and then again click on UI action button i guess it is starting the count from beginning
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2024 06:22 AM
Hi @kartikey ,
Yes I got the problem and now check this code it is working fine
var c = g_form.getValue("u_counter");
function counterInc(){
c ++;
alert("Inside Func = " + c);
g_form.setValue('u_counter', c);
g_form.update();
}
Please mark my answer helpful and correct if it helps you.
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2024 06:12 AM
Hey @kartikey ,
Create a field named "Counter" and put the default value as 0.
Then create UI Action and get the value of field var counter = g_form.getValue("counter");
counter++;
g_form.setValue("counter",counter);
g_form.update();
Please let me know if you have any questions.
Thanks,
Brahm