This document is part of: HowTo: Using external services in a Smart Device App
For this example lets suppose we have 4 external services provided by our main system:
Returns a collection of Customers ordered alphabetically by the First Name.
Returns a collection of Customers ordered chronlogically by the Date Of Birth.
Returns a collection of Customers which meets a certain Search Criteria ordered alphabetically by the First Name.
Returns a collection of Customers which meets a certain Search Criteria ordered chronlogically by the Date of Birth.
Note: All of this services take into consideration the pageSize and the page quantity so paging is available. To set the size of a page just set it on the rows property of the Grid.
How do we use this External Services in our SD App?
0- Create and import the WebServices to the KB.
a. Create a Panel for Smart Devices
b. Create the Variables that your Grid is going to show and design the Layout.
In this case:
vCustomerDateOfBirth -> Date
vCustomerFirstName -> VarChar(40)
vCustomerLastName -> VarChar(40)
c. Define the variables to consume the WebServices Previously imported to the KB.
eoFindCustomerOrdName ->Variables based on External Objects for each service imported on step 0
sdtCustomersFindOrdName - > Variables based on SDTs automatically generated for each service declared above.
d. Add the Order and Search Criteria on the Conditions Tabs.
e. Program the Load Event to consume the services depending on the interface and parameters recieved.
if &SearchText.isEmpty() --> &SearchText is the textbox automatically generated to do searchs on SD Grids. See images bellow
if &OrderedBy = 0 --> OrderedBy = 0 is the first order defined in step e. Se images bellow
for &sdtCustomersGetOrdName in &eoGetCustomerOrdName.Execute(&start,&count)
&vCustomerFirstName = &sdtCustomersGetOrdName.CustomersFirstName
&vCustomerLastName = &sdtCustomersGetOrdName.CustomersLastName
&vCustomerDateOfBirth = &sdtCustomersGetOrdName.CustomersDateOfBirth
if &orderedBy = 1 -->OrderedBy = 1 is the following order defined in step e.
for &sdtCustomersGetOrdDate in &eoGetCustomerOrdDate.Execute(&start,&count)
&vCustomerFirstName = &sdtCustomersGetOrdDate.CustomersFirstName
&vCustomerLastName = &sdtCustomersGetOrdDate.CustomersLastName
&vCustomerDateOfBirth = &sdtCustomersGetOrdDate.CustomersDateOfBirth
if &OrderedBy = 0
for &sdtCustomersFindOrdName in &eoFindCustomerOrdName.execute(&SearchText,&start,&count)
&vCustomerFirstName = &sdtCustomersFindOrdName.CustomersFirstName
&vCustomerLastName = &sdtCustomersFindOrdName.CustomersLastName
&vCustomerDateOfBirth = &sdtCustomersFindOrdName.CustomersDateOfBirth
if &orderedBy = 1
for &sdtCustomersFindOrdDate in &eoFindCustomerOrdDate.execute(&SearchText,&start,&count)
&vCustomerFirstName = &sdtCustomersFindOrdDate.CustomersFirstName
&vCustomerLastName = &sdtCustomersFindOrdDate.CustomersLastName
&vCustomerDateOfBirth = &sdtCustomersFindOrdDate.CustomersDateOfBirth
f. Bonus. Break By.
BreakBy is resolved by the client, so no extra service is needed. On the conditions tab enable the BreakBy option by adding a variable to it.