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
sgkmillssgkmills 

Setting Fields within an edit Page *** Solution ***

I have been reading these forums and keep seeig this request for a way to set fields on a page when using S-Controls.

I took the liberty to show my solution, which actually sets fields defined as read-only and editable fields on a specific page layout.

Below, I create a variable called "options".  This variable holds all the fieldnames and values I want to set within the field.  For example, opp7 is the fieldname for amount and the fields starting with "00N" are custom fields.  BTW, you can find the fieldname of the custom field by going to the Setup | Customize area in Salesforce and then going into the Fields area for the object that you are setting values in.  In my case it was Opportunity.

The next step, I created a "newURL" variable, which uses the URLFOR function to build the URL that I will redirect the browser to.  As you see, I append the "options" variable to the end of the created URL.

Then I just use the window.parent.location.replace function to redirect the browser to the newly created URL.

As I stated above, some of these fields are not editable on the layout, but still get changed and then they are viewed as read-only. 

Code:
 var options = "&opp7=0&opp11=Development&00N5000000xxxxx=0&00N3000000xxxxx=0&00N5000000xxxxx=" +
"&RecordType=012300000000xxxxxx&opp5;

var newURL = "{!URLFOR( $Action.Opportunity.Edit, Opportunity.Id,
      [retURL=$Request.retURL] ,true)}"+options;

window.parent.location.replace(newURL);