Hello Everyone,

I am working on a scenario where I need to get Records (With Id and Name) from another object.

In Model class, we can get one record but how to get a Collection of records with a filter/Parameter "Name" it should get all the records with the same Name. 

 

Like 0

Like

4 comments

There is an issue in current versions of Creatio with the filter classes, such as FilterGroup etc, being applied to model load/queries. I've been reporting this issue since 8.0.6 (#SR-01182879) but it's still not yet fixed in 8.0.9, very frustrating (I've been told it will be fixed in 8.1 #SR-01198668 🤞🏻). However you can still use them with a small workaround. The example below will get all Accounts that have Type = Customer:

// make sure to add "@creatio-devkit/common" as sdk
 
const accountModel = await sdk.Model.create("Account");
 
const customerFilter = new sdk.FilterGroup();
await customerFilter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Type.Name", "Customer");
 
// This is the workaround you have to do for the filters to work.
// Shallow copy to a new object and then reassign the items collection.
const newCustomerFilter = Object.assign({}, customerFilter);
newCustomerFilter.items = customerFilter.items;
 
// now use new shallow copied filters in the query
const customers = await accountModel.load({
    attributes: ["Id", "Name", "Type"],
    parameters: [{
        type: sdk.ModelParameterType.Filter,
        value: newCustomerFilter
    }]
});
 
// the customers variable is now an array of accounts with Id, Name, and Type columns
console.log(customers);

The whole issue with the FilterGroup is that the items collection doesn't get unrolled from a collection to an array - the copy forces the object to flatten out how it's expected by the underlying DataService call.

Ryan

Ryan = Creatio's code gap workaround master

Ryan Farley,

 

This is my code : 

handler: async (request, next) => {

        // Get the selected date values

        var dateFrom = new Date(await request.$context.DateTimeAttribute_6jtq65k);

        var dateTo = new Date(await request.$context.DateTimeAttribute_vg9eydm);

        var datesBetween = [];

          var currentDate = new Date(dateFrom);

          while (currentDate <= dateTo) {

        datesBetween.push(new Date(currentDate));

        currentDate.setDate(currentDate.getDate() + 1);

          }

  // Convert dates to integers without the time component

          var datesAsIntegers = datesBetween.map(date => {

        return parseInt(date.toISOString().slice(0, 10).replace(/-/g, ""), 10);

          });

        const accountModel = await sdk.Model.create("UsrEntity_a6e9b72");      

        // Load the accounts based on the filter.

        const accounts = await accountModel.load({

            attributes: ["DateTimeAttribute_x2whel6"],

        });

        console.log(accounts); 

            for (const value of accounts) 

            {

                for (const value1 of datesAsIntegers)

                {

                   const integerValue = parseInt(value1);

                value.NumberAttribute_ejh4wbq === integerValue;

                }

                console.log("1");

            }

return next?.handle(request);

        }

Here we are trying to get value of "NumberAttribute_ejh4wbq" but we are only getting "Id" .

Can you help us with this?

 

 

Verify that the column name is correct. In the accountModel.load your passing the attributes array with "DateTimeAttribute_x2whel6", this needs to be the column name in the object/table (which will likely start with a Usr)

Ryan

Show all comments

Hi,



Looking into implementing Customer 360 now that filter business rules exist in 8.0.9.



However, we noticed lookups are showing inactive values, which is not the case in Classic UI.



Is this expected behaviour (meaning proper filtering of inactive values does not exist yet)? Or is this a bug that needs correction ?



Cheers,



Damien

Like 1

Like

7 comments

Hello,

 

Could you please describe the issue in more detail and provide the screenshots of the problem if possible?

Mira Dmitruk,



Sure !



For example, account types: we have 2 inactive values in our Account Type lookup: Our company & Contractor



In classic UI, when you work on list & form pages, these 2 values will not show up, but in Freedom UI yes (see screenshots below). Same scenario for inactive contacts, inactive accounts, inactive fields in other lookups, etc....







Any idea if this would be fixed for Creatio 8.0.10 ?

Hello!

 

We don`t see a column "Inactive" from our side. Could you please describe how did you create it?

Mariia Sorochan,

 

Indeed sorry, we call it "inactive" but it's deactivated records.



You activate the feature for any object by creating a replacing object, here for accounttype, and you click the OOTB feature "Allow records deactivation"







 

You will then notice the "inactive" column as a choice in the columns to display, such as the example here with a Creatio 8.0.9 trial account:







 

Did this ever get improved upon in a later version of Freedom UI?

Show all comments

Hi community,

 

I have a custom entity A, that has a relation with a Contact entity. 

I would like to edit the related contact in the context of the entity A. Is this possible in Freedom UI?

Could I open a dialog with the Edit form of the Contact?

If it's not possible, I believe I have to navigate to the Contact to edit it.



Thanks,

Ignacio.

 

Like 0

Like

3 comments

Hello Ignacio,



I believe it could be achieved by an Expanded list.

 

For example as it's already realized for Contacts in Accounts:

 

Thank you Bogdan. That could work in case of a multi instance list, like the list of Contacts. What If I have only one contact related to a custom entity, like the example described? 

 

Ignacio,

 

We have only this example of its implementation

Show all comments

Good day, Colleagues!

Does anyone possibly have a code example on the new Freedom page showing how to calculate the difference of values ​​of two page fields and write it into a third field? For example: payment balance = Amount-PaymentAmount Maybe there's also a code example on how to get the exchange rate on the date specified in the Date field according to the Currency field or an example of how to refer to another object to get a value from it.

Like 2

Like

3 comments

You can see how to wire up a code to respond to a field change here:

https://customerfx.com/article/responding-to-an-event-when-a-field-is-c…

As far as getting and setting the values, this article will show you how to do that: 

https://customerfx.com/article/reading-and-setting-field-values-via-cod…

Ryan

Ryan Farley,



Thank you, I will give it a try.

Ryan Farley,

 

How can I achieve the same requiremet, but for the fields that are inside a detail with editable list?

 

Thank you in advance.

 

Best Regards,

Pedro Pinheiro

 

 

Show all comments

Hello 

Can someone help me to know, how I add a detail in a page that I am editing in the application Hub? 

I been searching how to do it but I can't find it. 

Thanks you. 

 

Like 0

Like

1 comments

Hello,

 

Please refer to this article for the detailed information. 



Best regards,

Anastasiia

Show all comments

Hello Everyone ,

 

I have tried to Create a custom Detail in my Custom Section but not able to bind it with "Id" of the Parent Object as in Classic ui When we Create Detail it Automatically fetch the Current Record if and we are able to see the list in detail for current record. Can anyone help how to do the same in Freedom UI

 

Like 0

Like

1 comments

Good day,

In the new interface, the details are configured similarly to the mechanism used in the old interface. It also includes automatic mapping to the ID of the current record, so there is no need to add it separately. For example, in the "Orders" detail added to the "Account" section by default, we can see that the detail displays records where Account.Id (of the current record) is equal to Order.AccountId.

Thank you for your question.

Best Regards,

Pavlo

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) =&gt; {
		// listen for changes to the Lookup field attribute
		if (request.attributeName === "LookupAttribute_spr6dlv" &amp;&amp; !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) =&gt; {
      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) =&gt; {
		// listen for changes to the Lookup field attribute
		if (request.attributeName === "LookupAttribute_spr6dlv" &amp;&amp; !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 ,

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