How can we seggregate a handler code to multiple callback functions in freedomUI?
Hello Community,
I had to write a code in the custom Handler to perform many validations based on the field values before saving a page.
Currently the handler contains almost 2000 lines of code, also it also contains duplicate lines of code in two different places.
I wanted to avoid it and need to split the code into multiple functions.
Is it possible to do it in Freedom UI?
Thanks
Gargeyi
Like
Hello Gargeyi,
In Freedom UI the best option would be - to move your large handlers logic to separate schemas and call them when required.
Here is an example how it may be done:
1) Create a custom Module, where executive code would be stored (It would be better if you use the same package. At least, make sure that the package with handlers is within dependant ones of the package with requesting schema)
2) Fill our new module with the required logic
3) Add our new module to the main Schema resources
4) Use Global functions
Example result:
As you may see on Contacts_FormPage we had "Raw Data for Global Handler" that was transformed into "Resulting Data for Global Handler" using a global method in a separate schema. This method may be called several times instead of duplicating the code.
This approach should let you optimise your methods.
Best Regards,
Dan
Hello denis,
Thankyou for your suggestion, I will try using it.
Hello Denis,
This works well, But I am not able to use Model class in the new module.
I have added the dependencies as well.
Is there any possibility to use the model class to read/Write/update the fields in the new module ?
Thanks
Gargeyi.G
I've been able to use the sdk classes, such as model, from modules without issue. Can you share some of the code for how you're using it? Also, which version are you on? I did experience some somewhat related issues with using referenced modules in 8.0.6 but were resolved in 8.0.8.
Ryan
Ryan Farley,
I am using version 8.0.8, Attaching the sample code I tried using sdk classes . When I am trying to load RoadSegment, It throws me an error saying "RoadSegment.load is not a function".
Suggest me if I am doing anything wrong here .
Hello ,
Is there a way I can use Modal classes to read data from new module?
Thanks