Can I pass the Object name as parameter to the function in C# script task?
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
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:
Back-end (C#) development basics:
Also, you can register a background operation by following this article and use it in any part of application: