Pass a variable to the data input

We now have a data input that retrieves information about the YHOO stock symbol every 30 seconds. However, if we wanted information about other stock symbols, we'd need to create a separate data input for each symbol. Rather than hardcode individual stock symbols, we can pass a variable to the REST URL that will enable the user of this add-on to configure the stock symbols they want.

To indicate a variable, we will use the format ${variable_name}. The current REST URL is:*

We'll replace the "YHOO" stock symbol with a variable "${Symbol}" as follows:*

Now to add a variable field and update the REST URL in our data input.

  1. On the Configure Data Collection page, click Edit for the StockInfo data input.
  2. The Edit Data Input wizard opens.

  3. Click the Data Input Variables tab.
  4. Use this page to define variables for the data input. For this input, we need to define a variable for the stock symbol.

  5. Under Component Library, drag and drop a Text Field to the Data Input Variables pane.
  6. With this field selected, fill out the properties for it on the Property Editor pane:

    • Display Label: Enter "Stock symbol".
    • Internal Name: Enter "Symbol", which is our variable_name.
    • Hints & Help: Enter "Enter a stock symbol"
    • Mandatory: Select this option because the variable is required.

  7. Click Next.
  8. in the REST URL field, replace the value with:*${Symbol}%22)&format=json&
  9. Notice that a new field is displayed for the stock symbol input we defined earlier.

  10. In Stock symbol (Symbol), enter a temporary value for testing, such as "SPLK". You can use any stock symbol you want.
  11. Click Test to verify the REST URL works.
  12. Click Save, and then click Finish.

>>  Continue to Extract fields.