Create action to update records
By the end of this section you will be able to:
- Create actions on Streams
- Add an action to a view
- Update a selected record with an action
- Create an action that requests values from users
Set a fixed value on records
- Open the model Dashboards and Forms 11-13. Actions to update, insert, delete
- Find the stream Wisteria Books Return Requests, and open the view Wisteria Books Return Requests – you will see a list of book return requests
- You will add an action to update records in this view – to record when return requests are refused:
- In the configuration form for the stream Wisteria Books Return Requests, go to the Actions tab
- Press to create a new action
- Give the action the following configuration:
- Name: Refuse Return
- Display Name: Refuse
- Go to the Item Updates tab, and set
- Stream Item Action: Update
- Press - Apply
- The form will update – press in the Action Attributes section
- In the Stream Action Attribute Details form:
- Select the Attribute ReturnStatus
- Set Expression to: "REFUSE"
- Press
- In the Stream Action Attribute Details form:
- Press in the main action form to save your changes
- To associate the action with a view (you will use an existing view on the Stream):
- Go to the Views tab
- Open the configuration form for the view Wisteria Books Return Requests
- Go to the Menu tab
- Press - Actions
- Select your action from the drop down list and drag it into the list of actions associated with the view
- Press to apply your changes
- To see the new action button on the view, open the view
- Test your button: select a record and press the button
- Press on the view; you will see the ReturnStatus updated
- Test your button: select a number of records and update the ReturnStatus with your button
Actions to request values from user
You will extend the action you created in the previous exercise to allow users to add to the comment on the record, when they refuse a return.
- First you need to create a form that will be used to take values from the user – in PhixFlow terms, this is known as a Form View:
- Open the configuration form for the stream Wisteria Books Return Requests
- Add a view:
- Name: Enter Refusal Comment
- Stream View Attributes: HandlingComments
- In the list of Stream View Attributes double-click on HandlingComments
- Set Width on Form to 300; Height On Form to 300
- Tick Multiline on Form
Press
The setting Multiline on Form determines the result of pressing the enter key when entering values into a PhixFlow form view. With this setting on, while the user is editing this field, the enter key will put a link break into the value being entered. While the user is in any other part of the form (except for another multiline field) pressing the enter key commits the action – the equivalent of pressing the button.
- Go to the Advanced tab
- Tick Form View
- Press to save your changes
- Open the configuration form for the action Refuse Return that you created during the previous exercise
- Set Form View to Enter Refusal Comment
- Go to the Item Updates tab
- Add an additional attribute:
- Press - Show the list of Attributes
- Drag in the attribute HandlingComments
- You will see that this is auto-populated with the expression _prompt.HandlingComments – leave this as it is, since this is the expression you need
- Press in the main action form to save your changes
This action is already associated with the view, so to test:
- Open the view Wisteria Books Return Requests
- Select a record and press the Refuse button
- In the form that pops up, enter some text into the HandlingComments field
- Press on the view
- You will see the comment update as well as the status
Create actions to insert new records
By the end of this section you will be able to:
- Create an action to insert a record
- You will need to take user input for 2 fields in the new action, so you must create a new Form View:
- In the configuration form for the Stream Wisteria Books Return Requests, go to the Views tab
- Create a grid view Add Return Request
- Add attributes to the view:
- CustomerRef
- BookTitle
- Go to the Advanced tab and tick the Form View flag
- Press
- Add attributes to the view:
- In the configuration form for the Stream Wisteria Books Return Requests, go to the Actions tab
- Press to create a new action
- Give the action the following configuration:
- Name: New Return Request
- Display Name: New Return
- Form View: Add Return Request
- Go to the Item Updates tab, and set
- Stream Item Action: Insert
- Press
- Press - Show the list of Attributes
- Drag in attributes:
- CustomerRef
- BookTitle
- ReturnStatus
- Set attribute expressions:
- (Accept the default expressions for CustomerRef and BookTitle, since we will take these values from the user in the form view)
- Update the expression for ReturnStatus to: "New"
- Press
- To associate the new action with the view:
- Open the configuration form for the view Wisteria Books Return Requests
- Go to the Menu tab
- Press - Actions
- Select the new action from the drop down list and drag it into the list of actions associated with the view
- Press to apply your changes
- Open the configuration form for the view Wisteria Books Return Requests
- To see the new action button on the view, open the view (if you already have it open, close it first)
- Test your button: press the new button, complete the details in the Form View and press
- Press on the view
- You will see a new row added
Create action to delete records
By the end of this section you will be able to:
- Create an action to delete a record
- In the configuration form for the Stream Wisteria Books Return Requests, go to the Action tab
- Press to create a new action
- Give the action the following configuration:
- Name: Delete Return Request
- Display Name: Delete Return
- Go to the Item Updates tab, and set
- Stream Item Action: Delete
- Press
- To associate the new action with the view:
- Open the configuration form for the view Wisteria Books Return Requests
- Go to the Menu tab
- Press - Actions
- Select the new action from the drop down list and drag it into the list of actions associated with the view
- Press to apply your changes
- Open the configuration form for the view Wisteria Books Return Requests
- To see the new action button on the view, open the view
- Test your button: select a record, press the new button, and press
- Press on the view
- You will see the row disappear