[SalesForce] Salesforce URL Hacking – Ability to remove the ‘multiple items found’ error

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.

Best Answer

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}
Related Topic