Now that we successfully set up a POST and GET web service block combination we can look into the possibilities of editing the data that has been submitted. This tutorial will be the next step up in difficulty.
- Parts 1 and 2 of the web service tutorials need to be completed.
Section I - Add the PUT web service block
- Make note of all the fields from your POST web service block as you will need these field names for the input parameters.
- Then, select the "Info" block from the GET web service block that was created in the previous tutorial.
This will make sure that we place the block in the right location, as the PUT web service block needs to be able to use the data that the "All Reports" block retrieves.
- Add a Web service block by clicking the red "+ Block" button and selecting it from the Pro blocks tab.
- Select AppMachine as provider.
- Select the PUT option from the list of predefined web service types.
- Enter the name of your database. In our case it's "reports".
!!! Note: You can ignore the dropdown that pops up when you select the field. !!!
- Open the Objectid dropdown, scroll down and select the _id field from the "All Reports" block.
It will look something like this:
The dataprovider number may be different for your app if you've made web service blocks before.
- Next, you will need to enter all the fields from your POST/GET web services. Add the appropriate amount of fields and enter the names.
Then, click the dropdown field below the "Value" column and select all the items corresponding with the field names you added under the "Name" column:
The end result should look something like the image above. You can enter these manually as well.
- Click "Next" and confirm that the web service block has successfully been created.
It should say "True" for the success field.
- Hit "Next" again and name your PUT web service block.
- The last step we'll take in this section is to make sure that the block is in the right location:
Section II - Editing the layout for the "Edit Report" Screen block
Next we'll make sure that the fields you added in the Web service are shown and pre-populated with the data from the users' profile.
- Select the "Edit" Screen block.
- You'll find that block already has fields added, some that are familiar and others that aren't. Remove the "Name", "Objectid"and "Merge" fields as we won't be needing these.
- Next, re-order the fields in the way you want. And you're done with this section. Save and continue.
Section III - Managing access to the "Edit Report" block
This will be a short one. We only need to make sure that the registered users can reach the "Edit Report" block after they selected an item from the "All Reports" list.
This can be done by adding a button to to the "Info" Screen block and connecting a Logic action to that button that navigates the user to the Edit Report block when clicked.
- Select the "Info" Screen block and drag a button on to the layout from the "Controls" tab.
Give your button a suitable Caption and proceed to the next step.
- Double-click your newly added button to open the Logic screen.
- Click the "+" icon and select the GoTo option.
- Select the "Edit Report" block from the dropdown and hit the "Finish" button.
- Save your changes and you're basically done!