Clio release 6.1.0.33 provides adding source code schemas to the package via Clio. It can be useful for working with C# code in IDE or Creatio embedded code designer,

 

// Adding source code schemas MySourceCodeSchemaName to package MyPackage
clio add-schema MySourceCodeSchemaName -t source-code -p C:\MyPackage

 

P.S: We plan to add more OOTB templates, the ability to create your own and add a set of different objects for complex cases like using virtual entity

1 comments

Really love the idea of using templates for this. Will make creating configuration services, entity event listeners, and other utility classes much quicker to not have to start from nothing. One of the best ideas!

Thanks ATF/Clio team!

Show all comments

Hi All, 

 

Greetings!

Attaching my source code file.

 

UsrDate -> Date 

UsrStartTime -> Time

CreatedOn -> Date/Time

 

I am getting following error in few records - 

Worklogs Integrations synchronized with errors: {"bd455ee2-8f6e-4aed-bafc-890304110ac3":"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.","3d4508d8-bf40-48b4-ab65-d836c7c0b3da":"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."}

screenshot from the source code is below - 


Screenshot of the record is below - 

 

 

Is it because Start time is NULL ?

If yes how can I handle this in the code so that the records gets synchronized with NULL ?


 

Thanks.

File attachments
Like 0

Like

1 comments

Hello.

I tried to do replicate the same situation. Activity table has a column SendDate which might be null. In business process i created a script task with the following code: 1

The result i got:
1
The values of SendDate columns in my Activity table were all null. All these values became the min value of datetime (1/1/0001 12:00:00 AM).

Your error message says that the datetime type in SQL Server has a limited range for dates it can store, specifically from January 1, 1753, to December 31, 9999. In .NET, the default value for DateTime is DateTime.MinValue, which is January 1, 0001. This default value is far outside the valid range for SQL Server's DateTime type.

After analyzing source code you provided i suggest taking a look at those lines of code and changing your sql command parameter types to SqlDbType.DateTime2:

