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
DJ 367DJ 367 

TypeError: unable to get property of 'TemplateID__c' of undefined or null reference

Hello All,
I am getting above error, I have written a code in javascript button in Account, my query is not returning anything, I have a if condition like if it is null then do something else do something else. but it is not working properly and getting error. how to handle it. Thanks
 
var Acc = sforce.connection.qwery(select Id,name ,website, Industry from Account where website = 'www.test.com' );
var websiteVal = Acc.getArray("records").[0].website;

if(websiteVal.length >=1){
   // code
}

else{
  // code
}



 
Best Answer chosen by DJ 367
DJ 367DJ 367
Hi ,
Thanks for all you reply, I have resolved it thru
var Acc = sforce.connection.query("select Id,name ,website, Industry from Account where website = 'www.test.com' ");
var websiteVal = Acc.getArray("records").[0].website;

if(Acc.size >=1){
   // code
}

else{
  // code
}

 

All Answers

Pascal Le ClechPascal Le Clech
Before posting a solution to that :

You should avoid typos first : qwery instead of query and put your query as a string (with quotes).

it could be a bit better then...
DJ 367DJ 367
Hi ,
That is correct on my original code. 
v varaprasadv varaprasad
Hi Dj,

Check once below code : 
 
var Acc = sforce.connection.query("select Id,name ,website, Industry from Account where website = 'www.test.com' limit 1");
alert(Acc);


var websiteVal = Acc.getArray("records").[0].website;
alert('websiteVal'+websiteVal);


Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/


Salesforce latest interview questions  :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1



 
DJ 367DJ 367
Hi ,
Thanks for all you reply, I have resolved it thru
var Acc = sforce.connection.query("select Id,name ,website, Industry from Account where website = 'www.test.com' ");
var websiteVal = Acc.getArray("records").[0].website;

if(Acc.size >=1){
   // code
}

else{
  // code
}

 
This was selected as the best answer