12
Views
2
Comments
Solved
How to dynamically execute a  ListAppend on a list
Platform Version
11.0.900.1

Reactive environment 

I have  question regarding the ability to dynamically add a element to a list using the  list append. I have a  application where a user has  the ability to add a new employer(s) to their entity. The use case is that when the user's employer web page is rendered, depending on the user's employer aggregate results, the user would either have all the previously added employer(s) rendered with the ability to add new ones if needed OR if the user has zero employers, have the ability to add new employer(s).

I have this working as expected but with one exception. I would like the ability for the application to dynamically add a new empty record (element) to add an  employer record. Currently, the page is rendered but the user must click 'add employer' which has a action that executes a list append action to add the empty element to the screen. 

I would like to have logic to automatically execute this list append upon an empty aggregate returned by the system, essentially a customer that currently do not have any employers. I just thought it would be nice  to have this empty record (employer record) displayed to the user upon render verse having to click the 'add employer' button. 

Would you know of anyway to this this? Looks like I am unable to add a list append to a if statement. Would I need to call a JavaScript to execute the manually create action dynamically? Any assistance would be appreciated.


Thanks,

Otis

Rank: #2760
Solution

Hi Otis,

You do not need to use JavaScript for this. Add an OnAfterFetch to your Aggregate. In the OnAfterFetch, you could check if the Aggregate came back empty using an If-statement. Create an empty Local Variable of the Record Type you need, and append that Local Variable directly to the empty Record List. Now you have a List with a single blank Record!