2011-11-10 7 views
2

소유권을 가져 와서 상태를 활성으로 설정하기 위해 사용자가 사례를 열면 사용자가 클릭 할 수있는 버튼을 만들고 있습니다. 코드는 아주 가깝지만 익숙하지 않은 오류가 발생합니다.Salesforce JavaScript

{!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; 

나는이 오류 받고 있어요 : 여기

내 코드의

A problem with the OnClick JavaScript for this button or link was encountered: 
identifier starts immediately after numeric literal 
+0

주석 코드는 //은 \\ 대신입니까? – Nettogrof

+0

네, 죄송합니다. 게시물에 덧글을 추가했습니다. – Havoc783

답변

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; 

더 자세히 살펴보면 내가 게시 한 코드가 update_Case.User = {!$User.Id}; 성명. Case에 User 필드가 없으며 User.Id 전역 변수는 다음과 같이 JavaScript 용 따옴표로 묶어야합니다. update_Case.OwnerId = "{!$User.Id}";

+0

매트 덕분에 훌륭하게 작동했습니다. 나를 괴롭히는 것은 전세계적인 부름이었습니다. – Havoc783

3

이렇게하면 쿼리가 저장 될 수 있습니다.

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

var url = parent.location.href; 

var update_Case = new sforce.SObject("Case"); 
update_Case.Id = '{!Case.Id}'; 
update_Case.OwnerId = '{!$User.Id}'; 
update_Case.Status = 'Active'; 

result = sforce.connection.update(update_Case); 
parent.location.href = url; 
0
`{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")} 
var newRecords = []; 
var c = new sforce.SObject("Case"); 
c.id ="{!Case.Id}"; 
c.User = {!$User.Id}; 
c.Status = "Active"; 
newRecords.push(c); 
result = sforce.connection.update(newRecords); 
window.location.reload();`