Im passing an array of Ids from my JS into currentUserId,


    <apex:form > 
        <apex:actionFunction action="{! removeFollower }" name="processId" oncomplete="refresh()">
            <apex:param assignTo="{! currentUserId }" name="userId" value="" />


   public String[] currentUserId { get; set; }

I want to then loop through EntitySubscription and delete each of them. This method works for single Ids, but I need to edit it to accept multiple Ids.

    public PageReference removeFollower() {         
    try {

        for(Integer i = 0; i<currentUserId.length; i++){
                EntitySubscription subscription = [SELECT parentId FROM 
                                                   WHERE subscriberId = :currentUserId[i]
                                                   AND parentId = :id];
                Delete subscription; 
        } catch(Exception ex) {
            system.debug('Error: ' + ex);
        return null;   

At the moment, I'm getting this error.

Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<String>

Would anyone have any suggestions or advice?

  • You're trying too hard...
    – sfdcfox
    Oct 17, 2013 at 15:11

1 Answer 1

public void removeFollower() {         
    Database.DeleteResult[] results = Database.delete([SELECT Id FROM EntitySubscription WHERE SubscriberId IN :currentUserId AND ParentId = :Id LIMIT 500], false);
    // process results here
  • Delete results; Is throwing up an error,
    – Daft
    Oct 17, 2013 at 15:30
  • What error? And for admin or non-admin?
    – sfdcfox
    Oct 17, 2013 at 15:32
  • I'm not sure if it's admin or non-admin, sorry Error: Compile Error: DML requires SObject or SObject list type: LIST<Database.DeleteResult> .
    – Daft
    Oct 17, 2013 at 15:33
  • sorry... I copied it wrong. My heads pretty melted at the moment.
    – Daft
    Oct 17, 2013 at 15:34
  • How are you passing in the values? Can you share that code, too?
    – sfdcfox
    Oct 17, 2013 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.