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
JesipJesip 

AJAX Create Error

I am getting an error creating the new Opportunity with the AJAX toolkit.

I have read through this message board and found that the object parameter must be in the form of an array, but I still get the following messge when I interogate the SoapFault object (toString):

"faultstring: org.xml.sax.SAXParseException:  The reference to entity "D" must end with the ";" dilimeter.  faultcode: soapenv:Server"

Can someone help me how I can troubleshoot this??

Here is my create script:

var Opp = new DynaBean("Opportunity")

//A series of set statements

var saveResult = sforceClient.Create([Opp]);

if (saveResult.getClassName() == "SoapFault") {

     alert(saveResult.toString);

} else {

     alert("It worked!");

}

Mike ShawalukMike Shawaluk

Jesip,

Did you try this syntax instead for your create:

var saveResult = sforceClient.Create(Opp)[0];

  - Mike

JesipJesip

Thanks for the quick response.

Yes, I did.  When I use that syntax, the SaveResult is returned as "undefined".  Any other thoughts?

Mike ShawalukMike Shawaluk

I was just reading another thread; the bracketed syntax (to convert Opp to an array) probably is not the problem.

However, the returned SaveResult is an array, so you may need to add [0] after it when you test for a result.

  - Mike

JesipJesip

I have some additional testing and have found that I can create other objects just fine.  It seems to be something about creating an opportunity that is causing the problem.  Attached is the full function that I'm using in case this were to generate some more thoughts.

var dna= new DynaBean("Opportunity");

dna.set("AccountID", "{!Account_ID}");
dna.set("Amount", "100");
dna.set("CloseDate", new Date());
dna.set("OwnerId", "{!Account_Owner_ID}");
dna.set("Description", "Test");
dna.set("Name", "BK-AJAX");
dna.set("RecordTypeId", "<A valid Record type ID>");
dna.set("StageName", "1.1 Account Manager Draft");
dna.set("Type", "R&D Project");


alert("before create");
var sr = sforceClient.Create([dna]);
alert("after create");

if (sr.getClassName()=="SoapFault") {
alert("soap fault");
alert(sr.toString());

SuperfellSuperfell
based on the error, i'd say the ajax toolkit is forgetting to xml encoding the string values, so the R&D string ends up as R&D on the wire when it should be R&amp;D

Message Edited by SimonF on 09-01-2005 01:49 PM

JesipJesip

WOW!  That was a great find.  It appears that you are absolutely correct.  I took out the "Type" field and it worked great.

Thanks a lot!