Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

map and Invoke client libs to form objects

Shiva27
Level 1
Level 1

Hi,

I am trying to achieve below use-case:

1. create custom client-libs for validating field objects. Main events are validate, value commit and click.

2. I want to invoke functions written in client libs to validate the fields without writing function call or use rule-editor at all. May be via events.

3. Also, we don't want to hardcode object name in client Libs and it should apply at whole form with field type. So that we can re-use it on other forms.

 

I have created client libs which has a function test(){ if(val>10) return true;} else false; 

How can I map this field to form object without field name and without rule editor and bind it to numeric box validate event. 

1 Accepted Solution
Mayank_Gandhi
Correct answer by
Community Advisor
Community Advisor

Hi @Shiva27 ,

Here you have multiple scenarios. Let's see the recommended approach to apply validation/rules on forms.
1. Do not use client libs, just write validation in rule/code editor.
2. Use client libs-> map it to form container-> call the function written in libs via visual/code editor.
3. You want to make re-usable client libs then as well approach 2 will work fine. But you have to invoke the method from the form on certain events.

Coming to the question where you want to invoke client libs without even calling it from forms then you will not be leveraging any capability of the adaptive form. Which is not an ideal scenario.

You can create re-usable client libs and have functions that need to be called by another form but you need to invoke the method somehow. Adaptive form Validate event gives you the way to leverage error and success widget and if you do not use forms capability it will just be vanilla js.

Suggestion-> Write client libs with functions-> invoke function from form based on the logic.

Mayank_Gandhi_0-1628081486814.png

 

View solution in original post

1 Reply
Mayank_Gandhi
Correct answer by
Community Advisor
Community Advisor

Hi @Shiva27 ,

Here you have multiple scenarios. Let's see the recommended approach to apply validation/rules on forms.
1. Do not use client libs, just write validation in rule/code editor.
2. Use client libs-> map it to form container-> call the function written in libs via visual/code editor.
3. You want to make re-usable client libs then as well approach 2 will work fine. But you have to invoke the method from the form on certain events.

Coming to the question where you want to invoke client libs without even calling it from forms then you will not be leveraging any capability of the adaptive form. Which is not an ideal scenario.

You can create re-usable client libs and have functions that need to be called by another form but you need to invoke the method somehow. Adaptive form Validate event gives you the way to leverage error and success widget and if you do not use forms capability it will just be vanilla js.

Suggestion-> Write client libs with functions-> invoke function from form based on the logic.

Mayank_Gandhi_0-1628081486814.png

 

View solution in original post