You need to sign in to do that
Don't have an account?
Case Accept button on Page Layout
This is the first time I am writing Ajax, but it seems pretty straight forward. However I am getting an error for which I cannot find an answer online.
I am trying to put a custom button on a Case Page Layout so when a user clicks the button then it will update the Case Owner to be user. The logic is able to query all the information correctly, but I am unable to update the record.
{!requireScript("/soap/ajax/19.0/connection.js")} var CaseObj= new sforce.SObject("Case"); var CaseNum = '{!Case.CaseNumber}' var UserId = '{!User.Id}'; var CaseId = '{!Case.Id}' var ExistingOwner = '{!Case.OwnerId}' var CaseObjs = sforce.connection.query("select id, OwnerId from Case where Id ='{!Case.Id}'"); CaseObj = CaseObjs; if ( UserId == ExistingOwner) { alert ('You already own the case'); } else { CaseObj.OwnerId = UserId; CaseObj.Id = '{!Case.Id}'; result = sforce.connection.update([CaseObj]); alert ('You have accepted Case Number' + CaseNum); } alert (CaseId + UserId + ExistingOwner + CaseObj);
This particular line gives me the following error when executed: "A problem with OnClick Javascript for this button was encountered. faultcode: Soapenv: Client, faultstring Missing entity type information. SObject requires a seperate 'type' field be sent"
result = sforce.connection.update([CaseObj]);
I will appreciate any help on this issue.
Thank You in advance.
To my surprise, I don't know what is still wrong with the code above, but I am writing the same logic in a cleaner fashion and it is working for me.
Here is the code that I modified