0

On Contact I have one custom button where we want to give create opportunity functionality. It is working fine for most of the values but not able to populate the look up field. I tried below ways.

/lightning/o/opportunity/new?useRecordTypeCheck=1&nooverride=true&defaultFieldValues=Contact__c={!Contact.Id},
Name={!Contact.name}

Here Contact__c is the the lookup field of which label name Primary Contact ( API name Contact__c)

enter image description here

I tried below steps also but not working..

1) Right click on lookup field (not on lookup icon) and inspect element.
2) Copy the id of field. Now you have field id.
3) Put field id = '' in URL,  try without space.
5) Now you can see that the value will be visible in lookup field.
7
  • Why not use an action instead of url hacking?
    – Guest
    Jun 5, 2023 at 22:42
  • What happens if you change it Name instead of name
    – Guest
    Jun 5, 2023 at 22:48
  • Buisness want to use URL hacking only as they already have lots of URL hacking working already. this is first time we are trying for lookup fields. Jun 5, 2023 at 22:48
  • @Guest Name already working but lookup is not working. Contact__c={!Contact.Id} Jun 5, 2023 at 22:49
  • Just to confirm, is the contact field you're trying to populate a custom lookup rather than a renaming of the standard Contact field on Opportunity? Jun 5, 2023 at 23:01

1 Answer 1

-1

This is working for me I had the custom field name as Opportunity_Contact__c instead of Contact__c

/lightning/o/opportunity/new?useRecordTypeCheck=1&nooverride=true&defaultFieldValues=Opportunity_Contact__c={!Contact.Id},
Name={!Contact.Name}

enter image description here

2
  • Welcome to SFSE! Please take the tour and read How to Answer. As is, this isn't a very useful answer because it amounts to "It works in my org". There's nothing here that the OP (or other people visiting this question) can do to know if this will or won't be an issue for them, nor anything about why this issue occurs and how to fix it.
    – Derek F
    Sep 27, 2023 at 18:10
  • If you have performed some research into this issue (to identify what the issue is and when it happens) and have a solution for the issue, then please edit your answer to add that information. Otherwise, the appropriate answer here is "Use an action instead of URL hacking" and "Don't let your non-technical stakeholders dictate how to solve a problem". Stakeholders describe what they want to have, not how to achieve it.
    – Derek F
    Sep 27, 2023 at 18:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .