When using a list display and giving the user the functionality to add multiple entries, deciding whether to save the data on add or execute a batch save depends mainly on a combination of business rules and personal preference of the developer. With K2 SmartForms these two approaches differ only in the rule specification.
Once you have created your K2 SmartObject, make sure you have at least one list method associated with this SmartObject. It can either be the default list method created by K2 or your own custom SQL Stored Procedure returning a selection of data.
Now, create a new K2 SmartForms View. Give it a descriptive name and choose “List View” under the “View Type” section. Next choose your SmartObject and select your chosen list method from the dropdown selection.
K2 Automated Testing Software
BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.
To generate your list, click on the “Generate Labels and Controls” link and choose the fields from your K2 SmartObject you want displayed. If you scroll down to the “Edit Options” section, enable list editing and set your preferences.
To save the data on add, you need to add an additional rule to the default “List item added” rule generated by K2. Add the “Execute a method for items that have been changed” action and set up the action to execute the “Create” method for all items that have been added. In the rule configuration use your original K2 SmartObject properties for the input mappings.
To do a batch save for all rows added to the list, you need to add an action after your save event (eg. button click). Then, exactly like the action added for the save on add scenario, select the “Execute a method for items that have been changed” action and set up the rule to execute the create method for all items that have been added. In the rule configuration use your original K2 SmartObject properties for the input mappings.
The create method you choose when setting up your action can, like the list method, be the default method supplied by K2 or your own custom SQL Stored Procedure.
The exact same approach can be used to update and save entries that have been edited by adding the same actions and setting it up to execute the update method for all items that have been edited.