Good day!

Task: Upon changing the Type field in the account card, export all records from the section  to a CSV file on the user's computer.

You encountered an error message: 'File' does not contain a definition for 'WriteAllText'. However, you have included the using System.IO; directive.



Code:

 

  namespace Terrasoft.Configuration

{

    using Common;

    using System;

    using System.Linq;

    using Terrasoft.Core;

    using Terrasoft.Core.Entities;

    using Terrasoft.Core.Entities.Events;

    using Terrasoft.Core.Factories;

    using Newtonsoft.Json;

    using System.IO;

    #region Class: CHAccount_Custom_1EventListener

    [EntityEventListener(SchemaName = "Account")]

    public class CHAccount_Custom_1EventListener : BaseEntityEventListener

    {

        Entity _entity;

        UserConnection _userConnection;

        public UserConnection UserConnection => _userConnection ?? (_userConnection = _entity?.UserConnection);

        #region Methods: Public

        public override void OnSaved(object sender, EntityAfterEventArgs e)

        {

            base.OnSaved(sender, e);

            _entity = (Entity)sender;

            _userConnection = _entity.UserConnection;

            var typeId = _entity.GetTypedColumnValue("TypeId");

            // Check if the saving event occurred for the Account object.

            if (typeId == new Guid ("f2c0ce97-53e6-df11-971b-001d60e938c6"))

            {

                // Retrieve data of the accounts from the Account object.

                EntitySchemaQuery esq = new EntitySchemaQuery(_entity.Schema);

                esq.AddColumn("Name");

                esq.AddColumn("CreatedOn");

                EntityCollection collection = esq.GetEntityCollection(UserConnection);

                if (collection != null && collection.Count > 0)

                {

                    // Create a CSV file.

                    string csvContent = "Name,Date\n";

                    foreach (Entity entity in collection)

                    {

                        string name = entity.GetTypedColumnValue("Name");

                        DateTime date = entity.GetTypedColumnValue("CreatedOn");

                        csvContent += $"{name},{date.ToString("yyyy-MM-dd")}\n";

                    }

                    // Save the CSV file to the C drive of the user's computer.

                    string filePath = @"C:\Accounts.csv";

                    File.WriteAllText(filePath, csvContent);

                }

            }

        }

        #endregion

    }

    #endregion

}

 

Like 1

Like

2 comments
Best reply

Hi,

 

It happens because the system thinks that File is the Terrasoft.Configuration.File class by default. You need to specify complete class path (System.IO.File) in the code:

 

System.IO.File.WriteAllText(filePath, csvContent);

 

for the code to publish successfully.

Hi,

 

It happens because the system thinks that File is the Terrasoft.Configuration.File class by default. You need to specify complete class path (System.IO.File) in the code:

 

System.IO.File.WriteAllText(filePath, csvContent);

 

for the code to publish successfully.

Oleg Drobina,

Thank you very much, that helped."

Show all comments

Hello.

 

For now

request.$context.LookupPropName = undefined

clear the value, but not triggers any change events on page.

 

How can i clear lookup value on the page with triggering 

crt.HandleViewModelAttributeChangeRequest request?

Like 1

Like

1 comments

Hello,

It looks like the only possible solution for you would be to clear the value inside the business process.

Otherways you just don't trigger the handler.

Show all comments

Hi, 

 

we have a new requirement of the customer like when we perform the import from excel, the customer wants to change the screens while performing the import process. as shown in the picture. 

 

 

File attachments
Like 0

Like

1 comments

Hello,

 

unfortunately, because of the fact that the mechanism behind the import process is quite difficult to customize as it has some core dependencies, there is no possibility to create those changes you are talking about at the moment.

 

Regards,

Gleb.

Show all comments

Hello,

I need to redirect a user to an Account edit page under certain conditions, after an activity is completed via the activity mini page. For this I used the OnSaved() event as indicated in the sample code, but I get the error below. How do I resolve this?

onSaved: function() {
	this.callParent(arguments);
	this.sandbox.publish("PushHistoryState", {hash: "CardModuleV2/AccountPageV2/edit/" + "f71a7d76-8ac6-46cb-ab7a-a8dae49471b4"});
},

core-base.js:704 user: Supervisor/7f3b869f-34f3-4f20-ab4d-7480a5fdf647

 file: http://localhost:50081/0/core/hash/ng-core/src/polyfills-es5.js?hash=cd…

 line: 1

 column: 83823

 message: Uncaught Terrasoft.UnsupportedTypeException: Message PushHistoryState is not defined in MiniPageModule (ViewModule_MiniPageListener_MiniPage_ActivityMiniPage) module 

 date: Tue May 23 2023 18:15:14 GMT-0500 (Central Daylight Time)

 stack: undefined

 

 

Like 0

