Best Practice on Reusing forms

Hi,

I would like to ask whats the best practice in using Reusable SAIL forms?

 

For example there are 3 forms. 

Form1 - Contains Details (editable)

Form2 - Contains another details (editable)

Form3 - Holds both Form1 and Form2 (sort of a container)

 

Form1 and Form2 have Load() part and Form3 as well.

Is it okay to have Load() in each form?

I notice that the data in Form1 and 2 does not refresh until I reload browser the entire UI (Form3).

 

Is it a good practice to have Load on the Reusable UIs (Form1 and 2) ?

 

Thanks!

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    You can have nested loads, but you need to be careful in your approach. As you have noticed, load variables will not refresh regardless of where they are in your interface hierarchy. An exception to this would be load variables within a!applyComponents().
  • I haven't come across an explicit best practice that talks about how load() should be used for reusable UIs/nested interfaces but I've been a fan of keeping all my local variables on the main form (if possible). Within Form 1 and 2, they would be referenced as ri! inputs. This approach helps me keep track of code when I'm either developing or reviewing. Here's an example:

    ----Main Form-----
    load(
    local!variable1:123,
    local!variable2:456,
    local!variable3:789,
    local!variable4:012,

    a!formLayout(
    firstColumnContents:{
    rule!form1(
    variable1:local!variable1,
    variable2:local!variable2
    ),

    rule!form2(
    variable3:local!variable3,
    variable4:local!variable4
    )
    }
    )
    )

    ----End of Main Form-----


    ---- Within Form 1----- inputs: ri!variable1, ri!variable2
    a!sectionLayout(
    firstColumnContents:{
    a!textField(
    value:ri!variable1
    ),
    a!paragraphField(
    value:ri!variable2
    )
    }
    )
    ---End of Form 1 (The same would be for Form 2) -----

    If the local variables aren't doing anything heavy (such as nested queries that retrieve several rows), then this approach is fine, otherwise, for performance, I would at least parse out "when" these local variables are declared/initialized within the main form & don't forget to use with() wherever needed (for refreshing data purposes).
  • If you desire to have the data in Form 1 and 2 refresh on interaction, you can use a with() instead of a load in those forms. This will re-evalutate the entire form upon every interaction with the form. This is useful if you need to recalculate local variables within these forms upon interaction.
  • If it is an editable form where data on form 2 changes with change in data in form 1, then use with(). We have used nested load() in dashboards etc., but in editable pages wherever form x data relies on form y's data, we have used with()