Purpose
Consume a simple OData service and display the result in a table

Main points

  • Build up the URL for the OData service

  • Use CopyText to receive the OData response (JSON format) in a GuiXT text variable

  • Call up a JavaScript routine via CallJS to transform the JSON format into GuiXT variables

  • Display the result as a table, using Table and Column statements

GuiXT Script

GuiXT
// Build up OData URL (here: OData Test service)
Set V[url] _
   "http://services.odata.org/V4/Northwind/Northwind.svc/Customers"

// Read Northwind customers via OData service
CopyText fromFile="&V[url]" toText="cust"

// Fill GuiXT variables via JavaScript
CallJS customercount = odata_customers

// Display customer table
Table (3,6) (15,101) title="Northwind Customers" -singlerowselection _
name="nwcustomers" rows="&V[customercount]" fixedColumns=3

Column "Company" size=40 name="company"
Column "City" size=30 name="city"
Column "Country" size=20 name="country"


JavaScript

JavaScript

Result

Components
InputAssistant + GuiXT Controls