Search Results for

    Show / Hide Table of Contents

    Workflow delete data - best practices

    A typical workflow setup for deleting data.

    Workflow setup

    The workflow setup should be:

    • Accept Input: Yes
      • Required Input: Yes
    • Hide Step Pane: Yes
      • Window Size: Small

    image-20231124145435441

    The activities should be configured as shown below:

    image-20231124142127892

    Scripted: Validate data

    The workflow must validate whether the data is deletable. Many systems have constraints for deleting data, such as it must not be possible to delete a setting that is currently in use or an active user.

    The activity should record validation errors in a workflow variable. In many cases, the error should be represented by a text resource key so that it can be displayed on the UI.

    // Example: the data must be deactivated before deleting
    if (ctx.Input.Get<bool>("IsActive"))
    {
        // Set the error message to a workflow variable "Error"
        ctx.Set("Error", "cwdm_cannot_delete_active_job");
    }
    

    Form: Show error

    Declare the variable to be used in the form, and then bind it to a CustomHTML component. Make sure you remember to apply the translate filter.

    image-20231124144048564

    <div ng-bind-html="dataSources.WorkflowVariables.data.Error | translate"></div>
    

    You must configure the Inclusion Logic so that the activity only executes when there is any error.

    image-20231124144219670

    Stop: Stop if error

    Use the Stop activity to stop the workflow. You must configure the Inclusion Logic so that the activity only executes when there is any error.

    image-20231124144419026

    Form: Confirm

    A form for confirming user decision. This is recommended for critical actions like deleting data.

    image-20231124144652158

    Remember to apply translation for the message:

    <div ng-bind-html="'cwdm_common_delete_confirm' | translate:{Name: dataSources.CwDmJob.data.Name}" />
    

    Scripted: Delete

    var dataApi = ctx.Use<IDataApi>(); 
    dataApi.Delete(ctx.Input.Id);
    
    In This Article
    Back to top Generated by DocFX