Hi,

I've created a custom FreedomUI page for AccountAddress object. I'd like to implement some kind of automation for two lookup fields: Country and Region. It consists of two parts:

1. When I choose a region from list, the country should be set to region's country. For example, if I choose Texas region, I expect that country will be set to United States

2. When I choose a country, regions lookup should display only these regions, which are connected with selected country.

I haven't any problem with implementation of the first part. But the second part doesn't work I expected. I use handler for crt.LoadDataRequest to append a filter parameter when loading regions list. The problem is that this handler runs only once, at first list load. It doesn't execute when I change country, although I trigger such request from other handler (crt.HandleViewModelAttributeChangeRequest). Here is the crucial of my code:

{
	request: 'crt.LoadDataRequest',
	handler: async (request, next) => {
        if (request.dataSourceName === 'Region_List_DS') {
	        const predefinedFilter = await request.$context.Region_filter;
	        request.parameters.push({
		        type: "filter",
		        value: predefinedFilter
	        });
        }
 
		return await next?.handle(request);
	}
},
{
	request: 'crt.HandleViewModelAttributeChangeRequest',
	handler: async (request, next) => {
        if (request.attributeName === 'EvCountry' && request.value?.value != null && (request.oldValue?.value == null || request.value.value !== request.oldValue.value)) {
			const countryId = request.value?.value;
            request.$context.EvRegion_filter = {
				"items": {
					"1954b2e1-ea91-4014-b785-cda17020595c": {
						"items": {
							"CustomFilters": {
								"items": {
									"customFilterCountry_Region_1664cb4d-2690-48d6-bcdf-0c8075824efa": {
										"filterType": 1,
										"comparisonType": 3,
										"isEnabled": true,
										"trimDateTimeParameterToDate": false,
										"leftExpression": {
											"expressionType": 0,
											"columnPath": "Country"
										},
										"rightExpression": {
											"expressionType": 2,
											"parameter": {
												"dataValueType": 10,
												"value": countryId
											}
										}
									}
								},
								"logicalOperation": 0,
								"isEnabled": true,
								"filterType": 6
							}
						},
						"logicalOperation": 0,
						"isEnabled": true,
						"filterType": 6
					}
				},
				"logicalOperation": 0,
				"isEnabled": true,
				"filterType": 6
			};
 
			const handlerChain = sdk.HandlerChainService.instance;
			const result = await handlerChain.process({
				type: "crt.LoadDataRequest",
				$context: request.$context,
				config: {
					loadType: "load"
				},
				dataSourceName: "EvRegion_List_DS",
			});
		}
 
		return next?.handle(request);
	}
}

The problem is that my trigger (handlerChain.process call) doesn't run crt.LoadDataRequest, and result variable contains full, unfiltered list of regions.

Like 1

Like

5 comments

Hello,

 

Thank you for the code and description!

 

We've verified the issue and discussed it with our core R&D team: in 8.0.9 there will be a possibility to add filtration business rules using wizard capabilities in Freedom UI. Please wait until this version is released and use this rule type to create dynamic filtration in Freedom UI interface.

Oleg Drobina,

as filtration business rules do not cover all cases of filtration, when can we wait for trigger fix?

We have tested in 8.0.9 and have the same issue as described



Thank you!

Vladimir

Vladimir Sokolov,

 

indeed filtration rules (along with static filtering business rules) don't cover all cases, but most of them. As for the list loading and the LoadDataRequest - in 8.1.0 there will be new "filterAttributes" attribute added for each list of each data source with the boolean "loadOnChange" property that will allow dynamic setup of filters in the lists (including combobox). It will look like this:

