You need to sign in to do that
Don't have an account?

Case copy fails - cant figure out why
I am trying to create a new button that runs an S Control that will take the current "Case", grab the information from specified fields, and create a new case. I have tried several methods. Surprisingly every time I search for information I come up with a new completely unrelated possible solution.
I have tried at least 4 different ways, and I continue to get page javascript errors "Object Expected", same error every time, line number does change.
Code:
I took out the other methods I had attempted so hopefully this is readable. I also tried creating a DynaBean("Case") and setting the values, case.set("Item",value); and then calling sforceClient.Create([case])[0]; but was met with the same result, Object Expected. Im going to try to see if it is null values or something somewhere. Is there a way to check that in the code I listed above?
<html> <head> <script language="javascript" src="/soap/ajax/8.0/connection.js" type="text/javascript"></script> <script type="text/javascript"> function createClone() { var case = new sforce.SObject("Case"); case.RecordTypeId = "012300000000000000"; case.ContactId = "{!Case.ContactId}"; case.Applicant_Name__c = "{!Case.Applicant_Name__c}"; case.Request_ID__c = "{!Case.Request_ID__c}"; case.Product_or_Service__c = "{!Case.Product_or_Service__c}"; case.Subject = "{!Case.Subject}"; case.Origin = "{!Case.Origin}"; case.AccountId = "{!Case.AccountId}"; case.CS_Case_Number__c = "{!Case.CS_Case_Number__c}"; case.Description = "{!Case.Description}"; var result = sforce.connection.create([case]); if (result[0].getBoolean("success")) { log("new case created with id " + result[0].id); } else { log("failed to create case " + result[0]); } } </script> </head> <body onload="createClone()"> <P> </p> </body></html>
I took out the other methods I had attempted so hopefully this is readable. I also tried creating a DynaBean("Case") and setting the values, case.set("Item",value); and then calling sforceClient.Create([case])[0]; but was met with the same result, Object Expected. Im going to try to see if it is null values or something somewhere. Is there a way to check that in the code I listed above?
I was able to get past the disabled View Source context menu and it looks like everything is being populated like its supposed to:
var case = new sforce.SObject("Case");
case.RecordTypeId = "0126000000098D0XXX";
//case.ContactId = "00330000004u89k";
//case.Applicant_Name__c = "TEST";
//case.Request_ID__c = "testing";
//case.Subject = "testing";
//case.Origin = "Email";
//case.AccountId = "00130000002XX";
case.CS_Case_Number__c = "00803464";
//case.Description = "test";
var result = sforce.connection.create([case]);
still getting error, Object Expected.
var result = sforce.connection.create([case]);
alert(result);
Let us see what the server returned.