insertCommand.Parameters.AddWithValue("@usrDate"...
insertCommand.Parameters.AddWithValue("@usrStartTime"...
insertCommand.Parameters.AddWithValue("@createdOn"...

Hope this helps

Show all comments

Is it possible to trigger the Freedom UI Live Data Refresh mechanism (LiveEditing feature) for a specific record from C# code? We have a C# process that is updating data directly in the database for performance reasons, but in certain circumstances we may want to trigger the Live Data Refresh of the record(s). Is this possible in any way? Or do we have to implement a workaround by refreshing from JS code when we think we may have to (so would be over-refreshing and not using the Live Data refresh mechanism).

Like 0

Like

1 comments
Best reply

You can see how that feature works by looking at the "LiveEditingBaseEntityEventListener" source code schema. In initial versions you could see they were just using MsgChannelUtilities.PostMessage and the message name, but in 8.1.2 that has been abstracted away. Still you could execute the same way as implemented in that schema.

Ryan

You can see how that feature works by looking at the "LiveEditingBaseEntityEventListener" source code schema. In initial versions you could see they were just using MsgChannelUtilities.PostMessage and the message name, but in 8.1.2 that has been abstracted away. Still you could execute the same way as implemented in that schema.

Ryan

Show all comments

Greetings Community,

 

     Could someone provide me with references for Script Task queries related to CRUD operations on Creatio objects?

 

      Are there any examples or references available for sample scripts and C# functions regarding the Script Task element suitable for beginners?

Like 0

Like

2 comments

Hello,

 

As the first step, we recommend you to check our Academy article on Script Task process element that includes both instructions and examples of working with it. You can also use Academy and Community for searching examples of implementation of some more specific requests using the key words.

https://academy.creatio.com/docs/8.x/no-code-customization/bpm-tools/pr…

Hello Mira,

 

Thank you for your reply. I have reviewed the Academy article on the Script Task Process element. Also, executed on Creatio platform.

 

I am now interested in learning more about what we can accomplish with the Script Task element. Is there any additional information or examples available for Script element? 

 

regards, 

Ajay

Show all comments

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

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

Is it possible to set the value of a System setting which has the "Save value for current user" setting enabled for a specified user from C# code, e.g. from a script task? I've found the below code for setting a System setting, but presume that if the checkbox for the above is selected, then it will only set the value for the current user (or the System User if running in the system context):

var settingCode = Get<string>("UsrSystemSettingCode");
var value = Get<string>("UsrSettingValue");
Terrasoft.Core.Configuration.SysSettings.SetValue(UserConnection, settingCode, value);
return true;

 

We need to be able to set the per-user system setting for a specific user (determined by data in the BP in our case) but looking at the (always hard to find) API documentation, it doesn't seem like there's an overloaded version of SetValue that allows you to do so as a specified user - except possibly one that is marked as being deprecated in a much older version:

 

Like 0

Like

3 comments

Anybody have any info on this?

Does anyone have any other methods for managing per-user system settings in Creatio? It seems like there aren't a lot of options besides setting them in JS code when a user does a given action, but then that feels like it defeats some of the purpose of system settings being that the value doesn't have to be calculated every time a user does something, and also means it can't reliably be used for tasks like setting a default field value on an entity.

Contemplating using this methodology for running code when a user logs in to set it, hopefully it will work. Would be nice to have some clean way of doing it though, especially since we don't really need to be calculating it every time a user logs in but just when certain data changes: https://customerfx.com/article/executing-code-in-creatio-application-an…

Show all comments

Hi!

 

I am currently working on a functionality that overrides and defines what needs to happen when clicking a button on a detail.

 

This means I am working on a "Source Code" type of file within the configuration, so only C# code involved.

 

I have some trouble debugging the code to see what's wrong besides this message that pops up:

 

I haven't found any debugging tips specifically for this type of "file"/task and I would like to display message boxes with values of variables and so on, just like the one above.

 

I know there is a way to achieve this using business processes and JS code inside the client module, but I haven't found any solution to programatically display this using C# code.

 

Can someone refer me to the class/library where this is located exactly?

 

Thanks,

Laurentiu

Like 1

Like

4 comments

Hello Laurentiu,

 

C# cannot be used to display the popup directly. What can be done is send a websocket message to the client side and display the popup when a websocket message is received. Like described here, but in the onNewMessage method you need to call this.showInformationDialog method (just check how it's called out-of-the-box) and pass the message to it.

If this is a local system you can use debugging with your C# code, see https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platfor…

If this is a cloud system, sending messages to the UI to display a message box isn't the best route since the message boxes aren't blocking, meaning if your code sends 3 messages, only the last one will show in the message box, plus it means you have to add client-side code to receive the message and display it. 

It would be far better to just create a lookup object to write your debug messages to, then you just check the lookup to see the messages. 

Ryan

Ryan Farley,

Do you have an example how to write into a lookup  object please ?

You can write to any object using the following: 

var schema = UserConnection.EntitySchemaManager.GetInstanceByName("AccountType");
var entity = schema.CreateEntity(UserConnection)
entity.SetDefColumnValues();
entity.SetColumnValue("Name", "Some new type");
entity.Save();

 

However, for debugging, even better than writing to an object would be to use logging, see https://customerfx.com/article/logging-information-and-errors-in-creatio-c-code-and-viewing-from-cloud-hosted-systems/

Ryan

Show all comments

We've got a requirement to run some async entity event listener code, but when following the academy article for that ( https://academy.creatio.com/docs/7-18/developer/back_end_development/ob… ) and trying to use the arguments.OldEntityColumnValues property of the EntityEventAsyncOperationArgs arguments parameter passed in, we get the following compilation error which we cannot seem to resolve:

 

From looking online for general resolutions, it looks like we maybe need to add this assembly to the web.config file, but we're on a cloud instance so presume this isn't a feasible resolution.

 

Any advice would be greatly appreciated.

 

Reduced version of the code (without usings etc shown) that throws the error below:

public class UsrAsyncSendLeadAssociation: IEntityEventAsyncOperation
{
    public void Execute(UserConnection userConnection, EntityEventAsyncOperationArgs arguments) {
        var oldModVal = arguments.OldEntityColumnValues;
    }
}

 

Like 0

Like

1 comments

Hello,

As a quick solution, you should disable the option "Compile into a separate assembly" in the package where the schema is located.

After this, the problem should be resolved.

Show all comments

New clio release 6.0.2.16 provide new feature for exploring file content on remote server.

clio files --package CrtBase
 
descriptor.json
src\css\driver.min.css
src\js\bootstrap.js
src\js\driver.min.js
 
clio files --package CrtBase --file descriptor.json
 
{
        "bootstraps": [
                "src/js/bootstrap.js"
        ]
}

P.S: Exploring features coming soon to clio explorer with edit mode

2 comments

This is fantastic. I assume this will eventually be available to view package file contents in Clio explorer as well?

Ryan

Ryan Farley,

Yes, we plan to do it in the near future and are already working on it.

Show all comments