Like

1 comments

Hello,

 

Try sending a custom sandbox message to MainHeaderSchema for example and call NetworkUtilities.openEntityPage (see it's usage in the basic code) upon receiveing this custom message. This should also open the edit page of account.

Show all comments

Hello,

We are using an out-of-the-box detail created by Creatio with code "OpportunityTeam" in the Opportunity section and would like to remove a filter on it.   The Contact lookup on the detail object "Opportunity participant" is being filtered by the Account lookup on the Opportunity object.  This means that users can only add contacts to the "OpportunityTeam" detail which have the same account as the account listed on the opportunity.  We do not want this behaviour so are looking for how to remove it.

 

There are no business rules on the Opportunity section page or the detail causing this filter.  Does anyone know which schema or perhaps mixin is causing this filter?



Thank you for your help!

Like 0

Like

0 comments
Show all comments

Hello!

I added a new section based on the ActivityFile object but the folders  are not displayed in the section? and in  the actions menu .

Who can i display folders in the section!

Thanks

 

 

Like 0

Like

1 comments

Hello!

 

We checked your problem and unfortunately, there is no possibility to add a “Show folders” button item.

When you created a new section, you should have seen this popup:

 

Best regards,

Kate

Show all comments

Can we get MFA implemented for Portal access?  The portal may contain private/personal info and would be required for compliance.

Like 2

Like

3 comments

Hi Mike,

 

At the moment there is no possibility to set up a two-factor authentication directly through Creatio.



But I believe your business task could be achieved by SSO integration.

Bogdan,

If Creatio wants this product to be adopted by Enterprise level customers, you will want to have this capability.  In today's world of security, I'm shocked and frankly dismayed that your CISO and CTO don't have this on your roadmap.  unbelievable.

Hi Mike Oliver,



The 2FA is currently in beta testing:

 

Please pay attention to the list of limitations:



1. Integrations only work through OAuth, as the integration cannot pass the second factor.

3. Additional configuration of the mobile application is required - the mobile app utilizes the system setting MobileExtendedAuthenticationUrl.

3. Only one authentication provider is allowed (provider with built-in second factor).

4. The provider must be registered with the name "InternalUserPassword" for the proper functioning of password expiration checks.

5. Not supported for portal users.

6. There is no possibility to specify which users require a second factor. It is enabled for all users.

 

 

Show all comments

Hello,

Lookup fields on Freedom UI have a feature that let user create a new record from lookup Field, like on the following screenshot (Owner field on Account Form Page):

I'd like to set some default values on such created record. For example, I'd like to set the new contact's account to current account record. I'm able to do this while using simple buttons, but I don't see such possibility for lookups.

It will be ok, even if the answer requires some coding, I have nothing against :)

 

Like 1

Like

4 comments

Hello,



You can set the default value for the column if the object settings:



 

Hi,

I know that its possible to set default value on the object level, but unfortunately it doesn't solve my problem. Let's see an example:



In Account, I have two important fields: Owner (which is my company employee, who takes care about the customer) and Primary contact (which is my customer, related with the account). Both fields refer to Contact records.

 

In Contact, I have a Type lookup, which I use to recognize whether a contact is my company employee or a customer.

 

I'd like to set Type to my company Employee, when adding record from Owner field, or set it to Customer otherwise. I can't do it by setting a default value on the object level.

 

Anyway, thank you for your answer :)

 

Hello again, do anyone know answer for my question? :)

Maybe try to set value through Business Rules. It can do this as much as I understood your query.

Show all comments

Hello,

some elements like button have "clicked" attribute, where we can configure which request should be emited and which params should be passed to its handler. I try to use this feature, but it doesn't always work I expected.

For example, I created two new elements on Accounts Form Page:

- a button

- a lookup (with adding new record from list control enabled)

 

The first one emit crt.CreateRecordRequest with some params, the second one consists of two viewConfigDiff entries: one of them is a crt.ComboboxSearchTextAction and emits crt.CreateRecordFromLookupRequest

request with no params.

I tried to add my custom param to both elements. You can see it at the source code I've attached to this post. Then, I created two handlers, for handling both types of requests. In the result I can access to my custom param from button click handler (the alert with text "Hello" shows up), but not for the lookup create new record handler (the alert display "undefined").

 

