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
- :
- Re: Onclick java Script donot Prepopulate null Val...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Onclick java Script donot Prepopulat e null Values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-11-2012 10:52 PM
Hi,
Can any one help me with the below code, even null values also prepopulating, I dont want populate null values
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var recordTypeName = '{!Account.RecordType}';
var BPRecordId = '';
var theDate = new Date();
var currentYear = theDate.getFullYear();
var NextYear =Number(theDate.getFullYear())+1;
if ( '{!User.Profile}' == 'System Administrator' ){
if(recordTypeName == 'Channel'){
var result = sforce.connection.query("Select r.Id 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 r.Id 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 r.Id 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 result =sforce.connection.query("Select Id, Name, Strengths__c, Threats__c, Weakness__c,Opportunities__c From Business_Plan__c where Name = \'" + currentYear + "\' and Account__c = \'{!Account.Id}\' limit 1" );
records = result.getArray("records");
if(records.length > 0 ){
Strength = records[0].Strengths__c;
Opportunity = records[0].Opportunities__c;
Threat = records[0].Threats__c;
Weakness = records[0].Weakness__c;
}
var BPDescription = sforce.connection.describeSObject("Business_Plan__
var BPUrlForNew = BPDescription.urlNew.split('com')[1];
var CFID = 'CF'+'00NN0000000KvoM'; // this ID is differnect with the production,please chage it after deployment
var AccountName = '{!Account.Name}';
var aid='{!Account.Id}';
result = sforce.connection.query("Select Id, Name From Business_Plan__c where Name = \'" + NextYear + "\' and Account__c = \'{!Account.Id}\' limit 1" );
records = result.getArray("records");
if(records.length > 0){
var prevId = records[0].Id;
window.top.location=prevId;
}
else{
window.top.location=BPUrlForNew+'?'+CFID+'='+Accou
}
Naresh
Re: Onclick java Script donot Prepopulat e null Values
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-24-2012 03:05 PM
In my experience, if a value is null, Salesforce to JS will copy the string "null" out to the UI. I usually have to write code to ensure that the "null" is not getting written to the screen. Like an if JS statement that checks for "null" strings and write out an empty string instead.

