Create delete-object workflow
Introduction
In this tutorial, you will learn how to create a workflow to delete books from your bookstore database.
Guide
Step 1. In Casewhere Admin site, navigate to Workflow Definition
Step 2. Click Create button
The Create New Workflow definition dialog will appear
- Step 3. Config General Setting tab as below
Field name | Actions |
---|---|
Name | Fill in "Delete Book" |
Display Name | Fill in "Delete book" |
Used For Creating New Cases | Make sure this field is uncheck ☐ |
Accept Input | ☑ |
Require Input | ☑ |
Window Size | Select Small |
- Step 4. Switch to Data classes tab
Click Select data classes drop-down, and select "CwBook"
Tip: The data classes you just select is the one you made in Create a data class step
Click Save
- Step 5. Edit Workflow Definition: Delete book dialog will display
Drag and drop Form activity definitions from Add Activity Definitions panel to Step 1 container
- Step 6: Create Activity Definition: Form will show up.
Field name | Actions |
---|---|
Name | Fill in "Delete book" |
Display Name | Fill in "Delete book" |
- Step 7. Navigate to the Toolbox tab
Drag and drop Label activity definitions from Toolbox panel to Form1 canvas
- Step 8. In the Properties window, looking for Text property
Field name | Actions |
---|---|
Text | Fill in "Are you sure you want to delete this item?" |
Click Save & Close
- Step 9. Switch to Navigation tab
Field name | Actions |
---|---|
'Back' button label | ☑ |
'Forward' button label | ☑ |
'Reset' button label | ☑ |
'Save' button label | ☑ |
'SaveAndClose' button label | Change the string to "Yes" |
Click Save & Close
- Step 10. Drag and drop Scripted activity definitions from Add Activity Definitions panel to the step container
- Step 11. The Create Activity Defintion: Scripted will open
Field name | Actions |
---|---|
Name | Fill in "Delete Book Script" |
In General Settings, copy and paste the following code
var dataApi = ctx.Use<IDataApi>();
var book= ctx.Input;
dataApi.Delete(book["Id"]);
Click on Save & Close
Now your Edit Workflow Definition: Delete book window should contains two activities in Step 1 panel as show below
Good job! You are ready to use this workflow definition in your next step - Create "Delete Book" button.
- Step 12. Create a button to trigger the workflow
Follow this guide to create and test a button to make "Delete book" button
- Step 13. Reload your page to see the button on-live
Good job!
You are ready to move to the next step