Unqork’s Internal API: Delete APIs

Overview

Most of Unqork's internal API APIs (application programming interfaces) are a set of protocols and definitions developers use to build and integrate application software. APIs act as the connective tissue between products and services. (applications programming interface) calls use one of the create, read, update, and delete (CRUD CRUD refers to the four critical operations for creating and managing data elements in your applications. It stands for create, read, update, and delete.) operations. In this article, you'll explore two examples of delete API services in Unqork. Here you'll explore the Deletes Multiple Module Submissions and Restore a Deleted Module Submission API calls.

What You'll Learn

In this article, you’ll learn about the Deletes Multiple Module Submissions and Restore a Deleted Module Submission API calls, how they're configured, and how to test them.

Deletes Multiple Module Submissions and Restore a Deleted Module Submission API

The Deletes Multiple Module Submissions call has the ability to "soft-delete" submissions based on a specified submission ID. Soft-delete marks the submission as deleted, but doesn't remove it permanently. This call's parameters are the module ID where the submissions exists and the submission IDs of the submissions you want deleted.

IMPORTANT  The maximum number of submissions you can delete at once is 50.

The soft-deleted submissions don’t appear in query calls, but they can be restored. To restore a submission, use the Restore Deleted Module Submission call.

You can also “hard-delete” these submissions from the database. If you hard-delete a submission, it can’t be retrieved. To hard-delete a submission, add a query parameter for destroy. Destroy is a Boolean data type. Setting destroy to a value of true hard-deletes the submission from the database.

Review the Deletes Multiple Module Submissions and Restore a Deleted Module Submission API Configuration

To help explain how the Deletes Multiple Module Submissions API APIs (application programming interfaces) are a set of protocols and definitions developers use to build and integrate application software. APIs act as the connective tissue between products and services. works, we've configured a module and Plug-In component that uses this API call. The following sections explore the configuration and lets you test the API. We will take a closer look at the Restore a Deleted Module Submission API later in this article.

WARNING  Feel free to use the configuration created here for your own builds. But, please do not reconfigure the modules. If you want to use the configuration, make a copy of the module and paste it in your application.

Review the initNewSubmission Initializer Component

First, let's open the preconfigured module and look at the Initializer configuration.

1. Open the preconfigured module in the Module Builder by clicking the following link: https://training.unqork.io/#/form/64cbec0ae2de2a5e9ddef2ae/edit.
2. Hover over the initNewSubmission Radio Button component icon Initializer component.

A 5-button toolbar displays above the component on hover-over.

3. Using the toolbar, click the (Settings) button.

You can see the Trigger Type is set to New Submission, firing the Initializer on page load. In the Outputs table, the component outputs values from a schema module and stores them in the moduleId iconHidden component.

A static image displaying the initNewSubmission Intializer component's configuration with the New Submission Trigger Type and outputs to the schema module.

Review the submissionIdDelete Text Field Component

This Text Field component is where you'll enter a submission ID in Express View Express View is how your end-user views your application. Express View also lets you preview your applications to test your configuration and view the styling. This is also the view your end-users will see when interacting with your application. After configuring a module, click Preview in the Module Builder to interact with the module in Express View.. After entering the submission ID, you can soft-delete the full submission.

TIP  To learn how to retrieve a submission ID to update, view our Unqork's Internal API: Read APIs article.

A static image displaying the SubmissionId to Delete Text Field in Express View.

Review the pluginDeleteMultipleModuleSubmissions Plug-In Component

Let's take a closer look at the necessary Plug-In component configuration and settings to make the API work.

1. Hover over the pluginDeleteMultipleModuleSubmissions Plug-In component.

A 5-button toolbar displays above the component on hover-over.

2. Using the toolbar, click the (Settings) button.

Internal Services

From the Internal Services drop-down, you'll see that the Deletes Multiple Module Submissions API is selected. Once selected, the Data Source URL auto-populates with /fbu/uapi/modules/{moduleId}/submissions. As you can see, the {moduleId} placeholder text in the URL was adjusted to {{data.moduleId}}. That way, you can delete the specific data stored the moduleId iconHidden component.

TIP  To learn more about the Deletes Multiple Module Submissions API, click the Learn More button in the Plug-In component's configuration window.

A static image displaying the Deletes Multiple Module Submissions Internal Service selection in the Plug-In component.

Request Type

The Request Type is also set to DELETE. The DELETE type is used to soft-delete data.

Inputs

Lastly, the Inputs table references the submissionIdDelete  Text Field component where you'll enter a specified submission ID to delete.

A static image displaying the Delete Request Type and the submission ID mapping of the Plug-In component.

Review the pluginGetDeletedSubmission Plug-In Component

