When developing applications with Kuika, you can create custom actions (Custom Actions) using SQL queries to enhance the functionality of your application. These custom actions allow you to define specific functions you need in your application and customize the functioning of your application. In the application you develop, you can integrate the Custom Actions you create with various screens and provide a more dynamic and user-oriented experience by adding these actions to the elements on the screens. In this course, you will learn step by step how to create Custom Actions, how to integrate them into screens and how to apply them to elements on screens.
This training content consists of the following topics:
In an application you develop with Kuika, you can create custom actions and use these actions on your screens. From the left menu of the Datasources module, you can view the data sources, actions and tables in the application you have developed, and add new data sources, actions and tables.
In an example scenario, let's say you want to create an action that lists the departments in the personnel list. Before creating this action, you need to create a table named “Department”. You can find detailed information about table creation in our content.
Copyselect * from Department WHERE DepartmentName LIKE @searchFor OR @searchFor is null OR @searchFor = '' ORDER BY DepartmentName
In an application developed with Kuika, you can increase the functionality of your application by creating custom actions. You can use the “Custom Actions” panel in the “UI Design” module or the “Actions” section in the “Datasources” module to create these actions.
Open the Custom Actions panel and select “SQL Action”.
3.1. Add Select Query: It is used to select records in the table and list them according to certain criteria. For example, a query such as “SELECT * FROM table_name” is created.
3.2. Add Select By Id Query: It is used to select a single record in the table according to a specific ID. For example, “SELECT * FROM table_name WHERE id = certain_id”.
3.3. Add Save Query: It is used to add a new record to the database or update an existing record. First, the existence of the existing record is checked with the “Update” query, then the new data is updated or inserted. If there is no record, the “Insert Into” command is activated and a new record is created in the data table.
3.4. Add Delete Query: It is used to delete a specific record in the database. For example, “DELETE FROM table_name WHERE condition expression”.
3.5. Add Search By Keyword Query: It is used to search the data in the table by a specific keyword. For example, “SELECT * FROM table_name WHERE column_name LIKE ‘%keyword%’”.
3.6. Add Search With Pagination Query: Used to search records by keyword and split the results into pages. Pagination is done with LIMIT and OFFSET parameters. For example, “SELECT * FROM table_name WHERE column_name LIKE ‘%key_keyword%’ LIMIT page_size OFFSET start”
4. Building SQL Queries with AI Assistant
You can get help from an AI Assistant when writing SQL queries. Click on the "Generate with AI" button and select the data table from the Select Box. Enter a command that describes the query you want to generate. For example, "I need a query to delete items". The AI will generate the query and you can copy and paste it into SQL Editor.
5. Adding Queries to SQL Editor
You can easily add AI generated queries by copying them to the SQL Editor area.
6. Query Result Parameter Panel
You can view the parameters of SQL queries in the Parameter Panel with the on/off button on the top right. The panel is dynamically updated according to the parameters of your action.
7. Testing SQL Queries
You can test SQL queries with the "TEST" button.
After completing all operations, you can finish the custom action creation process by clicking the “CREATE” (8) button.
On the Kuika platform, you can define a variable using the “DECLARE” command in the SQL Editor. This command allows you to specify the name of a variable, its data type and, if necessary, its initial value.
DECLARE @variable_name data_type;
There are two ways to assign a value to a variable:
1. SELECT Assignment:
SELECT @variable = değer FROM table_name;
2. Assignment with SET:
SET @variable = değer;
DECLARE @top1Product nvarchar(256);SELECT TOP 1 @top1Product = productName FROM table_name;
DECLARE @rowCount int;SET @rowCount = (SELECT COUNT(Id) FROM table_name);
On the Kuika platform, you can manually type the “DECLARE” command in the SQL Editor or you can get support from the Artificial Intelligence Assistant.
By activating the “Generate with AI” switch, you can enter a command by specifying the relevant table in the Search Box field. For example:
In this way, you can create your query quickly and easily.