Hi Community,
I want to make certain fields required based on condition that detail has a record in Freedom UI.
Thanks
Rakshith
Like
1 comments
17:47 Jul 05, 2023
Hello,
Here is an example of how to change the Required
viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{ "attributes": { "UsrCustomText": { "validators": { "required": { "type": "crt.Required" } } }, .... { request: "crt.HandleViewModelAttributeChangeRequest", handler: async (request, next) => { if (request.attributeName === 'LookupAttribute_nj0qj8x') { const accountAddressModel = await sdk.Model.create("AccountAddress"); const filters = new sdk.FilterGroup(); await filters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Account", request.$context.Id.__zone_symbol__value); const address = await accountAddressModel.load({ attributes: ["Id"], parameters: [{ type: sdk.ModelParameterType.Filter, value: filters }] }); if (address.length > 0) { request.$context.enableAttributeValidator('UsrCustomText', 'required'); } else { request.$context.disableAttributeValidator('UsrCustomText', 'required'); } } return next?.handle(request); } }
However, this code is currently not working, the fix to it will be added in a version 8.0.10
Show all comments