7

I've created the following custom button on my custom object to automatically lookup the contact and account names when the custom 'new' button is selected from a contact's related list:

/a0H/e?CF00ND0000005Mxeb={!Contact.Name}&CF00ND0000005Mxeb_Ikid=CF00ND0000005Mxeb_Ikid={!Contact.Id}&CF00ND0000005MxeW={!Account.Name}&retURL={!Contact.Id}

Is there a way to somehow make the contact and account name lookup fields automatically select the contact and account name that the button is run off?

I've been able to get it to work, however in cases where I have multiple contacts or accounts with the same name it returns the 'Error: multiple items found. Select from drop-down or click icon to refine search' next to the relevant fields.

I'd like to somehow stop this from appearing in cases like this.

Any ideas without having to go down the full coding route?

Thanks!!!

Cheers.

  • Adding &CF00ND0000005MxeW_lkid={!Account.Id} should do the trick. You seem to have done that for contact, passing not only the name but the id as well (although there looks to be a mistake by adding CF00ND0000005Mxeb_Ikid= twice). – Robin De Bondt Jul 1 '15 at 13:58
  • Thanks Robin. Made the changes as suggested (added Account.Id and removed the duplicate reference) but still seem to be getting the same issue. Cheers. – user21827 Jul 1 '15 at 14:18
3

There is a nice tutorial that explains how to hack the URL here.

Step 3 – Pre-populating lookup values

You may have noticed that if you are following a similar example to mine, your lookup value will not be pre-populating like the default “New” button does. This is because behind that new button, Salesforce is bringing over the value from the previous object, as our button is fresh, we will need to do this ourselves (and with any other lookup values we have). They do differ slightly from basic text values which I will explain below.

To populate a Lookup value we need the field ID as before but this time we need to add CF to the front of the ID so it looks something like this – CF00Ni000000EpsgO. This is required when populating a custom lookup field. The first part to populate a lookup value is to grab the name of the record we are populating. So using the method before but with the added CF you can expect your button URL to look like this

`/a0U/e?CF00Ni000000EpsgO={!Opportunity.Name}`

The next step is to grab the ID of the record we wish to populate. This time though, we are going to add “_lkid” to the end of our field ID (plus the CF we added on earlier). This lkid parameter is telling Salesforce this is a lookup field. So it looks a bit like this.

/a0U/e?CF00Ni000000EpsgO={!Opportunity.Name}&CF00Ni000000EpsgO_lkid={!Opportunity.Id}

Again nothing too fancy we’ve just added some extra parts to the ID and referenced this field twice, grabbing the ID and the Name of the record. Please note the “&” used to separate the URL when referencing different fields. You can also see this being used below where I have the full URL used for this demonstration.

/a0U/e?CF00Ni000000EpsgO={!Opportunity.Name}&CF00Ni000000EpsgO_lkid={!Opportunity.Id}&00Ni000000EpsgY={!Opportunity.Description}

Your URL with notes

/a0H/e?CF00ND0000005Mxeb={!Contact.Name}&CF00ND0000005Mxeb_Ikid=**(DUPLICATE PARAMATER AND MISSING MERGEFIELD)**CF00ND0000005Mxeb_I(SHOULD BE l not I)kid={!Contact.Id}&CF00ND0000005MxeW={!Account.Name}(MISSING ID FIELD)&retURL={!Contact.Id}  

Updated URL

/a0H/e?CF00ND0000005Mxeb={!Contact.Name}&CF00ND0000005Mxeb_lkid={!Contact.Id}&CF00ND0000005MxeW={!Account.Name}&CF00ND0000005MxeW_lkid={!Account.Id}&retURL={!Contact.Id}
| improve this answer | |
  • Thanks Jenny. This actually helped me out in identify that the issue was the lkid reference. I'd noted it down as Ikid (an i insteand of an l). All is working now. Cheers. – user21827 Jul 1 '15 at 14:36

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.