Professional Documents
Culture Documents
User Defined Java Class - SelfStudyDoc
User Defined Java Class - SelfStudyDoc
User Defined Java Class - SelfStudyDoc
In this document we will see how to use “User Defined Java Class” step to apply business logic using Java code
in workflows. We will see very basic example i.e. how to add two numbers.
Building workflow
1. In process studio, create a new workflow and save it as shown in below images:
Meta tab:
In Name column, enter fields name
In Type column, select data-type of the field.
In Format column, select format from drop-down if any.
Data tab:
3. Next we need to perform the addition operation. For this, drag & drop “User Defined Java Class” step from
left pane. Connect it with the previous step “Data Grid Input”.
Double-click on “User Defined Java Class” step to write the code.
4. Now we need to add a function called “processRow” which will act like a “main” function of Java code.
To add “processRow” function, go to left-side pane (Classes and code fragments), expand “Code Snippits” >>
“Common use” >> double-click on “Main”. It will add “processRow” function automatically in right-side
section as shown in below image:
5. In right-side “Class code” section, scroll-down till the end. Put the cursor just before the auto-generated code
as:
putRow(data.outputRowMeta, r);
Now in left-side, expand “Input fields” >> “Num1” >> double-click on “getNumber()”. Below code will add
automatically.
Double Num1 = get(Fields.In, "Num1").getNumber(r);
© 2018 AutomationEdge Inc. All Rights Reserved.
This document is for your company’s internal use only and may not be distributed to any third party.
Perform same operation for “Num2” as shown in below image:
6. Now create a method for adding “Num1” and “Num2” and call it as shown in below image:
logBasic("Addition is --->"+add);
10. Save and Run the workflow. You can check output in “Preview Data” tab and also in “Logging” tab as shown
below: