Creating a data view input app using free form app
You may come across cases where the data view input app template is insufficient for a particular case. You can use the free form app to replicate the standard functionality of the data view input and extend it to meet your specific needs. The steps provided here will guide you on incorporating the standard functionality of an input app but is intended to be used by developers experienced with developing apps in Longview.
To create a data view input app using free form app:
- Create a new free form app.
- Open the Execute Procedure.
- Type “TEMP” in the code editor. A menu appears.
- Select TEMPLATE_DataViewInput_Execute from the menu. Standard procedure code for the execute procedure of a data view input app is inserted.
- Modify the execute procedure, as necessary.
- If the app will use any input tools (adjust values, copy across, quick input, or spreads), in the Initialize section, add:
Run PROCEDURE "VIEW\InitTools.lvpro"
- If the app will use standard validation functionality, in the initialize section, add:
Run PROCEDURE "VALD\Init.lvpro"
- To specify dimensions to include in the validation results set the variable VALD_DimensionList to the names of the dimensions to include. Enclose in double quotes and separate each dimension name with a pipe character. This is normally only used in cases where there are slice dimensions or multiple nested dimensions in the view and it may not be obvious to the user exactly where the validation error exists.
- You can add standard symbol selection to the app or incorporate it into a custom form. Symbol selection occurs before the “Create lock” section. The remaining commands in Execute Procedure should only be executed if the user clicks OK. See Generating a symbol selection form or Generating symbol selection controls.
- If the input app will use input related schedules (comments, file attachments or line-item detail), add UseInputRelatedSchedules commands as appropriate at the beginning of the Create Lock section.
- If the pattern spread is made available to the user in the app patterns must be downloaded. You can use the procedure template Patterns_Retrieve to insert the required procedure code. This must be inserted before the Show DATAAREA command.
Note: The “Determine pattern periods from data area” section should be repeated for each data area created for which pattern spread will be enabled.
- Further modifications are noted in the following steps, depending on whether the app is a single data view or tabbed data view input.
- If the app will use any input tools (adjust values, copy across, quick input, or spreads), in the Initialize section, add:
- Create the query specs. Repeat for each query spec:
- Right-click on Data Area Definitions to create a new document.
- Change the name of the document.
Note: For a single view input name, the document Main to minimize the code changes required from the template execute procedure.
- In the code block, specify the symbols to query for each dimension.
Note: Depending on the purpose of the app you might use some query specs to set locks as well.
- Modify the “Prepare for input” section of the execute procedure to create all the query areas defined.
- Create the lock specs. Repeat for each lock spec:
- Right-click on Data Area Definitions to create a new document.
- Change the name of the document.
- In the code block, specify the symbols to lock in each dimension.
- Create the lock procedure:
Note: The lock procedure is called from the code library procedure CORE\OnLock.lvpro which performs the standard control around locking.
- Right-click on Procedures to create a new document.
- Change the name of the document to “Lock.”
- In the code block enter all the Create Lock commands required to lock data areas in the app.
Note: Note Use the Create Lock template in the code editor to quickly add the commands.
- Create the refresh procedure:
Note: The refresh procedure is called from the code library procedure VIEW\OnRefresh.lvpro which performs the standard control around refreshing data areas. This procedure is called prior to the view and whenever the user clicks Refresh.
- Right-click on Procedures to create a new document.
- Change the name of the document to “Refresh.”
- In the code block enter all the Download commands required to download data into the data areas.
- If there are any calculations to perform after download, add Run MODEL commands as required after the Download command.
- After the Run MODEL commands use the Set DATAAREA command to reset the data changed indicator to false, so the user is not prompted to save changes, if the app is immediately closed.
Note: Add any models referenced in the refresh procedure by right-clicking on Models to create a document.
- Create the save procedure:
Note: The save procedure is called from the code library procedure VIEW\OnSave.lvpro which performs the standard control around saving.
- Right-click on Procedures to create a new document.
- Change the name of the document to Save.
- In the code block enter the Upload command required to submit data from the data area to the database.
- If there are any calculations to perform prior to submitting, add Run MODEL commands as required before the Upload command.
- If there are any calculations to perform after submitting, add Run MODEL commands as required after the Upload command.
- To display the user submission details after upload, add the following code:
Sample code
If Count(LVS_BATCH_IDS)
For EACH iDVI_BatchID IN LVS_BATCH_IDS
Set VARIABLE VIEW_BatchIDList = ListAppend(VIEW_BatchIDList, $iDVI_BatchID$)
Next
END If
Note: Add any models referenced in the save procedure by right-clicking on Models to create a document.
- If using validations in the app, create the validate procedure:
Note: The validate procedure is called from the code library procedure VIEW\OnSave.lvpro, when the user clicks Submit and the code library procedure VALD\ViewResults.lvpro, when the user clicks Validate.
- Right-click on Procedures to create a new document.
- Change the name of the document to Validate.
- In the code block enter the commands to execute the validations. See Writing validations for details.
- If allowing the use of the standard import tool in the app, create the import procedure:
Note: The import procedure is called from the code library procedure VIEW\OnImport.lvpro which performs the standard control around importing data.
- Right-click on Procedures to create a new document
- Change the name of the document to Import.
- In the code block insert the DataViewInput_Import template.
- Create the views. Repeat for each view required:
- Right-click on Data Views to create a new document.
- Change the name of the document.
Note: For a single view input name, the document Main to minimize the code changes required from the template execute procedure.
- In the code block enter the functions to format the view.
Note: The code editor provides templates for a data view document which can be used to provide an outline of a view document.
Note: The code editor also provides function templates for adding standard functionality available in the data view input app to your view. Add standard items such as Import and Quick Spread using Action templates.
- For any models that need to be run as the user enters data, specify them using the DynamicModel function. Use one DynamicModel function for each model to be executed. The models will be executed in the order listed in the document.
- If allowing use of the standard import tool, add the icon to the toolbar using the Action_Template_InputApp_Import in the code editor.
- For a tabbed input with multiple data views:
- Right-click on UIs to create a new document.
- Change the name of the document.
- In the code block enter the DataArea keywords required to display each view in a tab.
- Change the Show DATAREA command in the Execute Procedure to a Show UI command.
- At this point you have created a free form app that contains the standard functionality of a data view input app. Add any additional items to round out the app.
Writing validations
Validation checks are performed by testing a value in the data area against an expected value and providing a warning or error depending on whether the validation failure should prevent the user from submitting data.
Repeat for each validation:
- Create a variable to store the validation result.
Note: You can use the same result variable for each validation.
- Write an expression to determine the validation result. Store the result in the variable created in step 1.
- Write a condition to check the validation result against the expected result.
- If the validation result does not pass the check, Set the VALD_Result variable and run procedure VALD\AddResult.lvpro to add the validation failure result to the list of validation failures.
Example
Create VARIABLE val as NUM
Set VARIABLE val = Value("daMain", "BS", "$TIMEPERIODS$", "$ENTITIES$", "GL", "SCENARIOS_Working", "$CURRENCIES$")
If $val$ != 0
Set VARIABLE VALD_Result = "ERROR|Balance sheet is out of balance|$val$"
Run PROCEDURE "VALD\AddResult.lvpro"
END If
Example (multiple entities)
Create VARIABLE val as NUM
For EACH entity in ENTITIES
Set VARIABLE val = Value("daMain", "BS", "$TIMEPERIODS$", "$entity$", "GL", "SCENARIOS_Working", "$CURRENCIES$")
If $val$ != 0
Set VARIABLE VALD_Result = "ERROR|Balance sheet is out of balance|$val$|$entity$"
Run PROCEDURE "VALD\AddResult.lvpro"
END If
Next
Setting value for variable VALD_Result
The VALD_Result variable is a string list variable, set as follows (separate each item with a pipe character “|”):
- ERROR or WARNING to specify the validation failure level.
- The validation failure message to display to the user.
- The validation failure amount.
- If validation dimensions are specified, the symbol for each dimension.