• Resources
    • Documentation
    • Knowledge Base
    • Forum
    • Courses
    • Webinars
    • FAQ
    • Changelog
    • Blog
    • Swag Shop
  • Marketplace
  • Start for Free
  • Login
  • Resources
    • Documentation
    • Knowledge Base
    • Forum
    • Courses
    • Webinars
    • FAQ
    • Changelog
    • Blog
    • Swag Shop
  • Marketplace
  • Start for Free
  • Login
home/Knowledge Base/General

How to Use Data Services

37 views 0 February 8, 2021 Marie

Prerequisites

Simplifier instance release 6.0.

In this article we will present several use cases of Simplifier data services. Our sample app is a simple project management tool, which offers the administration of projects and employees.

Step 1 – Data Base Schema

In the following you see the data base schema of our running example:

Step 2 – Load Data Sets

To get a simple overview of your projects and employees (e.g., using a list or table widget), you can use the ‘Load Dataset’ data service as explained in the Simplifier documentation.

Step 3 – Show Project Details

By clicking on a project the detail view opens showing the project’s name, description, and members:

To get those information, in a first step the ID of the selected project has to be determined (and stored in a global variable) by using the following statements in a script block in the process designer:
var context = this.ODataService.getSelectionContextForEvent(oEvent, 'NameOfYourDBSchema');
var id = context.getObject().id;
this.getGlobals().setVar("ProjectId", id);

Using this ID the ‘Load Data’ data service (Simplifier documentation) can be used to load the selected project record.

Next, the corresponding project members have to be loaded. Therefore, we will use a ODataV4 REST call, which filters (ODataV4 – $filter) the expanded (ODataV4 – $expand) ProjectMembers records. Using this connector in a Business Object, we can retreive the Employee records of the project members of the selected project.

Step 4 – Add Project Member

To add a new project member, we will use a select dialog widget, which opens by clicking the ‘add’ button:

To get a list of employees, which can be selected as project members, a Business Object is used which runs a ODataV4 REST call filtering out the already assigned project members from the Employees records (ODataV4 – $filter):

Filter statements in the ODataV4 REST call can be concatenated by using ‘and’ or ‘or’.

For adding new project members records to the data base according to the user selection, the selected employee objects are fetched from the select dialog to a global variable:

var selectedItems = oEvent.getParameter("selectedItems");
var projectMembers = [];
for (var i = 0; i < selectedItems.length; i++) {
    projectMembers.push(selectedItems[i].getBindingContext("Popups").getObject());
};
this.getGlobals().setVar("projectMembersNew", projectMembers);

Using an ‘Iterator’ module, the new project members records can be added to the data base using the ‘Write Data’ data service (Simplifier documentation).

Step 5 – Delete Project Member

The delete actions in this app are implemented using the widget property ‘type = delete’ of the list items:

For deleting a project member, first, the ID of the selected employee has to be determined (and stored in a global variable):

var context = oEvent.getParameter("listItem").getBindingContext("ProjectDetail");
var employeeId = context.getObject().id;
this.getGlobals().setVar('EmployeeId', employeeId);

Next, the ID of the corresponding project member record can be determined using a Business Object which runs a ODataV4 REST filter (ODataV4 – $filter) call on the project members table which is expanded (ODataV4 – $expand) by employees:

Step 6 – Save/Cancel Project

To save changes concerning the input fields (‘name’, ‘description’) the ‘Write Data’ data service (Simplifier documentation) can be used.

To discard changes concerning the input fields the  ‘Reset Changes’ data service (Simplifier documentation) can be used.

Chances concering the project membership are not affected here, they are handled independently (see  Step 4 and Step 5).

Step 7 – Show Employees Details

Similar steps can be done for the employees: By clicking on a employee the detail view opens showing the employee’s last name, first name, department, and projects:

The story flow in the process designer can be set up analog to the project detail view (see Step 3).

Step 8 – Change Department

In this case, the department selection is implemented using a select widget.

Therefore, all Department records are loaded in a  first step using the ‘Load Dataset’ data service (Simplifier documentation). The ‘id’ and ‘name’ fields are mapped to the ‘text’ and ‘key’ properties of the select items:

Next, the selected Employee record can be loaded using the ‘Load Data’ data service (Simplifier documentation). In case of the Simple Form Input Fields, the data fields ‘firstName’ and ‘lastName’ can be mapped directly. In case of of the employee’s department, the ‘selected key’ property of the Select widget has to be connected with ‘dept___id’.

Step 9 – Delete Project/Employee

To delete a whole project (or employee) entry, the ‘Delete Dataset’ data service (Simplifier documentation) can be used:

The ID of the selected project can be determined using the following statements in a script block in the process designer:

var context = oEvent.getParameter("listItem").getBindingContext("ODataModel_NameOfYourDBSchema");
var projectId = context.getObject().id;
this.getGlobals().setVar('ProjectId', projectId);

Was this article helpful?

Yes  No
Related Articles
  • How to check Simplifier Token Validity
  • Using SAP UI Theme Designer
  • How to integrate and use external libraries in Simplifier Apps
  • Plugin development with NodeJS
  • Execute Google Scripts via API
  • OpenUI5, SAPUI5 and Fiori
Leave A Comment Cancel reply

You must be logged in to post a comment.

Trending
  • Example Apps
  • Introduction
  • Install Simplifier on Azure
  • OpenUI5, SAPUI5 and Fiori
  • Create your first Application
  • Execute Google Scripts via API
  • Using SAP UI Theme Designer
  • Prerequisites & Helpful Links
  • How to integrate with SAP Business API Hub
  • Identity Provider Setup

Our support Staff is available 9 AM - 6 PM, Monday to Friday. Please be patient when posting an issue as staff may not be in the same timezone as you.

  • Contact | Imprint | Privacy | © 2020 Simplifier AG. All Rights Reserved.