+ Start a Discussion
advlgxpmadvlgxpm 

Create A URL To Default New Record Values....

How do you craft a URL to default field values on a new record that I want to create from a sidebar link?
 
For example, if I create a new child record from a parent object, the url I'm directed to is something like this:
na3.salesforce.com/a0O/e?CF00N50000001xQY6=Salesforce+Administration
 
Where CF00N50000001xQY6 seems to be some internal value for the parent record association and when the URL renders the parent record value is populated in the new edit record form.
 
So, how do I find out the id values for other fields I want to pass to this URL? For example, here is what I'm trying to do, but it does not work:
 
na3.salesforce.com/a0O/e?CF00N50000001xQY6=Salesforce+Administration&type__c=Question
 
Any ideas?
 
Also, how would I do this URL so that another page layout is displayed instead of the default page layout for a profile? How would I craft the URL to dictate which page layout is displayed and how do I find the ID for that page layout?
 
Thanks
RickyGRickyG
Not sure that I have all the answers for you, but some things that might help.

The ID used in a parent reference is the ID for the parent record.  This ID uniquely identifies the record, and is returned whenever you do a SOQL query for the record.

As far as variable page layouts, that is something normally accomplished with a record type.  If you can determine the record type for a record when you call the new page, you can pass that ID which I believe would shape the layout.  Of course, you could also use different Visualforce pages that would be called, if this would work better.

There still remains the issue of how you will determine which parent record and page layout you want to call. Perhaps you could have some type of formula field, which would be used as a merge field in the URL?

Hope this helps.
esaesa
The only way I've found out how to create the URL is to go to the form you want to pre-populate and view the source to look up the field IDs. I haven't found an easier way to look up these IDs. I looked in our WSDL and it's not defined in there either. This works great for text fields and checkboxes. I haven't figured out how to get pulldown menus to default.
esaesa

Pulldown menus appear to work by defining the values in the URL.  I thought it wasn't because there is a bug that resulted in it not working.  I submitted the bug as a case and SF has told me that it will be corrected in Summer '09.

 

The bug is that URLs with case sensitive parameters

(ie. http://na4.salesforce.com/xxxxxxxxx/e?abcdef=123&ABCDEF=123)

 

that are defined using PageReference (ie. to redirect user)

PageReference newPage = new PageReference(http://na4.salesforce.com/xxxxxxxxx/e?abcdef=123&ABCDEF=123);

return newPage.setRedirect(true);

 

are modified incorrectly (it must internally stores the URL with case insensitivity?)

 

System.Debug('URL: ' + newPage.getUrl()); 

outputs the following:

URL:  http://na4.salesforce.com/xxxxxxxxx/e?abcdef=123

 

advlgxadvlgx
Interesting.... thanks
MarcPMarcP

Unfortunately, they did not fix it. In the middle of a deployment and just encountered this bug. Back to javascript!

Saurabh DhobleSaurabh Dhoble

Agree with some of the suggestions above - use record types if you want to show different page layouts for different users. Regarding the URLs, you need to read about URL hacking - you can find a great series of posts at http://writeforce.blogspot.com/2012/12/prepopulating-fields-using-url-hacking.html

 

Khaled YoussefKhaled Youssef
https://help.mypurecloud.com/articles/format-salesforce-url-new-record-screen-pop-purecloud-salesforce/