Data Providers
...
REST
Create an app using REST APIs

Delete customer (DELETE)

8min
scenario add the ability to delete a customer from the list of customers by swiping left on the customer in the list item and tapping the delete button how does this work a delete function is configured to call the rest apis delete operation and identify the record to delete using the customer id (custid) the function is referenced in the execute entity action which will delete the customer from the list and from the datasource via the rest api when the delete button is pressed this code sample builds upon the previous list customers (get) docid 1o2k7 ccuvzfbg7x7f4r2 step, to develop a complete and functional solution rest api rest detail url https //\[your rest service]/api/customers?id={custid} operation/method delete function specify the rest api url and operation (method), parameters to include authentication in the header and the customer id (custid) to use as the identification of the record to delete rest delete customer jigx provider data provider rest method delete #deletes data from the rest service url https //\[your rest service]/api/customers?id={custid} #use your rest service url uselocalcall true #direct the function call to use local execution between the mobile device and the rest service format text parameters accesstoken location header required true type string value service oauth #use manage jigx com to define credentials for your solution custid type int location query required true action (global) create a load data jigx file under the actions folder this file is configured with an action that syncs the data from the rest service, by calling the function, to the local sqlite table the action file is referenced in the index jigx file to load the data when the app is opened or is in focus on the device load data jigx # the sync entities action is used to get the data from the rest data provider using the function \# the global action can be referenced throughout the solution for effieicency and performance \# the data is synced from the rest data provider to a local data provider on the device action type action sync entities options provider data provider rest entities \ entity customers function rest get customers jig (screen) use a list {{jig}} type to configure a list of customers since the data is already synced to the local sqlite data provider, the {{jig}} s datasource is configured using the local provider with a query to provide the data for use in the list expressions are used to reference the exact data property required in each component a swipeable left event is configured for the delete with an execute entity action that calls the delete function and uses the custid to identify the record to delete list customers jigx title global customers type jig list icon global accelerator header type component jig header options height small children type component image options source uri https //www dropbox com/scl/fi/ha9zh6wnixblrbubrfg3e/business 5475661 640 jpg?rlkey=anemjh5c9qsspvzt5ri0i9hva\&raw=1 \#define the data to use in the jig, the data has been synced by the global action to the local data provider from the rest service datasources customers type datasource sqlite options provider data provider local entities \ entity customers query | select cus id as id, json extract(cus data, '$ firstname') as firstname, json extract(cus data, '$ lastname') as lastname, json extract(cus data, '$ companyname') as companyname, json extract(cus data, '$ address') as address, json extract(cus data, '$ city') as city, json extract(cus data, '$ state') as state, json extract(cus data, '$ zip') as zip, json extract(cus data, '$ phone1') as phone1, json extract(cus data, '$ phone2') as phone2, json extract(cus data, '$ email') as email, json extract(cus data, '$ web') as web, json extract(cus data, '$ customertype') as customertype, json extract(cus data, '$ jobtitle') as jobtitle, json extract(cus data, '$ logo') as logo from \[customers] as cus \ order by \ json extract(cus data, '$ companyname') data =@ctx datasources customers item type component list item options title =@ctx current item companyname subtitle =@ctx current item firstname & ' ' & @ctx current item lastname leftelement element avatar text =@ctx current item state uri =@ctx current item logo label title =$uppercase((@ctx current item customertype = 'silver' ? @ctx current item customertype @ctx current item customertype = 'gold' ? @ctx current item customertype '')) color \ when =@ctx current item customertype = 'gold' color color3 \ when =@ctx current item customertype = 'silver' color color14 \#add the swipeable event to the customer list to include the delete button swipeable left \ label delete icon delete 2 color negative onpress type action confirm options isconfirmedautomatically false onconfirmed type action execute entity #action to execute the delete options \#use the rest data provider to call the delete function provider data provider rest entity customers method delete #delete the record from the local sqlite table function rest delete customer #delete the record from the rest service \#specifiy the function parameters required by the function to delete the customer, in this example custid functionparameters custid =$number(@ctx current item id) #id of customer record to be deleted in rest service data id =@ctx current item id #id of customer to be deleted from local data provider modal title are you sure? description =('press confirm to permanently delete ' & @ctx current item companyname) index for performance and offline support the data is synced from the rest service as soon as the app is opened or receives focus this is achieved by calling the global action in the onfocus and onload events index jigx name hello rest example title hello rest solution category sales \# onfocus is triggered whenever the jig is displayed the sync entities action in the global action calls the jigx rest function and populates the local sqlite tables on the device with the data returned from rest service onfocus type action execute action options action load data \# onload is triggered when the solution is loaded on the device the sync entities action in the global action calls the jigx rest function and populates the local sqlite tables on the device with the data returned from rest service onload type action execute action options action load data tabs home jigid list customers icon home apps logo