For instance, I've crafted a function to generate a contact:

 

void InsertContact(string contactName) {
   UserConnection userConnection = Get("UserConnection");

   contactName = contactName ?? "Unknown contact";


   var ins = new Insert(userConnection)
       .Into("Contact")
       .Set("Name", Column.Parameter(contactName))
       .Set("JobTitle", Column.Parameter("Consultant"))
       .Set("Notes", Column.Parameter("C# Script Test"));

 

   var affectedRows = ins.Execute();
}

 

However, I desire the function to be more versatile:

void InsertObject(string contactName, string ObjectName, var Object) {


   UserConnection userConnection = Get("UserConnection");

 

   // Generate a query dynamically using Object Name, Contact Object Columns, and Values

   var ins = new Insert(userConnection)
       .Into(ObjectName)
       .Set(Object["key"], Column.Parameter(Object["value"]));

 

   var affectedRows = ins.Execute();
}

This enhanced function can be dynamically utilized within the Script Element.

 

Is it possible to create the dynamic functions in Creatio like this?

 

Like 0

Like

1 comments

Hello, Ajay!

You can implement any logic with the code in the Creatio configuration, and any realization in C# is supported. Your code example looks logical and you can add it to the script task in business process, for example. 
More information about Script tasks:

https://academy.creatio.com/docs/8.x/no-code-customization/bpm-tools/process-elements-reference/system-actions/script-task-process-element

Back-end (C#) development basics:

https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/architecture/development-in-creatio/back-end-c-sharp

Also, you can register a background operation by following this article and use it in any part of application:

https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/back-end-development/data-operations-back-end/execute-operations-in-the-background/examples/register-a-background-operation

Show all comments

Hi Community,

I had created a section through business process, and now I want to add a detail in it using Script task. Please help

Like 1

Like

1 comments

Hello, adding a working detail using a Script task can be a very difficult task. In the detail wizard, there is a list of methods like %CreateSchema%, %DesignSchema% or %SaveSchema% which are used while creating details. Unfortunately, there are no detailed instructions on how to do it. But I can recommend looking at schemas SectionPageWizard and SectionWizard to see how it is done in the Detail wizard.

Show all comments