Hello community,

I'm interested in utilizing the Script element within Creatio. Where can I find reference materials or code samples for C#?

 

Additionally, is there a platform available to compile C# code snippets before directly uploading them to the Creatio Platform (in the Script Task Element)?

Like 0

Like

7 comments

Hello,

 

All available examples of using the code in the script task element can be found here. As for checking the C# code - there is no such platform for business processes script tasks. You can create a code in Visual Studio and check if it works. Then, using the provided article, implement the same functionality in the business process script task.

Is it also possible to create your Standard source code and call those from a script task?  Similar to Process to calculate actual working time in projects on schedule?  

Oleg Drobina,

Thanks for your response. Is it feasible to import Terrasoft packages into Visual Studio? If yes, could you provide the steps to do so ?

keith schmitt,

 

as in OOP you can create an instance of a class and use its methods in the logic of a business process. Use Terrasoft.Configuration in the business process (add it to the process usings in the process settings) and create an instance of your class as SomeClass nameOfTheInstance = new SomeClass().

Ajay,

 

You can enable development in the file system as described here and there won't be a need to manually import packages in the Visual Studio. You will be able to review the code and apply changes to it.

Oleg Drobina,

Is there any video reference available?

Ajay,

 

I'm afraid we don't have it, but I will ask our Academy team if they can create such a video tutorial. Thank you for this suggestion!

Show all comments

Hi. I am using C# decimal functions such as Math.Abs, Math.Round, etc. in a method on a page edit module, but it is not accepted. why is that?

Like 1

Like

4 comments

Dear Ricardo,

 

In order to use the static “Math” class in C# code you should add the “System” namespace to the file:

 

using System;

 

If the issue still exists, please provide us with a source code of the module and the error message. It will help us to analyze the issue in more details.

 

Additionally, please find more information about the “Math” class in the article by the link below:

 

https://docs.microsoft.com/en-us/dotnet/api/system.math?view=netcore-3.1

 

Best regards,

Norton

Norton Lingard,

Thanks for your prompt reply.

the code follows.

Where exactly in the code should I insert "using System; " ?

 

+++++++++++++++++++++++

define("FinJournal1Page", [], function() {

    return {

        entitySchemaName: "FinJournal",

        attributes: {

            "FinJrnNetAmount": {

                dataValueType: Terrasoft.DataValueType.FLOAT,

                dependencies: [

                    {

                        columns: ["FinJrnAmount"],

                        methodName: "calculateNetValue"

                    }

                ]

            }

        },

        modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,

        details: /**SCHEMA_DETAILS*/{

            ...

        }/**SCHEMA_DETAILS*/,

        businessRules: /**SCHEMA_BUSINESS_RULES*/{

            ... 

        }/**SCHEMA_BUSINESS_RULES*/,

        methods: {

            onEntityInitialized: function() {

                // Method parent implementation is called.

                    this.callParent(arguments);

                    this.calculateNetValue();

            },

                

                calculateNetValue: function() {

                //

                // MATH USE EXAMPLE

                //

                var amount = this.get("FinJrnAmount");

                if (!amount) {

                    amount = 0;

                }

                var absAmount = Math.Abs(amount) ;

                result = Math.Round(absAmount * 0.015, 2);

                this.set("FinJrnNetAmount", result);

            }

        },

        dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,

        diff: /**SCHEMA_DIFF*/[

            ...

        ]/**SCHEMA_DIFF*/

    };

});

+++++++++++++++++++++++

Best Regards,

Dear Ricardo,

 

It is impossible to use C# code inside JS code. Please note that it exists similar “Math” object in JS language. Please find more information about it in the article by the link below:

 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math

 

 Best regards,

Norton

Working fine now . Thanks

Show all comments