Save Your Contacts to Address Book
In this example, we have developed an address book process. Access the contact details stored in the address book at any time.
Steps
This example is divided into few sections. Following the steps below in the correct order, you will have an address book on the Emakin where you can save contacts and their phone numbers.
Create a Folder
First, need to create a new folder from the folders section.
Presses the “+New Folder” inside of all folders.
“Address Book” as the name of the folder and “Application” as the folder type is okay for the process.
Create a Process
To create a process, enter a process name in the field on the right side of the folder and click the blue plus button.
Press the edit button to design the process.
On the page that opens, "Pool" is selected under the Pools heading.
Create a Task
Click on the pool to start the process design.
The first green box that appears on the screen is the opening task.
Click on the “task” name on the green box and enter the name “Definition”.
Click on the Add New action button on the right side of the task and the text becomes editable.
After editing the text and pressing enter on the keyboard, the first button is created. The first action name is “ Update”.
After adding the update button, Add New comes down as the 2nd button.
Press Add New again and changes to "Cancel".
A single task is enough for this process.
Create a Form
After creating a task, necessary to design a form for the Address Book.
Enters the form under the “forms” heading on the same page as the task.
A blank page opens
When clicking on the blank part of the page, the form's menu appears.
Click “Add New”, and the “Layout Controls” list opens in the menu that appears.
Click on “Row Control” from within Layout Controls.
Click "Create new section here".
Enter the section name. Section name
Then press ok.
There is a column in the row content section of the form.
Click on Column and click to “Add New” from the menu that appears.
Add “Tabbed Content” from inside “Layout Controls”.
The title of the tabbed content is empty.
Title corrects by pressing on the title. Enter the “Contacts” name.
Selects the tab column under the title of the Contacts.
“List Control” opens from the menu.
Selects the “Table Content” from the List Control.
Table Name, Table Row name, and table columns information fill in on the screen that opens.
Clicks the add new under table columns and creates 3 columns.
Then, fills in the blanks.
After adding the data to the form designer, displays as follows.
Click on the text box under the phone number.
Click on “type” in the menu that opens on the side.
Select “Telephone” from the type.
Personal names are written in the same manner as table row names.
Data Model
Return to the "Process" tab, which is located above the form table you created in the previous stage.
The title "other" appears at the bottom of the page that opens. Click on “Data Model”.
In the data model, a string type Id field is added to be defined under personal. With Id, each contact has a unique number. The multiplexing of records is prevented.
Define Database Into The Process
The title "other" appears at the bottom of the page that opens.
Redirects to the page where the database was created.
An existing table is imported by pressing the import button
It is created from scratch by clicking the "Add New Schema" button.
Gives a name and prefix to the database creation.
Then, add a new table with a name.
Clicks details and adds field names with type and size in the fields tab that are necessary.
Since the ids should not be the same, the Type must be a unique identifier.
Then, it is done with the editing part.
Saving the Form Data to Database
Click on the process from the tabs above.
Reach the Definition by entering the Pool.
The lightning bolt icon on the right of the Task is called postwork.
Use postwork to save the information that is written on the form.
We will use the $Database.ImportFromXml function to save data from the database. More detailed information can be found on page $Database.ImportFromXml.
The code on the sample page should be changed according to the schema and table name.
The target schema name should be the same as the database name's first name.
The target table names are identical to the table names.
Then the line of code starting with XPath is used to access the saved data. Xpath is 'AddressBook/PersonalInformations/Personal'.
if ($WorkItem.SelectedAction == 'Update') {
$Database.ImportFromXml({
Parameters: {
TargetSchema: "AddressBook",
TargetTable: "Contacts"
},
XPath: "AddressBook/PersonalInformations/Personal",
Map: function (xml) {
this.Phone = xml.Evaluate("PhoneNumber")
}
});
}
Then, return back to the process design.
This time with the postwork icon, both icons that are lightning turn white.
After adding buttons, the task is done.
Loading Data from Database
Click on the process from the tabs above.
Reach the Definition by entering the Pool.
The lightning bolt icon on the left side of the task is called prework.
Prework allows us to see the saved information in the table as it is saved when opens again.
We will use the $Database.ExportFromXml function to reach data from the database. More detailed information can be found on page $Database.ExportToXml.
The target schema name should be the same as the database name's first name.
The target table names are identical to the table names.
Then the line of code starting with XPath is used to access the saved data. Xpath is 'AddressBook/PersonalInformations/Personal' .
$Database.ExportToXml({
TargetSchema : 'AddressBook',
TargetTable : 'Contacts',
XPath : 'AddressBook/PersonalInformations/Personal',
Map : function (row) {
row.SetValue("PhoneNumber", this.Phone)
}
});
Prework turns white after writing the code to Prework.
Usage Of Form
Presses the green close button to exit the page.
On the page that opens, click “commit change” to save the changes made.
Then, press the close button to go to the previous page.
Then, the created form appears with the name given to the task.
The form opens blank.
Click on "+Add New" to add a new row to enter a contact.
After entering the desired information in the columns in the row, click the "Update" button.
Opening the form again shows the contacts saved in the address book.
If the cancellation button is clicked, the address book exits without saving.
Copyright © 2010 - 2023 Emakin. All rights reserved.