Description
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
- Choose root entry to delete
- Could be done via a panel header function in a grid
- Create a typescript function to get the selected entry
- Include this function as a menu action in grid
- Other way via a function in a detail screen
- Also create a typescript function to get the chosen entry
- Include this function e.g. in the ribbon of a detail screen
- Include an ABL Business task into a TS function
- 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
orb1-CallBackendSync
) - Here is an detailed example, where the ABL BusinessTask
ProcessCustomParameterBT
is called in a TS function. You can adapt these for the deleting approach - And afterwards there are the code examples for the ABL Business task. Also here you can use the Build.One code snippets
b1-LogicClass
andb1-LogicParameter
- ProcessCustomParameterBT.cls
- ProcessCustomParameterParameter.cls
- The actual logic of deleting the entries must be implemented by you, follow these high-level steps:
- Find out or know all the tables which are connected to the entry you want to delete
- Know the key fields, how the different tables are connected
- Prepare a delete statement in ABL, which deletes the current entry and all connected ones
- Optional: Send message to frontend
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;
akioma.swat.App.invokeServerTask({
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)
akioma.swat.Message.message(plcParameter.OutputCharacterProperty);
});
}
USING Consultingwerk.OERA.BusinessTaskCatalogData.
USING Akioma.Swat.Samples.ProcessCustomParameter.ProcessCustomParameterParameter.
BLOCK-LEVEL ON ERROR UNDO, THROW.
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,
"ProcessCustomParameter",
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.
USING Progress.Lang.*.
USING Consultingwerk.JsonSerializable FROM PROPATH.
BLOCK-LEVEL ON ERROR UNDO, THROW.
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.
Back to Documentation
Back to Home Page