Usage of Load()within with()

Hello Folks,

 

can anybody give me a use case/ scenario where load() function is used within a with() function.

 

Thanks In Advance.

 

Regards,

Amit

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    in reply to laurenc20
    with() variables also are initialized on page load. An example use case would be a paging grid that loops over an expression that contains a load. Your paging grid would be within a with() so that your datasubset can be updated whenever you pagingInfo changes, and the looping function that paging grid uses has a load variable to cache information and make it accessible across all evaluations of the expression.
  • 0
    Certified Senior Developer
    As stated in this topic already, there shouldn't be any valid use cases for a load() inside of a with(), unlike the opposite scenario, which definitely has its uses. In a paging grid, for example, you have the grid itself saving into pagingInfo variable in the load() and the dataSubset variable re-evaluating in the with() using the pagingInfo.
  • 0
    Certified Lead Developer
    in reply to charlesm492
    I just listed a valid use case. If your grid uses an expression to calculate some sort of value or show an icon, and that rule needs to be looped over, you could have a load() inside of the expression rule, thus a load() within the with() the paging grid is in.
  • 0
    Certified Senior Developer
    in reply to Josh
    My apologies, I had the topic open from earlier and didn't see the new response. That's an interesting case for sure.
  • 0
    Certified Lead Developer
    Hi Amit,

    Here are my inputs on this.

    Analysis 1 :
    variables declared inside load function - initiates once and value will be cached throughout the SAIL interface
    variables .declared inside with function - can be initiated first and reevaluates each time based on the dynamic logic(s) in the SAIL interface.

    Analysis 2 :
    Load() function= a local variable's variable is only calculated the first time the expression is evaluated.
    With() function= a local variable's value is re-calculated when the expression is reevaluated .
    Please visit the below link :
    docs.appian.com/.../fnc_evaluation_load.html docs.appian.com/.../fnc_evaluation_with.html

    Analysis 3 :
    load() = load the locally declared variables one-time when the task is issued. To update a load variable, a save event must save into the local variable.
    with() = load the locally declared variables each time there is a change in the form (such as field input).

    Analysis 4:
    Load() calculates local variables value only first time when the expression is evaluated and With() re-calculates local variable's value when the expression is reevaluated

    Analysis 5:
    Load is used in expressions for SAIL interfaces to allow for user interaction on the SAIL, such as sorting or paging through a grid.
    With() differs from the load() function because it recalculates the local variable values when the expression is re-evaluated.

    If an expression requires multiple evaluations of a complex value, you can use the with() function to define the value as a local variable, so it's only evaluated once.

    Analysis 6:

    Differences :
    1. You can define multiple local variable either Inside load() or with() but you can't perform save operation over the variables which are defined inside with() whereas we can save the data into a variable which is defined inside load()
    2.Performance wise load() is faster than with() because of only once execution.
    3.Variables defined in load() instantiate for only once whereas variables defined in with() will be evaluated for each interaction on form, like sort, search, input a value in field etc. However forcefully you can dynamically change the value of the variables defined on load() as well.

    Hope the above may help you to understand better regarding Load() & with().

    Thanks,
    Ravi.