When working with data driven blocks like Excel or Web Service you often want to use data from these blocks in other blocks. Let's say you have a data feed containing Twitter profile names and you want to show the Twitter timeline in your app based on a selection made by the user.


In this how-to we will explain how you can reuse data from your data block in other (child) blocks.



Note: We are using a demo file during this how-to. You can download it at the bottom of this article. 



Prerequisites


  • An app containing an Excel or Web Service block (you can also use the attached demo file to create an Excel block);


How To


In this article we will show you how to use data from the attached demo file in other blocks. In this specific case we will be using the twitter profile name to load the associated timeline in our twitter block.


  1. Go to http://design.appmachine.com and sign in.
  2. Open the app containing the Excel or Web Service block you want to use data from;
  3. Select the Excel or Web Service block;
  4. First you need to determine the name of the field you would like to use; in this case the field containing the twitter account name. Once you have selected the Excel or Web Service block you see a list of all the available fields;
  5. In this case the name of the field we need to use is called "Twitter";
  6. Make sure the Excel or Web Service block is selected and click the "Add block" button.
  7. Select the Twitter block (or the block you would like to use);
  8. Click "Add block";
  9. In the next screen you will be prompted to enter the name of the Twitter account you would like to show in your app. This is where the magic happens. We won't be adding a valid Twitter account name but we will reference the Twitter field from the Excel block;
  10. Enter a in the text field next to the large "Connect" button.
  11. Once you entered the { character a menu will appear showing all the fields from the selected Excel block. The only thing you have to do is select the appropriate field, in our case Twitter;
  12. Once you've selected the correct field the result will look like this:
  13. Click "Next";
  14. Enter the name of this block, and click "Finish";
  15. The Twitter block will be placed underneath the Excel block, and will be shown as a detail screen for you Excel block;


Some additional info


So, what is actually happening when you use {data:Twitter} as the value of the Twitter account name property? Well, when you place any type of block underneath an Excel or Web Service block you will always be working with one entry (record) of your data.
When entering the text {data:FieldName} (where FieldName should be replaced with the name of your field) you are actually referring to the value of that specific field in the selected entry (record).


So when opening a block in your app, AppMachine will automatically replace everything starting with "{data:" and ending with "}" with the value of the referenced field.


Adjusting the title of a block


You could also use this feature to adjust the name of your building block by simply referring to a field in the title of your block like this:


Relational data


Let's say you are working with relational data. In the attached demo file there is also a sheet available called Agenda. And each entry in the sheet Agenda has a related Speaker. If you want to access data from the Speaker object, how would you do this?


It is actually pretty easy. We've applied the same trick, and the apps looks like this right now:



Now I want to do the same, showing the Twitter timeline of the speaker, so when I repeat the steps above, the result of step 11 will look like this:



In the screenshot above we are referring the field Twitter in the speakers sheet. So using . will indicate a relationship where speakers is the name of the related object / sheet and Twitter the name of the field in the related object.


Attachments


  • Excel demo file