Время создания
Filters

Hello everyone,

I’m working on a solution that automatically adds 15 minutes to the StartDate and assigns this new value to the DueDate attribute in Creatio. The issue is that although the logs show the correct date (after adding 15 minutes), the DueDate value is not updating on the page, and I still see the old value.

Here’s my code in the handler:

javascript

handlers: [
  {
    request: 'crt.HandleViewModelAttributeChangeRequest',
    handler: async (request, next) => {
      if (request.attributeName === 'StartDate') {
        const startDate = request.$context.StartDate;
        console.log("StartDate before adding minutes: ", startDate);
 
        if (startDate) {
          // Add 15 minutes to StartDate
          const newDueDate = new Date(new Date(startDate).getTime() + 15 * 60 * 		  1000);
          console.log("DueDate after adding 15 minutes: ", newDueDate);
 
          // Assign the new value to DueDate
          request.$context.DueDate = newDueDate;
 
          // I also tried using $set to update the UI
          try {
            if (request.$context.$set) {
              request.$context.$set('DueDate', newDueDate);
            }
          } catch (error) {
            console.log('Error with $set method:', error);
          }
        }
      }
 
      return next?.handle(request);
    }
  }
]
  • The logs show that the date is correctly calculated, and 15 minutes are added 
  • However, on the Creatio interface, I see that DueDate is not updating.
  • Even though I tried using the $set method to update the value, it still does not work.

**Has anyone encountered this issue before? How can I ensure that the DueDate is updated correctly on the interface after modifying StartDate? Any suggestions would be greatly appreciated!

Thank you in advance!

Like 0

Like

2 comments

First of all, are you sure the attribute for DueDate is really DueDate? I'd start with making sure you're using the correct attribute name as located on the viewModelConfigDiff. 

Second, the change request not only fires when a user changes a value, but also when the page loads the data initially. If you want to only handle the change when a user changes the value, add a check for request.silent=false (silent=true means it was silently loaded on the page, not an actual change occurring). 

Your if statement would look like this to only handle changes made after the page it loaded by the user: 

if (request.attributeName === 'StartDate' && !request.silent) {
    // code here
}

Ryan

It actually turned out that the attribute had a different name , but in addition I had to leave the ‘await’ 
const startDate = (await request.$context.StartDate);
Now it works, thank you for your help  :) 

Show all comments

Hi everyone!

 

I am stuck with the BP, hope you can help me out.

 

I have a detail with duplicate records in it. These records are automaticaly added after the certain emailing (via webhooks). The issues is there are duplicates and I do need them - I need some of them be deleted and at least one should be staying (see image below). 

 

I cannot understand how to write the deleting part in business process

 

Like 1

Like

0 comments
Show all comments

Hi Community,

 

We are trying to create a filter for this detail, that will use two conditions (one for each column) and a logical operator of “OR”. So basically, we only want the records that have the main record id on one of these columns (Contrato or Contrato Umbrella).

 

 

To achieve this, we first tried to add the filter using the FreedomUI Page Designer. However, the filter does not work with the logical operator “OR”.

 

 

So we needed to add it manually, through code. By following this post https://community.creatio.com/questions/detail-filter-freedom-ui. But that didn’t work.

 

 

An alternative was to add the filter in the viewModelConfigDiff section, but we don’t know how can we make the value dynamic.

 

 

Could you please help us find a solution to this problem?

 

Thank you.

Like 3

Like

1 comments

Hello Pedro,

Please review one of the community questions to find the example of Terrasoft.LogicalOperatorType.OR usage.

Additionally here is an explanation of how filtration on Detail work for FreedomUI. 

Case description:
On Contacts page there is a Job experience detail with listed companies where the person worked. Our goal is to show only those departments in the department field that are specified for chosen employer (Account object). So, for this case, Alpha Business has only 2 departments listed in the Departments detail. We only want to see those 2 departments when choosing a department for this account on Job experience detail on Contact page. 