define("Accounts_FormPage", /**SCHEMA_DEPS*/[]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/()/**SCHEMA_ARGS*/ {
	return {
		viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
			{
				"operation": "insert",
				"name": "ComboBox_xj333ko",
				"values": {
					"layoutConfig": {
						"column": 1,
						"row": 9,
						"colSpan": 1,
						"rowSpan": 1
					},
					"type": "crt.ComboBox",
					"label": "$Resources.Strings.LookupAttribute_it9tgfm",
					"labelPosition": "auto",
					"control": "$LookupAttribute_it9tgfm",
					"listActions": [],
					"showValueAsLink": true,
					"controlActions": []
				},
				"parentName": "SideAreaProfileContainer",
				"propertyName": "items",
				"index": 8
			},
			{
				"operation": "insert",
				"name": "addRecord_al7wl16",
				"values": {
					"code": "addRecord",
					"type": "crt.ComboboxSearchTextAction",
					"icon": "combobox-add-new",
					"caption": "#ResourceString(addRecord_al7wl16_caption)#",
					"clicked": {
						"request": "crt.CreateRecordFromLookupRequest",
						"params": {
							"MyParameter": "Hello" // HERE
						}
					}
				},
				"parentName": "ComboBox_xj333ko",
				"propertyName": "listActions",
				"index": 0
			},
			{
				"operation": "insert",
				"name": "Button_93h456o",
				"values": {
					"layoutConfig": {
						"column": 1,
						"row": 10,
						"colSpan": 1,
						"rowSpan": 1
					},
					"type": "crt.Button",
					"caption": "#ResourceString(Button_93h456o_caption)#",
					"color": "default",
					"disabled": false,
					"size": "large",
					"iconPosition": "only-text",
					"visible": true,
					"clicked": {
						"request": "crt.CreateRecordRequest",
						"params": {
							"entityName": "Contact",
							"defaultValues": [
								{
									"attributeName": "Age",
									"value": null
								}
							],
							"MyParameter": "Hello" // HERE
						}
					},
					"clickMode": "default"
				},
				"parentName": "SideAreaProfileContainer",
				"propertyName": "items",
				"index": 9
			}
		]/**SCHEMA_VIEW_CONFIG_DIFF*/,
		viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
			"attributes": {
				"LookupAttribute_it9tgfm": {
					"modelConfig": {
						"path": "PDS.EvColumn1"
					}
				}
			}
		}/**SCHEMA_VIEW_MODEL_CONFIG*/,
		modelConfig: /**SCHEMA_MODEL_CONFIG*/{}/**SCHEMA_MODEL_CONFIG*/,
		handlers: /**SCHEMA_HANDLERS*/[
			{
				request: "crt.CreateRecordFromLookupRequest",
				handler: async (request, next) => {
					alert(request.MyParameter);
					return next?.handle(request);
				}
			},
			{
				request: "crt.CreateRecordRequest",
				handler: async (request, next) => {
					alert(request.MyParameter);
					return next?.handle(request);
				}
			}
		]/**SCHEMA_HANDLERS*/,
		converters: /**SCHEMA_CONVERTERS*/{}/**SCHEMA_CONVERTERS*/,
		validators: /**SCHEMA_VALIDATORS*/{}/**SCHEMA_VALIDATORS*/
	};
});

What can I do to make it's working? I use version 8.0.7 (.NET core).

---------------------

This alert displays after click on the button:

And this alert displays after trying to add new record from the lookup:

 

Like 0

Like

4 comments

Hello Eryk,

 

You did everything correctly according to the basic logic and I was able to reproduce the same behaviour on my end. Additionally I reviewed the request in debugger, its context and other properties and wasn't able to locate the "MyParameter". I will pass this info to our core R&D team so they could make it possible to operate with custom parameters in terms of the CreateRecordFromLookupRequest request handler.

Oleg Drobina,

 

Is this the recommended way to pass custom parameters to a request handler in 8.1.3 and above? i.e. to just specify the parameter within the call to it from e.g. a button, and use it directly in the code? No decorations around the request handler, such as a params: [{"name": "someParamName"}] property similar to how Validators have? Or is there some more recommended way?

Harvey Adcock,

Thank you for your question.

You can read about decorating parameters in request handlers here. It is up to you how you implement the logic of your custom request handler; however, it is recommended to follow the guidelines provided by the Academy.

Let me know if you have any questions left, i will be glad to assist you!

Hello Harvey Adcock,

Update to your question. 
 

We got an answer from the R&D of the platform. There is no need and it is not recommended to decorate your parameters in custom request handler.

Hope this helps and let me know if you have any question left.

 

Show all comments

Hi,

 

I have a few checkbox fields on the Order page and would like to update the Order stage in the DCM based on the field values. Can anyone tell me what will be the best way to go about it?

Like 0

Like

4 comments

Hello Nirupama ,

You can use Business process to update the DCM .When the checkbox fields are modified have a trigger in Business process and modify the DCM stage using modify element

Pavan Manne,

Thanks, Pavan! That should work. I was just wondering if there is a way to do it from client side without creating a business process. Setting the Stage value through client code did not seem to work. Do you know if there is a way to update the DCM stage using client side code?

Thanks, Pavan! 

Show all comments