Trigger a rule in a content control

Who has never been tempted to use content control in their application? Control which allows to add an iframe in a form, allowing to insert a 2nd form inside the first one.

Several advantages:

  • Pass a parameter of the parent form to display data
  • To be able to change the content of a part of a form without reloading the complete page

Once in place, arrives the famous problematic: « Thin, how to call a rule present in the form contained in my content control ? »  🙄

The solution is quite simple, you have to go through JavaScript to set up this mechanism:

  • In the form in the content control:

[pastacode lang= »javascript » manual= »function%20SaveData()%20%7B%0A%24(‘%2300000000-0000-0000-0000-000000000000_e9f68a84-dafc-4dd8-b32f-27397cfe33e8’).click()%3B%20%0A%7D » message= » » highlight= » » provider= »manual »/]

This function JavaScript will be called by the parent form, the ID contained in my example (00000000-0000-0000-0000-000000000000_e9f68a84-dafc-4dd8-b32f-27397cfe33e8) is the ID of the button I want to call. To find these IDs, it’s easy, launch the form and use the F12 function to locate the button and retrieve its identifier.
😎 Tip: It will not change when you change environment.

  • In the parent form:

[pastacode lang= »javascript » manual= »%24(%22.content-control-iframe%22)%5B0%5D.contentWindow.SaveData()%3B » message= » » highlight= » » provider= »manual »/]

Mind you, the parent form can not know that the rule executed in the child form is complete, so be careful about expensive queries in time of execution to not close the form too quickly.

 

It’s your turn 😉

Rédiger un commentaire

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *