+ Start a Discussion
KNKKNK 

MalFormed Query Exception message only aggregate expression use field aliasing row -1 column -1

Hi ,

 

I'm trying to create a custom OnClick JavaScript button that will update multiple records sterngth , weakness , opps .

 

can any one help me here

 

 {!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var recordTypeName = '{!Account.RecordType}';
var idArr = {!GetRecordIds($ObjectType.Business_Plan__c)}
var BPRecordId = '';
var queryPart = "'" + idArr.join("','") + "'"

if(recordTypeName == 'Channel'){
var result = sforce.connection.query("Select Id Strengths__c, Opportunities__c, Threats__c, Weakness__c From Business_Plan__C  where Id IN ("+queryPart+")") ;
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 Business_Plan__C  where Id IN ("+queryPart+")") ;
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   Business_Plan__C  where Id IN ("+queryPart+")") ;
BPRecordId = result.getArray("records")[0].Id;
}
else{
alert('Invalid Operation. Please contact System Admin for details!!');
}

var BPDescription = sforce.connection.describeSObject("Business_Plan__c");
var BPUrlForNew = BPDescription.urlNew.split('com')[1];
var Strenght = '{!Business_Plan__c.Strengths__c}';
var CFID = 'CF'+'00NO0000000X9xI'; // this ID is differnect with the production,please chage it after deployment
var AccountName = '{!Account.Name}';
var aid='{!Account.Id}';
var Year = '{!Business_Plan__c.Name}';
 window.top.location=BPUrlForNew+'?'+CFID+'='+AccountName+'&'+CFID+'_lkid='+aid+'&RecordType='+BPRecordId+'&'+CFID+'='+Year;

Ritesh AswaneyRitesh Aswaney

You're missing a comma :) after Id -- this error usually occurs when the comma is missed out !

 

var result = sforce.connection.query("Select Id, Strengths__c, Opportunities__c, Threats__c, Weakness__c From Business_Plan__C  where Id IN ("+queryPart+")") ;

KNKKNK

If i use below code, I am getting Expected ; error. can any one help me

 

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var recordTypeName = '{!Account.RecordType}';
var BPRecordId = '';

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 BPDescription = sforce.connection.describeSObject("Business_Plan__c");
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 strengths = '{!Business_Plan__c.Strengths__c}';
var aid='{!Account.Id}';
window.top.location=BPUrlForNew+'?'+CFID+'='+AccountName+'&'+CFID+'_lkid='+aid+'&RecordType='+BPRecordId+'&'+'a17O0000000A4SE'=+strenghts;