質問

I have created a visualforce that allows a user to dynamically add rows to insert many child records related to a master record.

Each new rows contains 3 lookup fields (Account, Contact and User). The record is a custom object called "Participant". A participant can either be an "Account", "Contact" or "User".

I'm trying to create some validation that would prevent the user from choosing more than one lookup selection. For example, if the user select an account, then I don't want them to select a contact or user. If they select a contact, I don't want them to be able to select an account or user. If they select user, then I don't want them to be able to select an account or contact. I thought about a validation rule, but preferably, I'd like to validate the form before the record(s) are saved. Also, there is a use case where the user selects a contact and when they save, I have a trigger that fires and looks up the related account and populates the account look-up field automatically for them for that record (row).

I've been struggling with how to provide a good user experience to validate this use case.

What would be the best approach to provide the validation?

Any design approaches would be appreciated. Thanks.

役に立ちましたか?

解決

I think that the simplest way is a hiding 2 other fields for user after the choosing value on a first field, e.g. User choose value into Account field, after that you run js code into your page and hide the fields Contact & User. I think it's enough.

The another way is validate it on the fly, the trigger is same as on first case, but for now you look into 2 another fields and if one of their has a filled value you show error message on page and reset the entered value to null.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top