I’m constructing a button that a user can click once they’ve opened a case to take ownership and set the status to active. Although I had the code pretty close, but I’m getting an error I’m not familiar with.
Here’s my code:
{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")}
var url = parent.location.href;
var record = {!GETRECORDIDS($ObjectType.Case)}; //Looking for current case ID
var updateRecord;
var update_Case = new sforce.SObject("Case");
update_Case.Id = record;
update_Case.User = {!$User.Id};
update_Case.Status = "Active";
updateRecord.push(update_Case);
result = sforce.connection.update(updateRecord);
parent.location.href = url;
I’m getting this error:
A problem with the OnClick JavaScript for this button or link was encountered:
identifier starts immediately after numeric literal
I couldn’t get the code you posted to work, but this did:
Looking at it more, I think the code you posted is erroring because of the
update_Case.User = {!$User.Id};statement. There is no User field on Case, and the User.Id global variable should be placed in quotes (for JavaScript), like this:update_Case.OwnerId = "{!$User.Id}";