Actions

execute-entity

6min
execute entity can save, update, or delete data in a single row from a database, depending on the chosen method each datasource type (dynamic / sql / rest) will have a different syntax for updating, saving, and deleting data for the dynamic datasource, values will be saved under the data option for sql/rest datasource, values will be saved under the functionparameters option this action can't be used if you are using static data docid\ bn6yyljswkrsj1 bbwss1 configuration options configuration options an execute entity action can be used in multiple areas under the action button in action list in onpress/onchange events (if the component you are setting up has these options) in onrefresh/onfocus the execute entity has a go back option, which is set to on by default that means when you run execute entity, it will automatically return you to the previous {{jig}} offline remote data handling dealing with offline remote data is fundamental to ensuring data synchronization and consistency between the mobile app and the remote data source, allowing users to continue using the app and performing actions without interruption offline remote data handling docid\ h36q0e3t93lcbn9wejmjp explains how to configure solutions to deal with data when the device is offline using the queueoperations property available in execute entities and provides examples and code samples examples and code snippets examples and code snippets execute entity in action in this example, execute entity is used in action with the create method this example results in creating a new record with the first name, last name, email, and phone number information execute entity is called by the press of the save details button on the bottom example see the full example of execute entity in github execute entity action actions \ children \ type action execute entity options title save details provider data provider dynamic method create entity default/form data firstname =@ctx datasources employee detail dynamic firstname lastname =@ctx datasources employee detail dynamic lastname email =@ctx datasources employee detail dynamic email phone =@ctx datasources employee detail dynamic phone onsuccess type action go back execute entity in action list by pressing the save details button the execute entity action will be followed by the go to action examples see the full example of execute entity in github execute entity action list actions \ children \ type action action list options issequential true title save details actions \ type action execute entity options provider data provider dynamic method create entity default/form data firstname =@ctx datasources employee detail dynamic firstname lastname =@ctx datasources employee detail dynamic lastname email =@ctx datasources employee detail dynamic email phone =@ctx datasources employee detail dynamic phone \ type action info modal options modal title details successfully saved buttontext view list element type icon icon cog approved color primary onconfirmed type action go to options linkto ja execute entity onpress execute entity in onpress/onchange event here is the example of execute entity in onpress/onchange event in list item examples see the full example using onchange in github see the full example using onpress you in github onpress item type component list item options title =@ctx current item firstname subtitle =@ctx current item lastname description =(@ctx current item modify = 0 ? 0 @ctx current item modify) & ' time/s changed ' leftelement element avatar text '' uri =@ctx current item photo onpress type action execute entity options provider data provider local method update entity default/employees data id =@ctx current item id modify =($number(@ctx current item modify) + 1) onchange item type component list item options title =@ctx current item firstname subtitle =@ctx current item lastname description =(@ctx current item modify = 0 ? 0 @ctx current item modify) & ' time/s changed ' leftelement element avatar text '' uri =@ctx current item photo rightelement element checkbox value true onchange type action execute entity options provider data provider local method update entity default/employees data id =@ctx current item id modify =$number(@ctx current item modify) + 1 execute entity in onrefresh/onfocus here is the example of execute entity in onrefresh/onfocus see the full example using onrefresh in github see the full example using onfocus in github execute entity onrefresh onrefresh type action execute entity options provider data provider dynamic method update entity default/employees data id =@ctx datasources employee detail dynamic id modify =@ctx datasources employee detail dynamic modify >= 10 ? 1 ($number(@ctx datasources employee detail dynamic modify) + 1) execute entity onfocus onfocus type action execute entity options provider data provider dynamic method update entity default/employees data id =@ctx datasources employee detail dynamic id modify =@ctx datasources employee detail dynamic modify >= 10 ? 1 ($number(@ctx datasources employee detail dynamic modify) + 1) deleting data using execute entity here is an example of deleting different data using execute entity there are always 2 options for how you can delete a record using sql select using jsonata function in the first two examples, you can see the same situation where you are deleting all the records where the name equals jane the third example shows how to delete the first 3 records from your datasource delete by first name datasource people type datasource sqlite options provider data provider dynamic entities \ entity people query | select id, '$ name', '$ surname', '$ address' from \[people] where '$ name' like 'jane' actions \ type 'action execute entity' options entity people method delete provider data provider dynamic data id =@ctx datasource people id delete by fist name jsonata function type 'action execute entity' options goback stay entity form provider data provider local method delete data "=@ctx datasources people\[name = 'jane']{'id'\ id}\[]" delete first 3 records datasource people type datasource sqlite options provider data provider dynamic entities \ default/people query | select id, '$ name', '$ surname', '$ address' from \[default/people] limit 3 actions \ type 'action execute entity' options goback stay entity deafult/people method delete provider data provider dynamic data id =@ctx datasource people id