Use Cases


Delete DB records including linked records via ProCode

Delete DB records including linked records via ProCode


In this How-To we would like to explain how you can develop an individual function using ProCode to delete an entry including all connected subentries together.

Example Use Case:

Given the following data structure:

  • Offer 4711
    • Position A
      • Property 1
      • Property 2
    • Position B
      • Property 3
      • Property 4

Now I want to delete the Position A from the offer including the connections from A to the properties 1 and 2

How to use it

  1. Choose root entry to delete
    1. Could be done via a panel header function in a grid
      1. Create a typescript function to get the selected entry
      2. Include this function as a menu action in grid
    2. Other way via a function in a detail screen
      1. Also create a typescript function to get the chosen entry
      2. Include this function e.g. in the ribbon of a detail screen
  2. Include an ABL Business task into a TS function
    1. Here will be described the general approach how to include an ABL Business Task into a TS function. For that you can use the code snippets provided by Build.One: b1-CallBackendAsync or b1-CallBackendSync)
      1. Here is an detailed example, where the ABL BusinessTask ProcessCustomParameterBT is called in a TS function. You can adapt these for the deleting approach
      2. class ProcessCustomParameterParameter {
          IntegerProperty1: number;
          IntegerProperty2: number;
          OutputLogicalProperty: boolean;
          OutputIntegerProperty: number;
          OutputCharacterProperty: string;
        export function processCustomParameter(eventSource: akioma.swat.FormFieldObject): void {
          const form: akioma.swat.Form = eventSource.form;
          const parameter: ProcessCustomParameterParameter = new ProcessCustomParameterParameter();
          parameter.IntegerProperty1 = form.getScreenValue('IntegerProperty1') ?? 0;
          parameter.IntegerProperty2 = form.getScreenValue('IntegerProperty2') ?? 0;
            name: 'Akioma.Swat.Samples.ProcessCustomParameter.ProcessCustomParameterBT',
            methodName: 'ProcessCustomParameter',
            paramObj: { plcParameter: parameter }
          }).then(({ plcParameter }: {plcParameter: ProcessCustomParameterParameter}) => {
            form.setScreenValue('OutputIntegerProperty', plcParameter.OutputIntegerProperty);
            form.setScreenValue('OutputLogicalProperty', plcParameter.OutputLogicalProperty);
            if (plcParameter.OutputCharacterProperty)
      3. And afterwards there are the code examples for the ABL Business task. Also here you can use the Build.One code snippets b1-LogicClass and b1-LogicParameter
        1. ProcessCustomParameterBT.cls
        2. USING Consultingwerk.OERA.BusinessTaskCatalogData.
          USING Akioma.Swat.Samples.ProcessCustomParameter.ProcessCustomParameterParameter.
          CLASS Akioma.Swat.Samples.ProcessCustomParameter.ProcessCustomParameterBT
            INHERITS Akioma.Swat.Samples.BaseSampleBT
            IMPLEMENTS Consultingwerk.OERA.IBusinessService, Consultingwerk.OERA.IBusinessTaskCatalogInfo: 
            METHOD PUBLIC Consultingwerk.OERA.IBusinessTaskCatalogData GetCatalogData():
              DEFINE VARIABLE oCatalog AS BusinessTaskCatalogData NO-UNDO .
              /* Initialize first Method Descriptor through the catalog data descriptor */
              oCatalog = NEW BusinessTaskCatalogData (THIS-OBJECT:GetClass():TypeName,
                GET-CLASS (ProcessCustomParameterParameter)).
              RETURN oCatalog.
            END METHOD.
            METHOD PUBLIC VOID ProcessCustomParameter(poParameter AS ProcessCustomParameterParameter):
              poParameter:OutputIntegerProperty = poParameter:IntegerProperty1 + poParameter:IntegerProperty2.
              poParameter:OutputLogicalProperty = poParameter:OutputIntegerProperty GT 0.
              poParameter:OutputCharacterProperty = SUBSTITUTE("This is the result: &1", poParameter:OutputIntegerProperty).
            END METHOD.
          END CLASS.
        3. ProcessCustomParameterParameter.cls
           USING Progress.Lang.*.
           USING Consultingwerk.JsonSerializable FROM PROPATH.
           CLASS Akioma.Swat.Samples.ProcessCustomParameter.ProcessCustomParameterParameter
             INHERITS JsonSerializable:
             /* Input properties */
             { Consultingwerk/JsonSerializableProperty.i IntegerProperty1        INTEGER }. 
             { Consultingwerk/JsonSerializableProperty.i IntegerProperty2        INTEGER }. 
             /* Output properties */
             { Consultingwerk/JsonSerializableProperty.i OutputLogicalProperty   LOGICAL }. 
             { Consultingwerk/JsonSerializableProperty.i OutputIntegerProperty   INTEGER }. 
             { Consultingwerk/JsonSerializableProperty.i OutputCharacterProperty CHARACTER }. 
             CONSTRUCTOR PUBLIC ProcessCustomParameterParameter ():
               SUPER ().      
               THIS-OBJECT:AddSerializableProperties ("{&SerializableProperties}":U) .
             END CONSTRUCTOR.
           END CLASS.
    2. The actual logic of deleting the entries must be implemented by you, follow these high-level steps:
      1. Find out or know all the tables which are connected to the entry you want to delete
      2. Know the key fields, how the different tables are connected
      3. Prepare a delete statement in ABL, which deletes the current entry and all connected ones
      4. Optional: Send message to frontend

Back to DocumentationDocumentation

Back to Home Page