Outsystems — Create a .NET extension — Date difference in months

João Duro
ITNEXT
Published in
4 min readFeb 24, 2021

--

This article aims to simplify the creation and use of .NET extensions in Outsystems. As an example, I will demonstrate how to create and use an action in .NET that provides the month difference between the two dates.

Outsystems developers with some previous backend experience (no matter the language) can easily open Visual Studio and start creating/reusing a dll to use in their Outsystems projects.

But for the ‘new generation’ of low code developers, it’s not as accessible or linear as using low code.

Creating an Extension in .NET

Why?
Consider a situation that your company does some calculations estimating the costs of insurance given certain parameters.
Creating such an engine calculator from scratch in Outsystems would be very hard and time-consuming. With extensions, we can easily reuse .NET code in Outsystems.

How?
1) Open Integration Studio

You can start by creating your own action and later code it in .net, or import actions from a .NET dll

2) Describe your parameters.

For this example, we need a Start date and an end date. The output will be a decimal that represents the difference in months of 2 dates.

3) Edit your .net code (if the action wasn’t imported)

This will open Visual Studio. You will see a file with the name of the extension, in my case: DatesDifference.cs

This file will contain the action you described in Integration Studio, and it contains now the parameters that you’ve added:

You can see that the action MssGetMonthDateDifference has an output parameter that will return the desired calculation and uses the action GetTotalMonths. For that, I’ve created a new file with the calculation action itself (file DatesFunctions.cs)

There are innumerous ways of calculating the difference in months between two dates, but most of the approaches don’t take into consideration the decimals (days), only returning an integer (months) as a difference.
The approach I’ve used in this example to calculate the decimal difference in months was created by:
https://stackoverflow.com/questions/27825610/month-difference-between-2-dates/65284425#65284425

The last step in Visual Studio would be to build your solution to check for any errors. Please consider creating a new project in your VS solution to perform some unit testing there. You can easily call your new action and test it. For this I use a Console App (.NET Framework) project.

4) Verify, Save, Upload and Publish your new extension

Go back to Integration Studio, and click on Verify. Then in the popup window, you can verify, save, upload and Publish your solution.

Now you should be ready to use your new action in your flow in Outsystems.

5) Use your action in Outsystems

Go to Manage dependencies, find there your new extension action(s) and consume them:

Now you can reuse it, and build some logic around it:

Conclusion

Although it’s easy to use .NET extensions in Outsystems, we should take into considerations some points:

  • Maintanibility of .NET code (source control, testing, changes, etc)
  • Sometimes we need to write .NET code from scratch. Consider doing this in Outsystems by reusing small .NET assembly actions instead of a big one with all the logic inside.
  • For the example used in this article, I find it easier to do it in .NET and way less code than using such action in the Outsystems low code.
  • Testing. Testing newly built extensions can be time consuming, you would need to create a new project in your solution (VisualStudio) to create some unit testing. Or use it in your flow already in Outsystems and test it there (which I don’t recommend).

--

--