Error configuring dynamic filter on lookup

I have a problem filtering a lookup filed using Freedom UI.

The issue here:

The first lookup filed linked to the Contact entity

The second lookup filed's entity Account, contains a field "SMPrimaryAccountOwner" and it should be equal to the first filed value. 



Here is the filter:

 

{
				request: "crt.LoadDataRequest",
				handler: async (request, next) => {
					// filter the contact lookup for the account
					debugger;
					if(request.dataSourceName !== "LookupAttribute_emk4fel_List_DS") {
						return await next?.handle(request);
					}
 
 
					const account = await request.$context.LookupAttribute_r6avpkd;
					if (account) {
						const filter = new sdk.FilterGroup();
						await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SMPrimaryAccountOwner.Id", account.value);
 
						// note, these lines are only needed due to an issue with filters in Creatio-DevKit SDK
						// expected to be fixed in Creatio 8.1
						//const newFilter = Object.assign({}, filter);
						//newFilter.items = filter.items;
 
						request.parameters.push({
							type: sdk.ModelParameterType.Filter,
							value: filter
						});
					}
 
					return await next?.handle(request);
 
				}
			}



And here is the error on the console:



 

Maybe anyone here had the same issue.

Like 0

Like

2 comments
Best reply

Try changing to just the field "SMPrimaryAccountOwner" and not the ".Id" part at the end.

await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SMPrimaryAccountOwner", account.value);

Also, even if you're on 8.1 the commented lines are necessary - the issue that works around was *not* fixed in 8.1.

Ryan

Try changing to just the field "SMPrimaryAccountOwner" and not the ".Id" part at the end.

await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SMPrimaryAccountOwner", account.value);

Also, even if you're on 8.1 the commented lines are necessary - the issue that works around was *not* fixed in 8.1.

Ryan

Try adding the filter for "SMPrimaryAccountOwner" and not "SMPrimaryAccountOwner.Id", as in: 

await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "SMPrimaryAccountOwner", account.value);

Also, the workaround that is commented out is still needed in 8.1. It was not fixed in 8.1.

Ryan

Show all comments