Automate

 View Only
  • 1.  Rule execution in repeating table question

    Posted 04-24-2023 04:50

    Hello! 

    I'm currently facing an issue with loading and running rules on a repeating table.. 
    I am loading data from a SQL query into a repeating table. This table has some rules on two fields. 
    How do I stop the rules from executing before the query has been successfully loaded? 
    The way the logfiles shows, it looks like the rules run multiple times for a line and the numer of lines grows progressively as the table is loaded.

    Example:
    Run rule for field [0], then, later, run rule for field[0] and run rule for field[1] and so on.

    It seems that these rules (at least this is what the Blackbird log is showing) are really slowing down this form. (It takes around 3 minutes to load 16 lines with around 80 columns each). I did a test without any rules and it takes far less time (around 20 seconds). 

    Any help or advice is greatly appreciated! :D 
    Thank you! 



    ------------------------------
    Florin Dumitrescu
    Carestream Dental LLC
    Atlanta GA
    ------------------------------


  • 2.  RE: Rule execution in repeating table question

    Employee
    Posted 04-24-2023 07:59
    Edited by Hammad Naeem 04-24-2023 07:59

    Hi Florin,
    Simplest solution would be to move the rules from the form fields to a button click.
    you can run your query to fetch the data on start (i.e. on form load).
    once data is loaded, you can click on the button to run the rules.

    In case you use a custom code to iterate through all the fields of repeating table here is a piece of code that can help :

    -------------------------------
    var rows = count('/my:myFields/my:Repeating_Table_2/my:Repeating_Content/my:field_1') // fetch number of rows in repeating table.

    for(var i = 0;i< rows; i++)
        {
    $form.setValue('/my:myFields/my:Repeating_Table_2/my:Repeating_Content['+i+']/my:field_1',$form.getValue('/my:myFields/my:Repeating_Table_2/my:Repeating_Content['+i+']/my:field_2'));
                    }
    -------------------------------
    in above example, data is picked from field_ 1and is set to field_2 of the repeating table.

    Hope this helps.

    Regards

    ------------------------------
    Hammad Naeem
    Precisely Software Inc.
    ------------------------------



  • 3.  RE: Rule execution in repeating table question

    Posted 04-24-2023 08:22

    Hello Hammad, 

    Thank you for your reply and suggestion! 

    This would have been the route I would've taken normally.. 
    However, the rules I am talking about need to be triggered by a checkbox on the rows of the table as the example below: 

    The rules I am talking about are located on a checkbox like this and they need to execute when the box is checked. 


    Thanks,



    ------------------------------
    Florin Dumitrescu
    Carestream Dental LLC
    Atlanta GA
    ------------------------------



  • 4.  RE: Rule execution in repeating table question

    Employee
    Posted 04-24-2023 08:47

    Hi Florin,
    Uncheck 'Run Rule on form load' property for the rule and then test the scenario.

    Regards




    ------------------------------
    Hammad Naeem
    Precisely Software Inc.
    ------------------------------



  • 5.  RE: Rule execution in repeating table question

    Posted 04-24-2023 10:08

    Hello Hammad, 

    Thank you for your suggestion! 
    I was able to squeeze an extra minute of loading time by disabling this option for all the rules. 
    Thank you! 



    ------------------------------
    Florin Dumitrescu
    Carestream Dental LLC
    Atlanta GA
    ------------------------------



  • 6.  RE: Rule execution in repeating table question

    Employee
    Posted 04-24-2023 10:50
    Edited by Sigrid Kok 04-24-2023 10:56

    Hi Florin

    Hammad had great suggestions!

    I've had some challenges in this area myself. I've used other fields and helper fields in the past, and sometimes JavaScript.

    I have a somewhat complex demo for cost center creates and/or updates (multiple, thus in a table), as well as assigning or moving them to different cost center groups.  I wanted it to be as dynamic as possible, so nearly everything is a live query or lookup.

    I was able to use a rule like this (below) to have a rule run to lookup the current cost center group, which has been loaded into a repeating group from a query script. 

    I thought I was going to have to use JavaScript to trigger it, as it wasn't working reliably on each row, but this method works great.

    For you, you'd use the checkbox value in the condition, and then the rules can be on the field you are trying to set/calculate/modify.

    The rule itself looks like this - choose Execute rules on field, and then choose the field that has the rules you want to fire:  

    CurrenctCCGroup has a rule to find the group and set it from the query results


    Hope it's helpful.

    Best Regards,
    Sigrid



    ------------------------------
    Sigrid Kok
    Precisely Software Inc.
    ------------------------------



  • 7.  RE: Rule execution in repeating table question

    Posted 04-25-2023 03:42

    Hello Sigrid, 

    Thank you for your input! :) 
    The form I am working on right now is a Material master Create / Extend form, so I think that's at least as complex as cost centers.
    I've already tried moving the rules to a different field and using a for function to run them, but there wasn't really any improvement.

    It might just be that loading 50+ fields, 20+ rows does take a little while longer in Evolve than it used to in Designer/Infopath (I'm coming straight from that version).. Right now, with all the optimisations, I'm down to around 2:30 minutes for all the rows. I know it might sound like not a lot of time, but it's a bit annoying for the people who will use this form day by day.
     
    I'm waiting for a reply on a ticket created on this matter, hopefully we'll be able to get it down to maybe around 1 minute.



    Thank you! :)



    ------------------------------
    Florin Dumitrescu
    Carestream Dental LLC
    Atlanta GA
    ------------------------------



  • 8.  RE: Rule execution in repeating table question

    Employee
    Posted 04-25-2023 10:19

    Hi Florin
    I can appreciate moving the rules and adding them to multiple places.   The above combination works every time using the execute rules on field and apply the rule on the field you are setting. 
    That cuts down on load time, and removing the default of run on load helps, as you found out.  Most rules don't need to run on load time.
    Best Regards,
    Sigrid



    ------------------------------
    Sigrid Kok
    Precisely Software Inc.
    ------------------------------