21. Edit the Expense Claim Form (Claim Approval State)
In this step, you edit the rules for the Claim Approval State. This is the form's configuration and behavior the claim approver experiences. First, you will make the header and details controls read-only as the approver should not change any of the requester's content. The only exception is the Approver Comments Text Area, which you will leave intact so the approver can enter any comments or questions they may have. Next, you will add rules to load the originator's content into the header and details views. This provides claim details for the approver to review prior to making their decision. The last rule saves the Approver Comments back to the Expense Claim Header SmartObject, so the approver's comments become part of the expense claim record.
- Edit the form initializing rule for the Claim Approval State using the table below as a guide. If a setting is not specified, assume the default value. If you need help, expand the "Show me how..." section.
Rule Configure Notes Rule
(Edit) When the Form is Initializing
Condition
(None)
Action
(New) Specify edit state for View and Form controlsRead-only controls:
Set all fields to read-only except Approver Comments Text Area. Make the Approver Comments Text Area EDITABLE. This includes both the header and details views.NOTE: Make sure the Table control is set to Unchanged and not read-only! The table overrides all the controls it contains!
The approver should not make any changes to the originator's content. However, they can use the Approver Comments Text Area to enter any comments or questions they may have. Action
(New) Hide a Form controlSelect control:
Submit Button TableThe claim approver uses the Workflow Task view to select their decision and submit their response. Therefore, the submit and cancel buttons are not used and could be confusing. You will hide the layout table containing the buttons. Action
(New) Execute a view methodLoad originator's header view content: - (View) Expense Claim Header View
- (Method) Load
- (configure) Map the Expense Claim Header SmartObject > ID to the Input Properties > ID
You want to load the originator's header content into the header view so that the approver can review it prior to making their decision. Here, you are mapping the SmartObject ID for the current record over to the header view. K2 loads the current record into the header view using the record ID. Action
(New) Execute a view methodLoad originator's details view content: - (View) Expense Claim Details View
- (Method) Get List
- (configure) Map the Expense Claim Header SmartObject > ID to the Input Properties > Expense Claim ID
You want to load the originator's details content into the details view so that the approver can review it prior to making their decision. Here, you are mapping the SmartObject ID for the current header record over to the details view. The Expense Claim ID is the common field between the header record and the details records. K2 loads the details records that match the header record ID. - From the RULES screen, edit the Claim Approval State, When the Form is Initializing rule.
- First, you will make all controls read-only, except the Approver Comments Text Area. The approver should not change any of the originator's content. They can, however, enter any questions or comments they may have into the text area. With the Actions tab active, search for
edit state
then click Specify edit state for View and Form controls to add it to the rule definition pane. Click (configure). - On the Specify edit state for View and Form controls screen, make all controls READ-ONLY for the Expense Claim Header View and the Expense Claim Details View. Make the Approver Comments Text Area (header view) EDITABLE. Make sure the Table control is UNCHANGED. This is the layout table and it overrides all other settings, so you don't want it read-only! Click OK to save your changes.
- Next, you will hide the Submit Button Table so that the approver does not see the submit and cancel buttons. The approver has their own submit button on the view that K2 adds with the actions (such as Approved, Rejected, Rework). The original submit and cancel buttons may be confusing, so you will hide them for the approver state. With the Actions tab still active, search for
hide
then click the Hide a Form control action to add it to the rule definition pane. Click the select control link and select Submit Button Table. - The last two actions load the originator's content into the header and details views. The approver can review this content prior to making their approval decision. With the Actions tab still active, delete the search keyword so that K2 loads the default actions. Click Execute a View method to add it to the rule definition pane. Click the select View link and select Expense Claim Header View. Click the select method link and select Load. Click (configure).
- From the Context Browser, map the Expense Claim Form > Expense Claim Header View > Expense Claim Header SmartObject > ID to the Input Properties > ID. Click FINISH to save and exit this setting.
- Now, you will add the action to retrieve the details records. Click Execute a View method once again to add a second instance of this action to the rule definition pane. Click the select View link and select Expense Claim Details View. Click the select method link and select Get List. Click (configure).
- From the Context Browser, map the Expense Claim Form > Expense Claim Header View > Expense Claim Header SmartObject > ID to the Input Properties > Expense Claim ID. Click FINISH to save and exit this setting. Here, you are mapping the ID from the header SmartObject to a property in the details SmartObject. K2 returns all details records that match the header record ID.
- The form initializing rule should look like the image below. Click OK to save and exit rule.
- Next, add a new action to save the Approver Comments text area back to the Expense Claim Header SmartObject. You are editing the When the Workflow View is being submitted rule for the Claim Approver State. Use the table below as a guide. If a setting is not specified, assume the default value. If you need help, expand the "Show me how..." section.
Rule Configure Notes Rule
(Edit) When the Workflow View is being submitted
Condition
(None)
Action
(New) Execute a View methodSave approver comments: - (View) Expense Claim Header View
- (Method) Save
- (configure) Map the Expense Claim Header View > Expense Claim Header SmartObject > ID to the Input Properties > ID. Map the Expense Claim Header View > Controls > Approver Comments Text Area to the Input Properties > Approver Comments.
- (configure - continued) Map the System Values > Current Date > Current Date to the Destination > Approval Date.
You want to save any comments or questions entered by the approver back to the Expense Claim Header SmartObject. Note that "save" is the equivalent to "update" in K2 terms. You are mapping the ID as well, so K2 knows which record to update.
You will also map the system value > current date to the Approval Date text box so that you have a record of when the approver made their decision.
- Now, you will add an action that saves any questions or comments the approver entered back to the header SmartObject. With the Claim Approval State selected, click the When the Workflow View is being submitted rule, then click Edit Rule. This is the rule that fires off when the approver clicks the submit button on the Workflow Task view. K2 adds the Workflow Task view automatically. It contains the actions and the task submit button.
- With the Actions tab active, click Execute a View method to add it to the rule definition pane. Click select View and select Expense Claim Header View. Click select method and select Save. Click (configure). Save is the same thing as "update" in K2 terms.
- First, you will map the header SmartObject ID to the input properties so that K2 knows which record to update. Map the Expense Claim Form > Expense Claim Header View > Expense Claim Header SmartObject > ID to the Input Properties > ID field.
Next, you will map the approver comments control to the input properties to save any comments entered by the approver. Map the Expense Claim Header View > Controls > Approver Comments to the Input Properties > Approver Comments. - Now, you will map the current date to the Approval Data text box. This date shows you when the approver made their decision. Map the System Values > Current Date > Current Date to the Destinations > Approval Date field.
- Click FINISH to save and exit the settings.
- The Workflow View rule should look like the image below. Click OK to save and exit the rule.
- Click the Save icon to save your work so far.
Review
In this step, you worked with the Claim Approval State, which represents the form's configuration and behavior the claim approver experiences. You made the header and details view controls read-only because the approver should not make any changes to the requester's claim. You hide the layout table containing the submit and cancel buttons as the approver doesn't need the buttons and it could be confusing if they are shown. You added actions to populate the header and details views with the claim content. Finally, you added an action to save any comments entered by the approver back to the SmartObject record. You should have a sense now of how you can use the same form for multiple tasks, just by editing states. In the next step, you edit the Originator Rework State.