Unqork’s Internal API: Delete APIs

Overview

Unqork's internal Delete API call is one of the available 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. Depending on the 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., Delete The Delete operation removes existing data records from a database, allowing users to eliminate outdated or unnecessary information within a system. operations can permanently remove data from a database, or archive the data so it can be restored at a later time.

In this article, you'll learn how to delete submissions using the Deletes Multiple Module Submissions API, then recover the deleted submissions using the Restore a Deleted Module Submission API.

Deletes Multiple Module Submissions and Restore a Deleted Module Submission API

The Deletes Multiple Module Submissions call has the ability to soft delete A soft delete is a data persistence strategy that retains deleted records in a database instead of permanently removing them. Soft deletes can help protect data from accidental or malicious deletion, and they can also improve performance. Also known as archiving. submissions based on a specified submission ID. Soft-delete marks the submission as deleted, but does not remove it permanently. This API's parameters are the module ID where the submissions exists and the submission IDs of the submissions you want deleted.

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

Soft deleted A soft delete is a data persistence strategy that retains deleted records in a database instead of permanently removing them. Soft deletes can help protect data from accidental or malicious deletion, and they can also improve performance. Also known as archiving. submissions do not appear in query calls, but they can be restored. To restore a submission, use the Restore Deleted Module Submission API call.

You can also hard-delete Hard Delete, also known as "Permanent Delete" or "Destroy", irreversibly erases a file or submission record. There is no option to recover hard deleted files. submissions from the database. If you hard-delete a submission, it cannot be retrieved. To hard-delete a submission, add a query parameter for destroy. Destroy is a Boolean The Boolean data type accepts one of two values: true, or, false. 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.

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 4-button toolbar displays above the component on hover-over.

3. Using the toolbar, click the (Settings) button.
4. Review the following settings:

You can see the Trigger Type is set to New Submission, firing the Initializer component 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.

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 4-button toolbar displays above the component on hover-over.

2. Using the toolbar, click the (Settings) button.
3. Review the following settings:

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.

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 The Delete operation removes existing data records from a database, allowing users to eliminate outdated or unnecessary information within a system. 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's not 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 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. work.

1. Hover over the pluginGetDeletedSubmission Plug-In component.

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

2. Using the toolbar, click the (Settings) button.
3. Review the following settings:

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 component reference the submission ID entered in the submissionIdDelete  Text Field component.

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 The HTTP GET method is used to request data from a server, typically retrieving information without modifying any resources. type is used to retrieve data.

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 4-button toolbar displays above the component on hover-over.

2. Using the toolbar, click the (Settings) button.
3. Review the following settings:

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 component reference the submission ID entered in the submissionIdDelete  Text Field component. Then, the Plug-In component restores that submission.

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.

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.

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 DevTools 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 DevTools 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