Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Java Development
- :
- OnClick javaScript Button populates existing field...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
OnClick javaScript Button populates existing field values to the current Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2012 04:14 AM
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var strength;
var Weakness;
var Threats;
Var Opportuniites;
var recordTypeName = '{!Account.RecordType}';
var AccountName = '{!Account.Name}';
var aid='{!Account.Id}';
if(recordTypeName == 'Channel'){
var result = sforce.connection.query("Select Id Strengths__c, Opportunities__c, Threats__c, Weakness__c From RecordType r where r.SobjectType = 'Business_Plan__c' and r.DeveloperName = 'Distributor' limit 1");
BPRecordId = result.getArray("records")[0].Id;
}
else if(recordTypeName == 'Grower' || recordTypeName == 'Lawn and Garden'){
var result = sforce.connection.query("Select Id Strengths__c, Opportunities__c, Threats__c, Weakness__c From RecordType r where r.SobjectType = 'Business_Plan__c' and r.DeveloperName = 'Grower' limit 1");
BPRecordId = result.getArray("records")[0].Id;
}
else if(recordTypeName == 'Influencer'){
var result = sforce.connection.query("Select Id Strengths__c, Opportunities__c, Threats__c, Weakness__c From RecordType r where r.SobjectType = 'Business_Plan__c' and r.DeveloperName = 'Influencer' limit 1");
BPRecordId = result.getArray("records")[0].Id;
}
else{
alert('Invalid Operation. Please contact System Admin for details!!');
}
var BPDescription = sforce.connection.describeSObject("Business_Plan__
var BPUrlForNew = BPDescription.urlNew.split('com')[1];
var CFID = 'CF'+'00NO0000000X9xI'; // this ID is differnect with the production,please chage it after deployment
var AccountName = '{!Account.Name}';
var Strength = '{!Business_Plan__c.Strengths__c}';
var Opportunities = '{!Business_Plan__c.Opportunities__c}';
var Threats = '{!Business_Plan__c.Threats__c}';
var Weakness = '{!Business_Plan__c.Weakness__c}';
var aid='{!Account.Id}';
window.top.location=BPUrlForNew+'?'+CFID+'='+Accou
Hi,
I have created two custom Buttons current year and Next Yeat. If i click on Next Year the field values which has toget auto pouplate to next Year One.
Can any One help me..
Naresh
Re: OnClick javaScript Button populates existing field values to the current Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2012 05:24 AM
Hi,
We can auto-populate the field by passing values via URL,
Use the following code,
window.top.location=BPUrlForNew+'?'+CFID+'='+Accou
We are passing the currecnt year to the Year field.
Replace the field id in blue, with your field Id.
You can get your "Year" field Id, by going to the field in the setup, from the URL.
Checkout this link for more details Salesforce URL to Prepopulate
Please Mark this post as solved, if it helps you
Regards,
Bharathi
Salesforce For All
Re: OnClick javaScript Button populates existing field values to the current Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2012 05:55 AM
Not Only Year Field I Need some more fileds strength, Weakness, Opportunities and Threats
Naresh
Re: OnClick javaScript Button populates existing field values to the current Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2012 06:15 AM
Re: OnClick javaScript Button populates existing field values to the current Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-02-2012 11:25 PM
Hi Bharathi,
I am getting below error message after passing this url in cutom button: window.top.location=BPUrlForNew+'?'+CFID+'='+Accou
Naresh
Re: OnClick javaScript Button populates existing field values to the current Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-03-2012 03:15 AM
Hi,
Can you copy and paste the URL in the browser when this page is reached.
Thanks,
Bharathi
Re: OnClick javaScript Button populates existing field values to the current Fields
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-03-2012 03:50 AM
HiBharathi,
Please check here it is https://cs5.salesforce.com/servlet/servlet.Integra
Naresh


