0

Error occurred while performing DELETE operation on sobject: TopicAssignment with data: [record_id] (MALFORMED_QUERY: Implementation restriction: TopicAssignment only allows security evaluation for non-admin users when either (1) LIMIT is specified and at most 1000 or (2) WHERE is specified and filter on Id or Entity)...

Here is my remote object access definitions:

<apex:remoteObjects > <apex:remoteObjectMOdel name="TopicAssignment" fields="Id,TopicId,EntityType" /> </apex:remoteObjects>

I have written a simple fetch function that utilizes the retrieve() operation:

var topicassignment = new SObjectModel.TopicAssignment();
    var fetchTopicAssignments = function() {
      topicassignment.retrieve({ limit: 10 }, function(err, records, event) {
        if(err) {
          alert(err.message);
        }
        else {
          var ul = document.getElementById("TopicAssignmentList");
          records.forEach(function(record) {
            // Build the text for a topicassignment line item
            var tpaText = record.get("EntityType");


            // Add the line item to the list
            var line = document.createElement("li"); 
            line.id = record.get("Id");
            line.innerHTML = '<input type="checkbox" />' + tpaText;
            ul.appendChild(line);

          });
        }
      });

    };

I also have a save function that calls the del() operation on TopicAssignment object instances.

var save = function() {
      var x = document.getElementById("TopicAssignmentList"), 
          c = x.childNodes;

         for (var i = 0; i < c.length; i++) {
            if (c[i].nodeType === 1) {
            var value = c[i].id;
                if (c[i].firstChild.checked) {
                   x.removeChild(c[i--]);
                   topicassignment.del(value, updateCallback);
                }
            }
        } 
 }; 

In my updateCallback function, I am handling errors. I have console logged the error messages (if any), and this is where I receive the above error message.

I don't know how to build the del() call with criteria such as LIMIT or WHERE as the documentation states: "del() accepts two arguments, both optional, and can delete one or many records, depending on the arguments that you provide."

RemoteObjectModel.del([record_ids], callback_function)

Any thoughts are much appreciated!

2
  • Probably its internal bug, I've tried query on retrieve, but nothing works: {limit}, {where: {EntityType: {eq: 'Account' }}}, {where: {Id: ..., {where: {EntityId: ... Commented Apr 20, 2016 at 16:52
  • I was able to source this documentation from the SOAP API developer guide: developer.salesforce.com/docs/atlas.en-us.api.meta/api/… That indicates the delete call is not supported for this object. Commented Apr 28, 2016 at 22:08

1 Answer 1

0

You can try AJAX Toolkit instead:

<script src="../../soap/ajax/36.0/connection.js" type="text/javascript"></script>
<script>
    sforce.connection.sessionId='{!GETSESSIONID()}';
</script>

Refactored li element, now getElementsByName("ids") can be used

records.forEach(function(record) {
    var input = document.createElement("input");
    input.name = "ids";
    input.type = "checkbox";
    input.id = record.get("Id");
    var li = document.createElement("li");
    li.innerHTML = input.outerHTML+record.get("EntityType");
    ul.appendChild(li);       
});

Displays as:

<li><input id="0FT36000000Gx2SGAS" name="ids" type="checkbox">Account</li>

Delete function, bulk added:

var delete = function() { 
    var x = document.getElementsByName("ids");
    var record_ids =[]; //collect list of id
    for (var i=0;i<x.length;i++){
        if(x[i].checked){
            record_ids.push(x[i].id);
        }   }

    result=sforce.connection.deleteIds(record_ids);
    for(var i=0;i<result.length;i++){
        if(result[i].getBoolean("success")){
            console.log("account deleted with id"+result[i].id);
        }else{
            console.log("failed to delete account"+result[i]);
            alert(result[i].errors.message);
        }} };
1
  • Thank you @IlyaLepesh. Great thinking on the workaround. I had never used the AJAX toolkit before, so thank you for introducing that. Commented Apr 22, 2016 at 17:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .