How to Set validation in multiselctlookup object?

Hi Team,



I would like to set an alert based on validations in a Multi-select-lookup detail object.



I have replaced the Account object and added a new field UsrParentComapny which points to the Account object itself.



Now, account is added as a multiselect lookup detail object in a section.  I would like to setup validation based on the selected values in the multiselect lookup.



Validation Required:

if the user selects a company (Account) that is a parent company (UsrParentCompany of Account) then he can’t select the comapnies (Account) that has this UsrParentCompany, 

If he tries to select such company (Account) there will be a pop-up: “you can’t choose more than one daughter company"

 

I have provided a sample Multiselect Lookup of Products. similarly i have Account object as multiselect detail object in another section 



 

 

Kindly guide to achieve the validation.





Regards,

Bhoobalan P.

Like 0

Like

1 comments

Hi Bhoobalan,

 

In the addCallBack function from this instruction (Academy instruction on adding the multiselect lookup) the list of selected rows is formed in this part of code of the method:

 

this.selectedRows = args.selectedRows.getItems();

 

You need to debug this method and exclude those accounts from items that don't feat the conditions (it has a parent account selected as an account in your custom section). The check can be performed via a custom esq that refers to accounts and checks if the account is a daughter company or not (you will need to create such a esq query). And in case some of the items in selectedRows is not suitable it will be automatically removed from the selectedRows and the further logic won't be triggered for records that shouldn't be processed. So you will need to create a custom esq that will perform this check.

 

Best regards,

Oscar

Show all comments