• forcelearner
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I'm extremely new in attempting to use AJAX and Javascript and am having quite a bit of trouble creating a button that will allow for the conversion of a business account to a person account. I found some code on the developer board got an error after copying and pasting the original script. Since then, I have continued to modify the code but am still getting error messages that vary depending on the browser I'm using.

 

If I'm using Firefox and click the new button, I get the following error message:

 

"A problem with the OnClick JavaScript for this button or link was encountered:

Account is not defined"

 

However, if I'm using Internet Explorer, I get a different error message:

 

"A problem with the OnClick JavaScript for this button or link was encountered:

 

Syntax error"

 

I'm not sure why I'm getting a different error message from the different browsers and I cannot figure out where I went wrong in the code. If someone could please help me out I'd really appreciate it as I've been working on this for the past 3 days and have gotten nowhere. The script I am trying to use can be found below:

 

<script src="/soap/ajax/22.0/connection.js" type="text/javascript"></script>
var ready = true;
if(ready && confirm("Are you sure you want to convert this Account and Contact to a single Person Account? This is NOT reversible.")) {
var account = new sforce.SObject('Account');
Account.Id = "{!Account.Id}";
Account.RecordTypeId = "012A00000004E7C";
result = sforce.connection.update([Account]);
alert(result);
location.reload(true);
}