function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Katie_TKatie_T 

Example code - create new record from custom link

I want to use a custom link that creates a new record (custom object) with fields populated.  Does anyone have a sample of code that does something similar?  I am able to update existing records using code from this board, but I don't know how to create a new one.

Thanks,

Katie

The_FoxThe_Fox
Hi

Take the first three charachers after yoursalesforceserver.com and add /e? the returl=2%FID of teh record you came from and then you can pass your parameter with IDofthefield1=Value&Idofthefield2=Value and of cours all of this url encoded

Example here
https://emea.salesforce.com/a00/e?retURL=%2F00320000001HCAC&CF00N20000000kCk1=Jason+Bourne

aoo : the first three cahracters of the custom objects
CF00N20000000kCk1= ID of the field1 in order to have the id of the field when you are on the custom object page in the setup when you mouseover on the field you should have the id at the bottom of the screen or make a view source when your editing one custome object through the UI
Jason+Bourne = urlencode(Jason Bourne) ie Jason Bourne = my value
Regards
Again AgainAgain Again

I find that when I try to add values to lookup fields, the values aren't transfered. I've tried putting the ID of the lookup product, or the text description, with different variations of using single quote, double quote, urlencode - no luck. If I add these same values on a text field I can see that the correct value comes through. What must I do if I want to prepopulate a lookup box with a given value when I open the new record window?

Thanks!

Rozanne

Again AgainAgain Again

Bother ... I actually did this once, long ago, some late night and there's an SF help topic for it. Never resolved the contact though, but it should help with the campaign and the product values I'm trying to insert.

https://na1.salesforce.com/help/publicHelpSolution.jsp?ps=1&orgId=00D000000000062&retURL=/help/doc/public_solution_search.jsp?search=custom+link+lookup&orgId=00D000000000062&langSid=1&id=50130000000JoHL