How to filtering lookup with static filter that i have 1 object that is relation to contact and account, and i want to filter if the account is has been added to the object then the account not display in the lookup
Like
The necessary filtering can be implemented in section page source code. In order to do that you will have to write the handler for crt.LoadDataRequest request that appears when the lookup is opened.
Here is the example of the implementation:
/**SCHEMA_MODEL_CONFIG_DIFF*/, handlers: /**SCHEMA_HANDLERS*/[ { request: "crt.LoadDataRequest", handler: async (request, next) => { if(request.dataSourceName !== "PDS_UsrDoctor_sm2qg7w_List_DS") { return await next?.handle(request); } console.log('Lookup Load Data...'); const cardModel = await sdk.Model.create("UsrHospitalVisitCardV3"); // now load the records and provide the filters const cards = await cardModel.load({ attributes: ["UsrDoctor"] }); console.log(cards); if (cards) { const filter = new sdk.FilterGroup(); filter.logicalOperation = sdk.LogicalOperatorType.Or; cards.forEach(async (card) => { if(card.UsrDoctor && card.UsrDoctor.value){ await filter.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Id", card.UsrDoctor.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: "filter", value: newFilter }); } return await next?.handle(request); } } ]/**SCHEMA_HANDLERS*/
In the example above "PDS_UsrDoctor_sm2qg7w_List_DS" is the name of the lookup that has to be filtered and "UsrHospitalVisitCardV3" is the object that contains that lookup and which records we should check.
You can also find some additional details and useful information in the articles:
https://customerfx.com/article/dynamically-filtering-a-lookup-on-a-creatio-freedom-ui-page/
https://customerfx.com/article/querying-data-using-filter-conditions-via-the-model-class-equivalent-to-enityschemaquery-in-a-creatio-freedom-ui-page/