The Component library lets you extend functionality in Bizagi by including custom code to be used in the logic behind your processes.
Through such custom code you can integrate with other applications or extend any processing or other operations that your processes execute.
You include custom code through Bespoke code that is included via the Component Library, by registering and uploading DLL assemblies (components) in Bizagi.
You can include any number of components and then choose to use them directly from Bizagi's business rules.
For introductory information about this feature, refer to Custom components.
This article provides an example of using the Component Library feature, where a custom component connecting to an external API is included in Bizagi to extend its functionality.
What you need to do in Bizagi
To use the Component Library feature, complete these steps:
1. Build your component (a compiled output).
2. Register the component in Bizagi.
3. Create the business rule which invokes the component.
When developing a component for the .NET edition, you need to make sure that the compiled component works for the supported framework used by Bizagi.
In Automation Service, the framework used in a .NET platform is version 4.6.1.
A sample Credit Request Process illustrates using the Component Library.
This is a simplified example, in which we validate that the Applicant is not reported using a central Black List in the service task Verify Blacklist.
In this service task, we create a business rules that accesses our developed component to make use of am API. Through this API, we invoke a method that returns whether or not the applicant's ID is listed in the Blacklist.
This illustrates how to use the Component library feature for a .NET project.
Build your component (a compiled output)
The first step is to develop the component as a class library project.
In our sample component MyCreditBureauComponent, we make use of a CreditBureau.dll, which represents an example API.
We include the reference in our component.
For the .NET edition, we build the class library project as a dll assembly.
Our component’s namespace is called MyCreditBureauComponent, and our Class is public (Class1). The method we will use in this example is IsCustomerInBlackList.
Register the component in Bizagi
Having built the component’s assembly in our previous step, we use the MyCreditBureauComponent.dll output to register the component in Bizagi's component library.
To do this, we go to Bizagi Studio’s Tools and add a new component:
Find the .dll file and click open. Upload the MyCreditBureauComponent.dll assembly:
Once the component is added, give it a Display name and a Description.
Since this component references and uses another class library (the API), we need to register and include this API into our Component Library as well.
Therefore, we repeat the steps to add a component, but this time add the CreditBureau.dll assembly.
We need to register our two assemblies as two separate components:
Create the business rule which invokes the component
Now that we have registered our component in the Component Library, we create a business rule which invokes the component’s method.
For the sake of simplicity, the following example shows how to call this component from directly within a business rule.
However, as a best practice in terms of maintainability of your solution, we recommend that you create a global rule (a library rule) that receives input parameters, invokes the component and returns output parameters.
This way, business rules call this global rule, and you have a single point in Bizagi coupled to your component.
Members of your team working on the same project just need to know which global rule to use.
We go to Activity Actions view from our Process wizard, and select the “Verify black list” service task. We include a business rule at this point in the Process:
In the expression, we invoke our MyCreditBureauComponent’s method with the following syntax:
Our Class is not defined as a static class, and therefore we can create an instance of it, so we can invoke its methods. In our example, the complete expression invokes the IsCustomerInBlackList method by:
•Sending out the Applicant’s ID.
•Storing the method’s result in the CreditRequest.InBlackList Boolean-type attribute.
This is the expression:
var temp = new Class1();
At this point, we are set to use a custom component with the Component library feature in Bizagi!
To see this example working, we execute our Process in Bizagi's Work Portal by clicking the Run button:
We can see that after the “Verify black list” service task, our next Activity shows the result of our component’s method invocation: