Posted: 21 Oct 2015 16:53 EDT Last activity: 31 Oct 2015 7:21 EDT
Creating Sections dynamically using Activity
As part of our requirement ,we need to create the sections dynamically and for this we will be having all the properties which needs to be part of that section.Can i create the section dynamically in the activity by just building the page of Rule-HTML-Section and set all the property references in the activity.Also would like to know if there will be any compilation issues .
I have used this approach with other rule types like report definitions, data sets, and flows in the past and it works fairly well. Most of the problems that I have encountered with it are at upgrade time when the definition of the rule, which I have been creating instances of dynamically, changes. Sometimes this has resulted in existing dynamically created instances no longer working, other times it has resulted in unexpected new behavior. One way that I have found to mitigate many of the unexpected changes is to have a template instance of the rule type and after an upgrade resave the template instance. This helps to prevent new instances from being based on an outdated design. I also have used the resaved template and diff'ed the before and after of the resave to see if I might need to do a resave of the instances that were dynamically created before the upgrade.
Thanks for the reply,as you mentioned i used the same approach for RD's,RFB,DT's and its working without issues , but was skeptical about using the same approach for sections as i thought that each section has a unique id associated to it.
Could you please explain a bit more about why it is not sufficient to have a static section that includes various property-referencing-conditionals and other property references such that you can achieve the customized appearance by changing the values of your properties and hence avoid needing to change the actual definition of the section ? /Eric
I would think carefully before taking this approach. While it might be possible to achieve the desired results, you are also venturing outside the guardrails. I don't see how this could be accomplished without making assumptions about the current underlying implementation of the Rule-HTML-Section structure. We don't guarantee this will stay constant, and your implementation might break when (not if) it changes.
Due to the other various flexability mechanisms in pega (Circumstancing, Rule resolution, etc,) without knowing more about your reasons for considering this approach it is hard to know exactly what would be better.
We are 7.1.6 and we have a lot of data tables which are delegated to the business,the look and feel is same for them as for the developers.Since we have a lot of headless applications and our business rules depend a lot on the data in these tables the business wants to have an an approval process in place so that some one approves it before the instances are saved and this should apply for all the data tables .Overall there are more than 100 data tables across 6 different applications and we want to design a one click process like the application profile to enable the approval process which would provide a jump start for the teams.We provided extension points where each team can make further changes like adding validations(sever side ) /duplicate checks for certain classes .For this we have designed a flow and as part of 1st screen we want to have 2 grids one to show the instances and the second grid to hold the instances which needs to be modified.For the first grid we used section with report definition and dynamic source generation so there was no problem in cloning to other data tables from a model section(present at data- layer) as all we are changing is the class value in the section for the repeating grid.For the second grid though we have to provide the option to edit the instance and this is where the challenge is .We had the below 2 approaches in mind
1)We wanted to follow the same approach of that for grid 1 but the only difference is that we add the elements to the layout of the section using the activity .
-->Advantage of this approach the section is developer friendly in terms of adding their own client validation/formats etc.
-->Problem with this approach is that when upgrade are done there is no guarantee that these will workand it would be a maintenance night mare .
2) We wanted to have a name value pair of all the properties in the class as a pagelist and we will have a template section for each data type and then a section with a repeating grid to display the fields.
-->With this maintenance is minimal.
-->But this approach needs a transformation logic to map these name vale pairs to the original instances before saving it to the data base.Problem with this approach is that if the team has to implement specific validations for certain class it would be a challenge .
Thanks Chunzhi Hong we implemented exactly what you mentioned,probably this should be a OOTB feature .In our approach though we create the Search things mentioned by you dynamically and for create and deletion we used the OOTB rules and apart from that we have dynamically generated the excel template for the business to import the data into the grid .As i mentioned we want to make sure the time to production is minimum by generating the most of the rules.
Question :- Did you create the sections rules manually every time a new data class needed a rule approval.
Thanks for all those details. However, the details didn't convince me you need to generate section rules dynamically.
Note that section rules can use a "repeating row layout" or a "grid" to show a page list or other extensible lists, so if you have some sort of list of db tables and validation requirements, they could be shown in a repeating row layout without having to generate a section rule "on the fly".