-1

Onclick 'New opportunity' button under the account. We see 'Account Name' field prepopulate as in images below.enter image description here

My requirement is while clicking lookup button for account selection. It should show only the existing account or user cannot change the current populating account. If a user selects another account it should throw error. How can we achieve this?

  • does your users profile FLS allow him to change the value? have you tried setting it to read only? – glls Nov 26 '18 at 18:29
  • No, we can not make it read-only fields, cannot create a new pagelayout. – RAHUL SRIVASTAVA Nov 26 '18 at 18:32
  • why cant you set it up a s read only for those profiles/users? and why would you want to create a new pagelayout? – glls Nov 26 '18 at 18:33
  • Read-only is not recommended. Can we have some other approach? – RAHUL SRIVASTAVA Nov 26 '18 at 18:41
  • 1
    sounds to me like this is mostly a bad design/requirement and a custom UI would be the only way to cope with your requirement – glls Nov 26 '18 at 18:50
2

The only way to do this is to make the field read-only on the page layout. This will allow the account they clicked the button on to be selected, but will not allow it to be changed. There is no other way in the standard user interface to enforce the behavior you're looking for. If the field is not read-only, they can change the value. A validation rule/trigger/etc won't help, because you cannot detect what the original account was, or if they changed the value. The only other alternative is to write your own Visualforce page for the New Opportunity page.

  • Can we apply lookup filter on that field? – RAHUL SRIVASTAVA Nov 26 '18 at 18:45
  • 1
    @RAHULSRIVASTAVA It wouldn't do any good; you can only filter based on data on the record or the related record. There'd be no way to specify a filter of "only the record the user was looking at." – sfdcfox Nov 26 '18 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.