For filtering we basically need just 2 base handlers to be triggered:

  1. crt.DataGridActivateRowBusinessRulesRequest – triggered when we click on an existing detail row or add a new one.
  2. crt.HandleViewModelAttributeChangeRequest – triggered when we change a value of fields.

We also need to create our own handler which we can name usr.ApplyDepartmentFilter. This one would find the currently active row of our detail to have access to its manipulations. After that, we check if account field is filled in and if yes, we create a filter for the Department field. To apply it, we need to use setValue method by targeting filterAttributeName that can be created using the formula: 
"{detailName}DS_{targetFieldName}_List_BusinessRule_Filter".
After that, it is important to use markAsPristine method to make sure that the attribute is applied silently, without forcing us to save the row.

As for crt.DataGridActivateRowBusinessRulesRequest, here we just need to filter it by request.dataGridViewElementName === "CareerList" to target only the detail needed and then call the execution of usr.ApplyDepartmentFilter request that was added earlier.

In crt.HandleViewModelAttributeChangeRequest handler we need to cover the situation when the Employer (Account) field is changed to update the filtration for Department field. First of all, we check if request.attributeName === "CareerList". After that we select the active row and get control over Account field. We check if it’s changed by using account?.dirty property and also if it has value with account?.value?.value, because we would want to filter Department field only in case the Employer is filled in. If those 2 conditions are met, we use markAsPristine method for the account field attribute. We use this one here because it will allow us to handle the subsequent changes of the Employer field. Without it, the field will remain dirty until we save the row. Eventually, we need to set value of the Department field to null using: row?.getAttributeControl(attributeName + "DS_Department").setValue(null, {silent: true});
After that, the usr.ApplyDepartmentFilter handler can be executed to apply the filtration of Department field by Employer.

Show all comments

Hello creatio community,

 

I am trying to apply a filter into cases mini page which is developed using freedom ui screens. Code as below:

{
	request: "crt.LoadDataRequest",
	handler: async (request, next) => {
 
		if(request.dataSourceName == "CaseDS_OPCaseType_4943d10_List_DS") {
			const caseType = await request.$context.CaseDS_OPCaseType_4943d10;
 
			var moduleTypesIds = await OPPermissionFunctionsSsp.getModuleTypes();
 
			const filter = new sdk.FilterGroup();
			if(moduleTypesIds.length > 0){
				filter.logicalOperation = sdk.LogicalOperatorType.Or;		
				for (let i = 0; i < moduleTypesIds.length; i++) {
					await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Id", moduleTypesIds[i].value);
				}
			}
			else{
				await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "OPCode", '');
			}
 
			const newFilter = Object.assign({}, filter);
			newFilter.items = filter.items;
 
			request.parameters.push({
				type: "filter",
				value: newFilter
			});
		}
		return await next?.handle(request);
	}
}

 

The filter newFilter shows the right filter condition. I also used sql profiler and it returned the correct values. The issue here is that the CaseDS_OPCaseType_4943d10_List_DS lookup its not showing any value and does not apply the developed filter.

 

This issue happens only in the mini page. I have used this approach in freedom ui form pages and it works fine. Is there something I'm missing?

 

Kind regards

Like 0

Like

2 comments

I assume this is a dropdown lookup and not a lookup that opens the Select dialog? 

I just double-checked and I do have similar code to filter a dropdown on a Freedom UI mini page/dialog and it is working. I don't see anything that looks incorrect in the code you posted - just wanted to confirm that it does work on mini pages (at least in my case it is)

Show all comments

Hey Guys, we are using Creatio marketing to send newsletters but when we send campaign or test emails, all the links are not working meanwhile in builder when we click on them they work fine. Is it due to tracking or something else? How to fix this?

Like 0

Like

1 comments

When you send the emails the links are changed to go through the tracking links. In the Domain setup in Creatio it has you create a CNAME DNS entry for "tracking" and links in the email are changed to go through "tracking.thedomain.com" - have you set up that CNAME DNS entry?

Ryan

Show all comments