1

我的公司有一个应用程序,他们从应用程序交换(注意:在我开始之前)下架,允许您在 salesforce.com 中关注或取消关注大量案例/帐户/机会等。据说以前有效,现在无效。我需要了解每个按钮的代码有什么问题。如果我无法修复它们,有什么替代应用的想法吗?该应用程序不再在应用程序交换中。

这是关注按钮的代码:

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

//EDIT THE FOLLOWING LINE TO ALTER THE CODE FOR OTHER OBJECTS. USE THE PICKLISTS ABOVE        TO SELECT FIELD TYPE = $ObjectType AND THE OBJECT NAME THEN REPLACE "$ObjectType.Case" WITH   YOUR NEW OBJECT NAME
var records = {!GETRECORDIDS( $ObjectType.Case)};

function LBox() {
var box = new parent.SimpleDialog("steve"+Math.random(), true);
parent.box = box;`

 box.setTitle("Follow Records");

box.createDialog();
box.setWidth(220);

box.setContentInnerHTML("<img src='/img/loading32.gif' alt='' /> Running");

box.setupDefaultButtons();`

box.show();
}

function CBox(){
box.setContentInnerHTML("You are now following "+follow_count+" records<br /><br /><a href=\"#\" onclick=\"box.hide();\">Close</a>");
}



if (records[0] == null) { 
alert("Please select at least one record.");
} 
else { 
var follow_count = 0;

LBox();

for (var i = 0; i < records.length; i++){ 
var fol=new sforce.SObject("EntitySubscription");
fol.ParentId = records[i];
fol.SubscriberId = '{!User.Id}';

try{
sforce.connection.create([fol]); 
follow_count++;
}
catch(e){
alert(e);
}
}
CBox();

}

here's the unfollow button:
{!REQUIRESCRIPT("/soap/ajax/18.0/connection.js")}

// EDIT THE FOLLOWING LINE TO ALTER THE CODE FOR OTHER OBJECTS. USE THE PICKLISTS ABOVE TO SELECT FIELD TYPE = $ObjectType AND THE OBJECT NAME THEN REPLACE "$ObjectType.Case" WITH YOUR NEW OBJECT NAME
var records = {!GETRECORDIDS( $ObjectType.Case)};

// display running message popup
function LBox() {
var box = new parent.SimpleDialog("steve"+Math.random(), true);
parent.box = box;`

box.setTitle("Unfollow Records");

box.createDialog();
box.setWidth(220);

box.setContentInnerHTML("<img src='/img/loading32.gif' alt='' /> Running");

box.setupDefaultButtons();

box.show();
}

// display output message
function CBox(){
if (unfollow_count < records.length)
box.setContentInnerHTML("You have now unfollowed "+unfollow_count+" records. You were not following the other selected records. <br /><br /><a href=\"#\" onclick=\"box.hide();\">Close</a>");
else
box.setContentInnerHTML("You have now unfollowed "+unfollow_count+" records. <br /><br /><a href=\"#\" onclick=\"box.hide();\">Close</a>");
}

if (records[0] == null) {
alert("Please select at least one record.");
}
else {
var unfollow_count = 0;`

LBox();

try {
// find following records
var searchstring = "SELECT Id FROM EntitySubscription WHERE (ParentId IN (";
for (var i = 0; i < records.length - 1; i++) {
searchstring += "'" + records[i] + "',";
}
searchstring += "'" + records[records.length - 1] + "') AND SubscriberId ='{!User.Id}')";
var resultRecords = sforce.connection.query(searchstring).getArray("records");

// delete following records
var recordIds = [];
for (var i = 0; i < resultRecords.length; i++) {
recordIds.push(resultRecords[i].Id);
unfollow_count++;
}
sforce.connection.deleteIds(recordIds);
} catch(e) {
alert(e);
}

CBox();
}

第一个错误消息与权限有关,我没有收到此错误,因为我有管理员权限,第二个错误仅在帐户选项卡的按钮上。我更担心权限问题,有什么关于权限的吗?任何帮助都很棒!

4

2 回答 2

0

非系统管理员用户对 EntitySubscription 的查询必须包含 LIMIT。如果您将按钮中的查询代码更改为以下内容,它应该可以工作:

// find following records
var searchstring = "SELECT Id FROM EntitySubscription WHERE (ParentId IN (";
for (var i = 0; i < records.length - 1; i++) {
   searchstring += "'" + records[i] + "',";
}
searchstring += "'" + records[records.length - 1] + "') AND SubscriberId ='{!User.Id}') LIMIT 1000";
于 2012-07-27T21:43:33.967 回答
0

我认为问题是SFDC中的限制,您只能跟踪每个用户一定数量的记录。如果这个应用程序是按照您描述的那样设计用于大量跟踪记录,那么您可能会踩到油门,这是我从您的同事收到的错误中得到的一种印象at most 1000,如果它以前有效,那将是有道理的您已达到组织/用户的最大限制

于 2012-07-27T17:05:05.733 回答