• Dean Rourk 2
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Can you guide me if I want to extract the field values of Activity history in your query, how would I do it?

I am trying to use this code but I don't understand how to write the wrapper

public ActivityHistory[] getHistory() {
       // List<Activities> act {get;set;}
       
        List<Account> AccountsWithActivityHistories = [ 
            // you can't query ActivityHistory directly; only in a subquery against another object type
            SELECT
            Id
            ,Name
            ,( SELECT ActivityDate, Description, whoid, whatid,Status, subject, istask, ActivityType
              FROM ActivityHistories)
            FROM Account WHERE Id = :accountId
        ];
       
        // ActivityHistories on Account
        for (Account a : AccountsWithActivityHistories) {
            for (ActivityHistory ah : a.getSObjects('ActivityHistories')) {
                              
                if (((string)ah.WhatId).startsWith('001')) {
                    // only add ActivityHistory's tied directly to an Account
                    activities.add(new ActivityWrapper(ah));
                   
                }
            }
        }       
       
    }
 
We use the account owner and their manager to control who can view accounts.  Owners can only see there accounts.  Works great.

I created a VF page and controller to display a custom object that has a master detail relationship with account.  Everyone can all the accounts.  I don't understand why the the account security is not following through on the VF page.  

Any help would be greatly appreciated.
 
I keep getting a compile error: Error: Compile Error: Method does not exist or incorrect signature: [Approval.ProcessSubmitRequest].setNextApproverIds(Id) 
Eventually I will not hard code the user name 'john Taylar' and get it from the object.  

Has anyone been able to get this to work.


trigger SDRStartApprovalProcess on SDR__c (after update) {
      for( id aId : Trigger.newMap.keySet() )
{
  if( Trigger.oldMap.get( aId ).Account_Owner_id__c!= Trigger.newMap.get( aId ).Account_Owner_id__c )

     // do something here because your field has changed
        List<User> users = [select Name from User where Name= 'John Taylor'];

         id approver= users.get(0).Id ;  
         //Approver =  userMap(Trigger.newMap.get( aId ).Account_Owner__c).Id        
        
         Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
         app.setObjectId(aid);
         app.setNextApproverIds(approver);
         Approval.ProcessResult result = Approval.process(app); 
}
 
}

}
We use the account owner and their manager to control who can view accounts.  Owners can only see there accounts.  Works great.

I created a VF page and controller to display a custom object that has a master detail relationship with account.  Everyone can all the accounts.  I don't understand why the the account security is not following through on the VF page.  

Any help would be greatly appreciated.