Salesforce JavaScript

Hav*_*783 2 javascript salesforce onclick

我正在构建一个按钮,用户可以在打开案例后获取所有权并将状态设置为活动状态.虽然我的代码非常接近,但我收到了一个我不熟悉的错误.

这是我的代码:

{!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; 
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

A problem with the OnClick JavaScript for this button or link was encountered:
identifier starts immediately after numeric literal
Run Code Online (Sandbox Code Playgroud)

Mat*_*t K 5

我无法获得您发布的代码,但这样做:

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}

var updateRecord = new Array(); 
var myquery = "SELECT Id FROM Case WHERE Id = '{!Case.Id}' limit 1";

result = sforce.connection.query(myquery);
records = result.getArray("records");

if(records[0])
{
    var update_Case = records[0];
    update_Case.OwnerId = "{!$User.Id}"; 
    update_Case.Status = "Active";
    updateRecord.push(update_Case);
}

result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;
Run Code Online (Sandbox Code Playgroud)

更多地看一下,我认为你发布的代码是错误的,因为update_Case.User = {!$User.Id};声明.Case上没有User字段,User.Id全局变量应该放在引号中(对于JavaScript),如下所示:update_Case.OwnerId = "{!$User.Id}";