"filterAttributes": [
					{
						"loadOnChange": true,
						"name": "AccountItems_FILTER_BY_ACTIVE_ROWS"
					}

where AccountItems_FILTER_BY_ACTIVE_ROWS will be the filter itself. So in 8.1.0 all filtration cases should be covered by this functionality.

Hello,

 

Glad to inform you that in 8.1.1 we've added the possibility to use custom filters in page schema handlers when working with SDK. So you can upgrade your apps and you will be able to use custom filtration on the page.

Hi Oleg,

 

Do you have the code / Procedure to do this in 8.1.1 ?

Show all comments

Hello,

 

Can any one help me how to get "Description" of a lookup type field and Populate it in any Other Field via code in freedomUI ? 

Like 0

Like

2 comments
Best reply

I'm positive there is a way to register the field as an attribute for the Lookup's data source, I've just not figured out or tested how to do that yet. Likely info here https://academy.creatio.com/docs/developer/front_end_development_freedo…

As for now, you could do the following - in this example I have a lookup for ContactType and will retrieve the Description once selected. You'll ned to know the actual attribute name for the lookup which you can see in the viewDiffConfig for the control as:

control: "$SomeAttributeName"  (this is the attribute name, minus the "$")

Then, add a change request handler like this: 

{
	request: "crt.HandleViewModelAttributeChangeRequest",
	handler: async (request, next) => {
		// listen for changes to the Lookup field attribute
		if (request.attributeName === "LookupAttribute_spr6dlv" && !request.silent) {
			// get the selected value
			var lookupVal = await request.$context.LookupAttribute_spr6dlv;
			// retrieve the description
			const model = await sdk.Model.create("ContactType");
			const results = await model.load({
				attributes: ["Description"],
				parameters: [{
					type: sdk.ModelParameterType.PrimaryColumnValue,
					value: lookupVal.value
				}]
			});
			const desc = results[0].Description;
			// set the other column's attribute with the description
			request.$context.SomeOtherAttribute = desc;
		}
 
		return next?.handle(request);
	}
}

Ryan

Hi,

 

Example of retrieving description value of the lookup:

const accountCategoryModel = await sdk.Model.create("AccountCategory");
					const accountCategory = await accountCategoryModel.load({
						attributes: ["Id", "Name", "Description"],
						parameters: [{
							type: sdk.ModelParameterType.PrimaryColumnValue,
							value: "38ea507c-55e6-df11-971b-001d60e938c6"
						}]
					});
					console.log("The result: ", accountCategory);

value: "38ea507c-55e6-df11-971b-001d60e938c6" - Id here can be dynamically set as some variable that is received from the context. To set the result for the column (in this case for the UsrSubjectDetails):

request: "crt.HandleViewModelAttributeChangeRequest",
    handler: async (request, next) => {
      if (request.attributeName === 'UsrSubject') {
        const isFieldsShouldBeSynchronized = request.oldValue === await request.$context.UsrSubjectDetails;
        if (isFieldsShouldBeSynchronized) {
          request.$context.UsrSubjectDetails = "some value";
        }
      }

 

I'm positive there is a way to register the field as an attribute for the Lookup's data source, I've just not figured out or tested how to do that yet. Likely info here https://academy.creatio.com/docs/developer/front_end_development_freedo…

As for now, you could do the following - in this example I have a lookup for ContactType and will retrieve the Description once selected. You'll ned to know the actual attribute name for the lookup which you can see in the viewDiffConfig for the control as:

control: "$SomeAttributeName"  (this is the attribute name, minus the "$")

Then, add a change request handler like this: 

{
	request: "crt.HandleViewModelAttributeChangeRequest",
	handler: async (request, next) => {
		// listen for changes to the Lookup field attribute
		if (request.attributeName === "LookupAttribute_spr6dlv" && !request.silent) {
			// get the selected value
			var lookupVal = await request.$context.LookupAttribute_spr6dlv;
			// retrieve the description
			const model = await sdk.Model.create("ContactType");
			const results = await model.load({
				attributes: ["Description"],
				parameters: [{
					type: sdk.ModelParameterType.PrimaryColumnValue,
					value: lookupVal.value
				}]
			});
			const desc = results[0].Description;
			// set the other column's attribute with the description
			request.$context.SomeOtherAttribute = desc;
		}
 
		return next?.handle(request);
	}
}

Ryan

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

Hello ,

I have a requirement where "A" is a date field and "B" is a boolean. When a record is created, it should calculate the number of days left until "A" arrives. If the number of days left is less than 45, then the value of "B" should be changed to "true". 

Note : I m using Freedom UI. Also if this is possible through Bussiness Process please Advise.

Like 0

Like

4 comments

Good day,

 

This can be done by making a formula to count days between "today" and your filed "A" with a function .Days.

It should look something like the following:

 

([#Date value.5/31/2023#]-[#System variable.Current Date#]).Days

 

I will also will leave some community questions on the matter:

https://community.creatio.com/questions/auto-calculate-age-based-new-bi…

https://community.creatio.com/questions/need-use-caluculated-field-valu…

 

Cheers.

Artem,



I have Created A process but data is not reflecting as i want.

Screenshot of Process and records are attached 

This is my SubProcess



This is my Main Process





This is the list of Records





Here Course C is the field which displays the Days which is not Correct. 

Please Advise



 

 

Hey there,

 

If you are referring to the way the data is represented, it depends on the type of the column (in order to make the value not have zero after it - make the column integer)

 

If you want to show a checkbox that would be ticked if a certain number is reached and you do not want to use code, keep the column in which you store the number of days, and on the base of it, build a business rule that "if the number of days is reached, then make the box true"



https://academy.creatio.com/docs/user/nocode_platform/freedom_business_…

 

Thank you

Artem,

 Thanks for your reply.

I want the value in Field should be correct as it is 92 for all records allthough there are some records whose value should be 30 days or 60 days

 

Show all comments

Hi Community,

 

I would like to know how we can make a column mandatory in an attachment list (the detail here) as soon as we upload a file to the detail.

 

 

Thanks in advance!

 

Regards,

Abilash.S

Like 0

Like

1 comments

To make a column mandatory in FreedomUI, you can follow these steps:

  1. Identify the column you want to make mandatory in the detail view of your form.

  2. Open the code or configuration file associated with your FreedomUI implementation.

  3. Locate the section or code block related to the detail view of your form.

  4. Find the column you want to make mandatory within the code or configuration.

  5. Depending on the specific implementation of FreedomUI, you can typically add a validation rule or attribute to the column to make it mandatory.

  6. Add the necessary code or configuration to enforce the mandatory requirement for the column. This may involve setting a "required" flag, adding a validation rule, or specifying a validation message.

  7. Save your changes and test the form to ensure that the column is now mandatory in the detail view.

It's important to note that the exact steps may vary depending on the version and customization of FreedomUI you are using. Refer to the documentation or consult with the developers or support team of FreedomUI for specific guidance on making a column mandatory in the detail view.



More detail : https://360degreecloud.com/

Show all comments

Hi Creatio Community,

 

I would like to know the name of the function/handler that's called when creating a record and saving it in an editable detail in FreedomUI so that we can override it. We also noticed SaveRecordRequest doesn't seem to be called here.

 

Thanks in advance.

 

Regards,

Abilash.S

Like 0

Like

4 comments

Hello,

 

These should be the crt.CreateRecordRequest request and the crt.CreateRecordHandler handler. Try those in either:

 

1) Page where detail is added

2) Detail schema

3) Edit page of the detail

 

and it should be triggered.

Oleg Drobina,

 

Tried these two methods. They don't seem to be called when creating and saving the records in an editable detail.

Abilash,



I tried this handler:

handlers: /**SCHEMA_HANDLERS*/[
			{
				request: "crt.CreateRecordRequest",
				handler: async (request, next) => {
					return next?.handle(request);
				}
			}
		]/**SCHEMA_HANDLERS*/,

on the schema where detail is added and it's successfully triggered:

It also depends on which handler you have specified in the "Add button" properties, you need to find it in the schema diff (in my case it was crt.CreateRecordRequest):

{
				"operation": "insert",
				"name": "GridDetailAddBtn_z5e8jja",
				"values": {
					"type": "crt.Button",
					"caption": "#ResourceString(GridDetailAddBtn_z5e8jja_caption)#",
					"icon": "add-button-icon",
					"iconPosition": "only-icon",
					"color": "default",
					"size": "medium",
					"clicked": {
						"request": "crt.CreateRecordRequest",
						"params": {
							"entityName": "Contact"
						}
					},
					"visible": true,
					"clickMode": "default"
				},
				"parentName": "FlexContainer_n5yrzkv",
				"propertyName": "items",
				"index": 0
			},

 

Oleg Drobina,

 

The detail we are working with uses an inline record to create new records which doesn't seem to be calling CreateRecordHandler or CreateRecordRequest. 











 

Show all comments

Hi Community,

 

Would like to know how we make a list display in FreedomUI editable or make one of it's columns editable.

 

 

Thanks in advance.

 

Regards,

Abilash.S

Like 0

Like

6 comments

Hi Abilash,



As I can see on the screenshot, it's not a freedom UI section.



For the freedom UI section, you can use the Expanded list element

 

And you can make it editable:

Bogdan,

When I open the designer for the above page I'm getting this:



 

As you can see, I don't have the option to make it editable.

 

Abilash,



Is it expanded list element?

Bogdan,

I'm not sure. How do I check that?

 

Abilash,

 

Tis is not a expanded list element this is a Attachment Element

To my pleasant surprise, it appeared that that attachments component became editable since 8.0.7. If you upgrade your instance you should be able to make it editable. 

Show all comments

In contact/Account list , every time i want to go to a field proporties it blocks the page .

This is the error i get in the console :

Like 0

Like

1 comments

Hello,

 

This issue has already been resolved in version 8.0.8.

If the error persists in your version, please create a support ticket with support@creatio.com.

As a workaround, you can access the properties of the column through the page designer.

Show all comments

Hello Community, 

 

I have a requirement to validate a Column in the editable detail.

How can we achieve this? I tried using validators with the column name of Datagrid. But it didn't worked.

 Any suggestions is really helpful. 

 

Thanks

Gargeyi.G

File attachments
Like 0

Like

3 comments

Hello,

In order to add validation to an editable detail you need to override the method save() in the detail page, for example:

define("UsrSchema1051cea3Page", [], function() {
	return {
		entitySchemaName: "UsrTestDetObj",
		attributes: {},
		modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
		methods: {
			save: function() {
                    if (this.get("UsrName") == "1") {
                        this.callParent(arguments);
                    } else {
                        this.showInformationDialog("UsrName should be 1 ");
                    }
                }
		},
		dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
	};
});

 

Hello, 

 

Thankyou for your response, 

But I wanted to validate columns in the detail,

I don't open the detail page and so I don't want to validate in the detail page but in the inline record.

please find attached screenshot

Hi,

This example is working on a detail itself.

With it, you cannot save the record unless the condition is met.

Considering the fact that detail fields are virtually generated, this is the best option to add validation.

Show all comments