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
StacieStacie 

S-control to populate new objects

I am trying to use a custom s-control to take the data from an existing lead, and create a new ‘candidate’ (a custom object) - for those people that fill out a form online, but are looking for a job, not our services.  I am able to have the custom s-control open up the ‘new candidate’ window, but I can’t get any of the data to populate.  What am I doing wrong?  How do I make it so that sfdc knows to pull the data from the lead record?

I currently have:

{!URLFOR($Action.Candidate__c.New)},%{!Candidate__c.Name}={!Lead.FirstName}

Any help would be greatly appreciated!

bakumbakum
Hi,

You're code: {!URLFOR($Action.Candidate__c.New)},%{!Candidate__c.Name}={!Lead.FirstName}

Proper Syntax: {!URLFOR(target, id, [parm1="A", parm2="B", etc], [no override])}

id is going to be null when you are making a new record

When specifying params you have to find the HTML field name of the field you want to inert the value into.  Something like this: <input name="CF00N70000001dcKo_lkid"  (but you don't need the _lkid part)

So it ends up looking like this:
{!URLFOR($Action.Candidate__c.New,null,[EV00N70000001dcKo={!Lead.FirstName},EV00N40000001fSvB={!Lead.LastName}])}

Obvioulsy those field names are not the right field names for you, I just made them up.  You'll have to find your own field names.
StacieStacie
Thank you for your help!  I followed your instructions, but first it had a problem with the '[', so I tried replacing that with a '('..but then it says I am missing a ')', and highlights the field id.  So, right now I have:

{!URLFOR($Action.Candidate__c.New,null,(2F01I60000000EAI4={!Lead.FirstName}))}

I looked at the URL for the candidate name, and the string includes:
s/d?id=Name&type=01I60000000EAI4&retURL=%2F01I60000000EAI4%3Fsetupid

I tried both sets of Id's, but I get the same error in both situations...

Now what am I doing wrong?
bakumbakum
First of all don't swap out [] for ().  The syntax requires [], so if you're getting an error you're doing something else wrong.
{!URLFOR($Action.Candidate__c.New,null,[2F01I60000000EAI4={!Lead.FirstName}])}

Second, the field ID you need is not in the URL string. It's in the HTML.  OPen up the Candidate object and click New, so you get a new Candidate form.  Then look at the source code.  Find the <input> tag for the Name field and get the ID from there.


Stacie wrote:
Thank you for your help!  I followed your instructions, but first it had a problem with the '[', so I tried replacing that with a '('..but then it says I am missing a ')', and highlights the field id.  So, right now I have:

{!URLFOR($Action.Candidate__c.New,null,(2F01I60000000EAI4={!Lead.FirstName}))}

I looked at the URL for the candidate name, and the string includes:
s/d?id=Name&type=01I60000000EAI4&retURL=%2F01I60000000EAI4%3Fsetupid

I tried both sets of Id's, but I get the same error in both situations...

Now what am I doing wrong?


jawtechjawtech
I had the same syntax error issue. It seems that the syntax checker trips over custom names like 00N60000001LTqa inside the parameter input list . Instead of the following:
 
Code:
{!URLFOR($Action.MUSW__Receipt__c.New,null,[00N60000001LTqa={!MUSW__Fund__c.MUSW__Original_Full_Amount__c }])}

 
Do this:
Code:
{!URLFOR($Action.MUSW__Receipt__c.New,null)} + "&00N60000001LTqa=" + {!MUSW__Fund__c.MUSW__Original_Full_Amount__c }