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

  • Hello Amit

    Everytime you load the page and you have some filters you place the filters dropdowns on the load (because you want to load them once. Even you can load the initial information to display on the grid, in this scenario you have to load the grid information again if the user clicks a button or sort the information on the grid.

    In the same scenario above if you want the information to be updated right away after the user changes the filter then you need to load all the filters In the load, and inside that load a “with” function loading the information for the grid. In this case you don’t need to wait until the user clicks the button. When the user changes the filter the information will be updated.

    One specific example for with.
    You should use with as well in a expression rule on which you want to make some processing on the information and you want to split the logic in a “understable way”. to do that you need variables. In this case you want to ensure your variables get the proper values everytime you call the rule, let’s say in the same screen. To ensure that all the variables in that rule should be created within a “with”.

    Hope this helps

    Jose
  • Any code inside of the with() is going to be automatically re-evaluated on each action (as well as the page load) anyway, so putting a load() inside of a with() is never necessary.
  • As far as I've ever been able to tell, the only thing that matters regarding placement of load() and with() is the actual variables that you declare in them, and where you need those variables used.

    I've heard people claim for a long time that "code contained inside a with() re-evaluates", but I think this might be a bit misleading as it's just the with() variables themselves that re-evaluate, and then any components using these will adjust as necessary.

    load() is usually placed outside the scope of a with() variable as load() variables (at any level) only automatically evaluate once per form load, and thereafter their values only adjust when manually pushed from a component. the with() section (if any) is usually done inside this as it most likely needs to refer to load() variables and their potentially changing values (as changed by user input etc). But none of this is strictly required. You can have a load() and no with(), or a with() and no load(), or any combination of them at various levels, as long as they do what you need.
  • Thanks Guys for the replies.

    Regards,
    Amit
  • Hi Amit,
    To understand the actual difference on both functions I would suggest you to use one function at a time and see how the Appian respond to you.

    With just load() in your logic you can see the details in a form is loaded only once i.e. at the time of initial load.
    that means you wont be able to see any dynamic changes in your form with whatever selection you make in form and hence it is advisable t use load() only where you wish to populate details at first and should not change after once its loaded.

    Now with with() you can see your form dynamically changes with the details selected in the form (for an example consider based on your country selection the field for phone code automatic changes ) for such logic you should be using with().


    I hope this would help you better understand about both the function.

    Thanks.
  • Variables defined in load() evaluated only once whereas variables defined in with() will be evaluated for each interaction on form,However forcefully you can dynamically change the value of the variables defined on load() as well.But Performance wise load() is faster than with().you can't perform save operation over the variables which are defined inside with().
    Any consistent values should be maintained in the variables defined in load(),and variables which are expected to change its value based on given input should be defined in with().
  • Load() will occur before the with() as load variables evaluate when the page loads and with variables evaluate every time something happens on the page. I do not know of a scenario where it would make sense to need to put a load() inside of a with()