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
Dman100Dman100 

auto-populate s-control

I found the following article that provides an s-control example that auto-populates field values for a new contact with values from the account record from which the contact is created.
 
Here is the URL to the article and example: http://wiki.apexdevnet.com/index.php/Auto_Populate_Contact.html
 
I have a couple of questions about this s-control. 
 
I believe fields must be prefixed based on a combination of the object name addreviation (e.g. "con"), plus the ordinal position of the field on the Page Layout (e.g. Contact). For example, Account is the 4th field on the Contact page layout, when counting from top to bottom, left to right, within each page layout Section. Thus the field name on the page layout is "con4".  Is this correct for the prefixing of the field names?
 

If so, for custom objects, what would be the object prefix?

When I tried to add an additional field to auto-populate, over and beyond the address fields, it did NOT work.  Why?  I followed the exact structure.

There are also other major drawbacks to this S-Control, even if it does work:

  1. You have to be very careful about adding or moving fields in the page layouts after you implement the S-Control, because the S-Control assumes static ordinal positions of the fields it references.
  2. This S-Control assumes the user is adding a new Contact from the Account page, so it alreadys knows the Account ID.  What if you add the Contact from the Contact page instead?

Any help is appreciated.

Thank you.

jrotensteinjrotenstein
Use "View Source" on the Contact page and look for the field in the HTML markup to find the field name.
RexRex
yes that's right use the view source option.

FYI not all the fields have number in the end. All custom fields have field ids.

Note: SF doesn't support passing info through URL. Don't ask why? He he
TCAdminTCAdmin
Hello Rex,

What are you referring to when you say "SF doesn't support passing info through URL"? I've been using custom links and URLs to pass information but I may be using different terminology. Please explain :)
TCAdminTCAdmin
Another option is to utilize FireFox and the Web Developer Toolbar. You can then use 'Forms | Populate Form Fields' or 'Forms | Display Form Details'. You can also use 'Forms | View Form Information' which will display it in a spreadsheet format.
RexRex
Well I say that because... Let's say you want to populate fields in edit page account. Its always better to use URL FOR but you can't populate fields using URL for. Its not recommended to hard code edit URLs or any URL. We should be using URL for and you can't populate using URL for. When asked visual force is the correct way to accomplish this. Hope this answers.
Dman100Dman100

I was able to find the field names by viewing the page source, which works for standard fields, but the id for one of the custom fields I have showed 00N40000001PBVN as the id/name of the custom field in the page source.  When I tried to add this id into the S-Control:

00N40000001PBVN = Account.SLASerialNumber__c

It did not work, the field id is not recognizable?

Are custom fields not avaible to auto-populate using the example s-control shown at the top of my post?

Thanks.

RexRex
This what i did to pass it through the URL.
 
 
hope this is clear.
Dman100Dman100

Hi Rex,

Thanks for your response.  I'm not clear on how you are passing this in the URL??

Based on the s-control, can you explain how to include the custom field id so it can read the input field?

RexRex
Thats what i explained in my previous post. you cannot use URL FOR for passing variables you have to hard code the URL. I hard coded the URL. didnt use URL for. Alright.
TCAdminTCAdmin
This is probably what you want to do instead of using the s-control and URLFOR. This will pass the information through the use of a custom link.