Use the Advanced Query activity to create a Salesforce query. 
      You can get records with multiple entities and multiple WHERE clauses. 
      You can map the query results from Salesforce to your process schema.
To get the records using a custom, advanced query, do the procedure in this topic.
    
    
    
    Salesforce Query Advanced Entity Configuration Screen
      
      
      
      
     
    
    
    
    
    
    
    
    
      
    How to Start
 
         
         
          
          - On the Organizer, 
            do one of these: 
            
            
            
          
 
          
          
          - Do one of these:
            
              - Add an activity:
                
                  - In the Process Builder, in the Activity Library, 
                    open the Salesforce 
 tab. 
                  - On the Salesforce 
 
                    tab, 
                    drag the Query Advanced Entity 
 
                    activity onto your process. 
                
               
              - Change an activity: 
                  - In your process, double-click your activity.
 
                
               
            
           
          - On the SaleForce Query Entity Configuration screen, click Advanced Query Entity 
. 
        
        
        
       
    
        
    Procedure
 
       
      
       
        - On the SaleForce Query Entity Configuration screen, in the Salesforce field, select your Salesforce access token.
          
To create a new access token, click 
            Add Token 
. For more information, refer to
            New Salesforce Access Token.
 
        - Complete this field 
	 				as necessary. 
          
              | Field Name | 
              Definition | 
            
        Query 
 | 
        
        
          
          
            
              - Function:
 
              - Specifies the select statement that defines the SQL query the activity does to get records from Salesforce.
 
            
            
            
              - Accepted Values:
 
              
              - A valid SQL select query.
              
 
              
            
            
            
              - Default Value:
 
              
              - None
                
              
 
            
            
            
              - Accepts Process Data Variables:
 
              
              - Yes
 
            
            
            
              - Example:
 
              
              - 
SELECT Id, Name FROM Account 
  WHERE Id IN ( SELECT AccountId FROM Contact WHERE LastName LIKE 'apple%' )
  AND Id IN ( SELECT AccountId FROM Opportunity WHERE isClosed=false) 
               
            
            
           
          
         | 
      
         
        - Click Execute Query to display the response of the query in Result Query box.
                  
 
        - On the Schema Mapper field, click the Ellipses button.
 
        - On the Schema Mapper screen, map the response columns to the schema elements.