Skip to main content
Nintex Community Menu Bar

I have a datalabel that looks like button, it has an "OnClick" event and I can do alerts etc. so the JS is working. e.g.

 

<button onclick='alert('clicked!');'>Click Me</button>

 

What I'd like to know if it is possible to ether ...

 

(A) Call/execute a rule from the onclick event

(B) Populate another data label that when I click a K2 Button Control it can submit the new value back to SQL/SharePoint/Wherever!

 

I've been trawling the threads for a while now and can't find anything that seems to work

 

Thanks!

Hi NickW,

 

Have a query , why you are not using button control directly.

 

If you want your label to call rule on click you have to create a Custom control that will attach a click events handler to label which you can reuse everywhere you want.

 

 Here is another way around to call rule on click of dynamic button, where you have to maintain a hidden Data label (lets name it ‘dlbhdEventbutton1‘ ) and on every click on dynamic button just change its value.

Add rule when Data Label (i.e. ‘dlbhdEventbutton1‘) value is changed and inside this write you Action and condition rule.

 

Let me know if it helps you.


Hi,

 

To achieve this follow below steps.

  1. Drag and drop button control.
  2. Go to rules and add your rules that you need to execute for this button click event.
  3. Now get the id of this button by accessing developer mode (hit f12 and inspect the button)
  4. Now modify the data label script as below. 

<button onclick="javascript&colon;document.getElementById('000000*personal details removed*0000_79af447e-1e*personal details removed*f18d59d72').click()">Click Me</button>

 

** Replace 000000*personal details removed*0000_79af447e-1e*personal details removed*f18d59d72 with the button id you found in Step 3.

 

 5. For the button created at step 1, set property “visible = false”. (As we don’t require to show this button on interface.)

 

That's it, now click the data label button and you will see the rules getting executed.

 

For More Details visit : https://vijaydk2guy.wordpress.com/2017/06/02/basic-jqueryjavascript-samples-in-smart-forms/

 

Thanks,

Vijay.


Thanks but referencing raw id's isn't really a solution as soon as it's deployed to a different environment it will break due to the id changing.

 

The reason for not using a button is because i'm placing this in a list view so it is repeating X number of times and I need to be able to pass say the id of my list item to the SmartForms rule.


Control ids doesn't change when deploying to different environment as these are unique id's (GUID) which will be stored by K2.

 

when we create  a control  unique id is assigned to it and  it will be same for control untill or unless we delete the control and recreate a new one.

when we deploy package, these id will be taken as internal dependency and hence they doesn't change.

So there should not be any problem for using control ID's.

 

 

you can also use same functionality with name attribute as selector as below

script> $( '&name="labelname"] ').click(function() { $( '(name="buttonlabelname'"] ').click();});</script>


Reply