This Plug-In component is configured only to test if the soft-delete was successful. If that submission ID is already deleted, the call fails. If it isn't deleted, it displays in the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software..

Let's take a closer look at the necessary Plug-In component configuration and settings to make the API work.

1. Hover over the pluginGetDeletedSubmission Plug-In component.

A 5-button toolbar displays above the component on hover-over.

2. Using the toolbar, click the (Settings) button.

Internal Services

From the Internal Services drop-down, you'll see that the Get Module Submission API is selected. Once selected, the Data Source URL auto-populates with /fbu/uapi/modules/{moduleId}/submissions/{submissionId}. As you can see, the {moduleId} placeholder text in the URL was adjusted to {{data.moduleId}}. That way, you can retrieve the data from the moduleId iconHidden component.

The {submissionId} placeholder text in the URL is also adjusted to {{data.submissionIdDelete}}. Doing so lets the Plug-In reference the submission ID entered in the submissionIdDelete  Text Field component.

TIP  To learn more about the Get Module Submission API, click the Learn More button in the Plug-In component's configuration window.

A static image displaying the Get Module Submission Internal Service selection in the Plug-In component.

Request Type

The Request Type is also set to GET. The GET type is used to retrieve data.

A static image displaying the Get Request Type of the Plug-In component.

Review the pluginRestoreDeleteModuleSubmission Plug-In Component

This Plug-In component is configured only to restore soft-deleted submissions. Let's take a closer look at the necessary Plug-In component configuration and settings to make the API work.

1. Hover over the pluginRestoreDeleteModuleSubmission Plug-In component.

A 5-button toolbar displays above the component on hover-over.

2. Using the toolbar, click the (Settings) button.

Internal Services

From the Internal Services drop-down, you'll see that the Restore a Deleted Module Submission API is selected. Once selected, the Data Source URL auto-populates with /fbu/uapi/modules/{moduleId}/submissions/{submissionId}. As you can see, the {moduleId} placeholder text in the URL was adjusted to {{data.moduleId}}. That way, you can restore the specific data and store it in the moduleId iconHidden component.

The {submissionId} placeholder text in the URL is also adjusted to {{data.submissionIdDelete}}. Doing so lets the Plug-In reference the submission ID entered in the submissionIdDelete  Text Field component. Then, the Plug-In restores that submission.

TIP  To learn more about the Restore a Deleted Module Submission API, click the Learn More button in the Plug-In component's configuration window.

A static image displaying the Restore a Deleted Module Submission Internal Service selection in the Plug-In component.

Request Type

The Request Type is also set to POST. The POST type is used to create data.

A static image displaying the Post Request Type of the Plug-In component.

Test the Deletes Multiple Module Submissions and Restore a Deleted Module Submission APIs

Now, let's preview the module and test the configuration.

1. Preview the preconfigured module in Express View Express View is how your end-user views your application. Express View also lets you preview your applications to test your configuration and view the styling. This is also the view your end-users will see when interacting with your application. After configuring a module, click Preview in the Module Builder to interact with the module in Express View..
2. In Express View, right-click anywhere on the page.
3. Click Inspect. The Inspect tab of the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software. opens to the right of the page.
4. Click the Console tab.
5. In the SubmissionId to Delete field, enter a submission ID to delete.

TIP  To learn how to retrieve a submission ID to update, view our Unqork's Internal API: Read APIs article.

6. Click Delete Submission(s). This button triggers the pluginDeleteMultipleModuleSubmissions Plug-In component.
7. Returning to the Console tab, enter the angular.element('.unqorkio-form').scope().submission command.
8. Expand the data: drop-down section.
9. Expand the data: drop-down section.
10. Click the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. of the API’s Plug-In component. In this example, it’s pluginDeleteMultipleModuleSubmissions.
11. Select the submission indexed by [0].
12. The deleted submission ID displays in the id string.

A static image displaying the deleted submission ID in the DevTools Console.

With the Console still open, click Get Deleted Submission. On button-click, the Console displays errors associated with the call. The errors occur because the Plug-In component is referencing the submission ID from the SubmissionId to Delete field and trying to retrieve it. Because it's deleted, there's no submission to retrieve.

A static image displaying the DevTools Console errors that occur when trying to retrieve a deleted submission.

Lastly, with the Console still open and the submission ID still in the SubmissionId to Delete field, click Restore Deleted Submission. Then, click Get Deleted Submission. once more. Run the Angular Command The Angular command, or data command, is a tool that displays submission data in a browser's developer console. In Express View, enter the following command in the devtool console: angular.element('.unqorkio-form').scope().submission and open the pluginGetDeletedSubmission data to see the successfully restored submission ID.

A static image displaying the restored submission data in the DevTools Console.

Resources