You need to sign in to do that
Don't have an account?
vander
create case with ajax
hello -
i'm trying to create a case w/ the ajax toolkit and having some issues. Here is the javascript function:
//create case from asset using contact id and record type info
function createCase() {
//check that all required variables are set
if (assetId != "" && conId != "" && proTypeId != "" && proType != "") {
//create case dynabean
var _case = new DynaBean("Case");
_case.set("AssetId", assetId);
_case.set("ContactId", conId);
_case.set("RecordTypeId", proTypeId);
_case.set("Type", proType);
//create 1 new case
var saveResult = sforceClient.Create(_case);
alert("Here is the save result:"+saveResult.toString());
}
else {
alert("Error: Information required to create a Case directly from this Asset is missing.");
//return to asset page
frameNav(assetUrl);
}
}
saveResult.toString() is being returned as a null so i'm not getting any feedback. the variables being set are correct. any ideas/suggestions are much appreciated! thanks!
i'm trying to create a case w/ the ajax toolkit and having some issues. Here is the javascript function:
//create case from asset using contact id and record type info
function createCase() {
//check that all required variables are set
if (assetId != "" && conId != "" && proTypeId != "" && proType != "") {
//create case dynabean
var _case = new DynaBean("Case");
_case.set("AssetId", assetId);
_case.set("ContactId", conId);
_case.set("RecordTypeId", proTypeId);
_case.set("Type", proType);
//create 1 new case
var saveResult = sforceClient.Create(_case);
alert("Here is the save result:"+saveResult.toString());
}
else {
alert("Error: Information required to create a Case directly from this Asset is missing.");
//return to asset page
frameNav(assetUrl);
}
}
saveResult.toString() is being returned as a null so i'm not getting any feedback. the variables being set are correct. any ideas/suggestions are much appreciated! thanks!
Hi vander,
Try this line:
var saveResult = sforceClient.Create([_case]);
There is a bug in the toolkit. The documentation states that you can pass a single object or an array to the create call, but it is only working for an array.
Placing _case inside square brackets makes it an array.
thanks again - i really appreciate the help!
What is returned is either a SaveResult array or a SoapFault. You access the values returned by using "get" syntax.
So in your code you would do:
Message Edited by DevAngel on 08-17-2005 11:56 AM
alert("The new id is: " + oneSaveResult.get("Id"));
Calling '.id' directly works properly. Like this:
alert("The new id is: " + oneSaveResult.id);
Thanks for pointing me in the right direction though!
Message Edited by vander on 08-17-2005 01:12 PM
(Sheepish grin) Guess I actually ought to test the code first. To be clear and rectify the implied method of access properties - the "get" and "set" are used only for DynaBeans (a DynaBean is the class that is used to create an SObject), for all other objects you would use the dotted syntax. There are other alternatives due to the way javascript objects work, but for simplicity sake, the dotted is best.