Skip to content
  • There are no suggestions because the search field is empty.

How to Make a Lookup Table or Dictionary in DataHub WebView

This example shows how to create a Lookup Table or Dictionary in the DataHub WebView.  This will allow you to display a text string depending on the value coming from a tag.

  1. On the Page, there is an OnPageLoadStarted event.  In the event, you want to copy and paste the following text:
    nameLookupTable = new Dictionary<|int,string|>();
    nameLookupTable.Add(1, "one");
    nameLookupTable.Add(2, "two");
    nameLookupTable.Add(3, "three");
    nameLookupTable.Add(4, "four");
    nameLookupTable.Add(5, "five");
    nameLookupTable.Add(6, "six");

    function lookupName(value, lut)
    {
      var result = "none";
      try
      {
        result = lut[value];
      }
      catch (e)
      {
        /* result = e.Message; */
      }
      return result;
    }
  2. Replace the "one", "two", etc with the text you want to display.
  3. Replace the 1, 2, etc with the tag values that correspond with the string values you just edited.
  4. Add a label to your page. Set the Binding to Script and use the following script:
    lookupName(VAL("default:test"), nameLookupTable);
  5. Replace the "default:test" with your tag name that holds the values from step 3