Freedom UI Filtration

Hi,

 

I haven't found an example of lookup filtration for Freedom UI in Academy.

 

Anyone has some sample code ?

 

Thanks,

Like 0

Like

3 comments
Best reply

Hi,

 

Let's imagine you've displayed the lookup column on the edit page that references the "Account" object. In this case you will get this code in the "attributes" property of the "viewModelConfig":

"LookupAttribute_6tp5bvd": {
					"modelConfig": {
						"path": "PDS.UsrAccountColTest"
					}
				}

where UsrAccountColTest is the code of the added lookup column. To add filtration to this column you need to create additional attribute like the one below:

"LookupAttribute_6tp5bvd_List_BusinessRule_Filter": {
					"value": {
						filterType: 6,
						isEnabled: true,
						items: {
							"CustomFilters": {
								filterType: 6,
								isEnabled: true,
								items: {
									"cb855fc4-4526-475a-beea-8e44a7f5a436": {
										comparisonType: 11,
										filterType: 1,
										isEnabled: true,
										leftExpression: {expressionType: 0, columnPath: "Name"},
										rightExpression: {expressionType: 2, parameter: {dataValueType: 1, value: "acc"}},
										trimDateTimeParameterToDate: false
									}
								}
							}
						}
					}

so you need to add the _List_BusinessRule_Filter part to the attribute name and specify the filter. This particular filter I sent above will return only account where the "Name" column of the account contains the "acc" part.

 

If you doubt how to correctly specify filtration you can add the "List" component to the designer (referencing the same object as your lookup column), add filtration there:

save the page and check the code added to the schema (it will contain the "PredefinedFilter" part (in my case the name for the filtration was "DataGrid_7ql0gtq_PredefinedFilter")), it will contain the filtration needed and then you can create an attribute for the lookup as I described above and use the same filtration there.

Hi,

 

Let's imagine you've displayed the lookup column on the edit page that references the "Account" object. In this case you will get this code in the "attributes" property of the "viewModelConfig":

"LookupAttribute_6tp5bvd": {
					"modelConfig": {
						"path": "PDS.UsrAccountColTest"
					}
				}

where UsrAccountColTest is the code of the added lookup column. To add filtration to this column you need to create additional attribute like the one below:

"LookupAttribute_6tp5bvd_List_BusinessRule_Filter": {
					"value": {
						filterType: 6,
						isEnabled: true,
						items: {
							"CustomFilters": {
								filterType: 6,
								isEnabled: true,
								items: {
									"cb855fc4-4526-475a-beea-8e44a7f5a436": {
										comparisonType: 11,
										filterType: 1,
										isEnabled: true,
										leftExpression: {expressionType: 0, columnPath: "Name"},
										rightExpression: {expressionType: 2, parameter: {dataValueType: 1, value: "acc"}},
										trimDateTimeParameterToDate: false
									}
								}
							}
						}
					}

so you need to add the _List_BusinessRule_Filter part to the attribute name and specify the filter. This particular filter I sent above will return only account where the "Name" column of the account contains the "acc" part.

 

If you doubt how to correctly specify filtration you can add the "List" component to the designer (referencing the same object as your lookup column), add filtration there:

save the page and check the code added to the schema (it will contain the "PredefinedFilter" part (in my case the name for the filtration was "DataGrid_7ql0gtq_PredefinedFilter")), it will contain the filtration needed and then you can create an attribute for the lookup as I described above and use the same filtration there.

Oleg Drobina,

Thanks for this, works like a charm.

@Oleg Drobina,

 

How might you change this so that the filter is the value of a lookup column on the page? I.E Filtering "Primary Contact" by the "Account" 

 

What would the code for the right expression be?

Thanks in advance

Show all comments