• Arthur Almeida 12
  • NEWBIE
  • 20 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 8
    Replies
I would like to do a select in one account that has 2 assets with status X

I tried with:
SELECT Id, AccountId FROM Asset WHERE Status = 'X' LIMIT 2

but this return 2 rows with 2 different accounts... I need it to be the same account...

how does it?
I have a "table" Campaign Member in the Salesforce, with 2 records:
User-added image
And I have a "table" Asset with 2 records too:
User-added image
I would like to know if there is a way to select all AccountId of the table Asset that is not in the table Campaign Member.
 
For example, the query would return just the AccountId 111, because Account Id 870 there are in the table of Campaign Member.
 
Exist some way to make this?
I have this class:
public class Class {    
    public class HandleInput {        
        @InvocableVariable(required=true)        
        public String idAsset;    
    }        
    public class HandleOutput {        
        @InvocableVariable(required=true)        
        public String status;    
    }

    @InvocableMethod    
    public static List<HandleOutput> find(List<HandleInput> inputParameters){        
        String idAsset = inputParameters.get(0).idAsset;                
        String status = [SELECT Status FROM Asset WHERE id =: idAsset];

        List<HandleOutPut> outPuts = new List<HandleOutput>();        

        HandleOutput outPut = new HandleOutput();        
        outPut.statusPreAutorizacao = status;        
        outPuts.add(outPut);                
        return outPuts;    
    }
}

When I execute this class in the anonymous window, the result is Success, but when the Einstein Bot executes the class, it gives an error:
System.QueryException: List has no rows for assignment to SObject

When I execute in the anonymous window, I execute this script:
Class.HandleInput handleInput = new Class.HandleInput();
handleInput.idAsset = X;

List<Class.HandleInput> inputParameters = new List<Class.HandleInput>();
inputParameters.add(handleInput);

List<Class.HandleOutput> outputs = Class.find(inputParameters);
System.debug(outputs.get(0).status);

Why the result is different from executing in anonymous and in Einstein Bot?
I have a Unit Test Apex, and I would like to schedule this test for execution every day in a specific hour
how to make this?
When I execute this query
List<AggregateResult> query = [
    SELECT Max(Id) Id, AccountId, Max(CustomField__c) 
    FROM Asset WHERE Status = 'X' 
    AND (CustomField__c = 'Z' 
    OR CustomField__c = 'Y') 
    GROUP BY AccountId LIMIT 1000 
];

The first time, happen an error:
Internal Salesforce.com Error

But the second time, I executed this query, the result with success 

User-added image

Why does this happen?
I have a batch apex class, and this class makes a SELECT with a limit of 1000.
after that, this class creates one campaign using insert, and processes others things, whatever.

the question is when I execute my class, it creates five campaigns in the same hour... how is this possible?
my class creates only one campaign.

the batch apex is executed multiple times at once when the volumetry of data is big?
I am trying to deploy my chat button with routing type omni-channel using SFDX and this error occurred:

You must select at least one skill.

what do I need to make?
I need to use this code:
List<Asset> assets = map.get(accountId);
For this, I created this map:
Map<Id, List<Asset>>
but I do not know how to assemble this map, I have a list of the Assets, and each Asset has a lookup of the Account

 
I have a "table" Campaign Member in the Salesforce, with 2 records:
User-added image
And I have a "table" Asset with 2 records too:
User-added image
I would like to know if there is a way to select all AccountId of the table Asset that is not in the table Campaign Member.
 
For example, the query would return just the AccountId 111, because Account Id 870 there are in the table of Campaign Member.
 
Exist some way to make this?
I have this class:
public class Class {    
    public class HandleInput {        
        @InvocableVariable(required=true)        
        public String idAsset;    
    }        
    public class HandleOutput {        
        @InvocableVariable(required=true)        
        public String status;    
    }

    @InvocableMethod    
    public static List<HandleOutput> find(List<HandleInput> inputParameters){        
        String idAsset = inputParameters.get(0).idAsset;                
        String status = [SELECT Status FROM Asset WHERE id =: idAsset];

        List<HandleOutPut> outPuts = new List<HandleOutput>();        

        HandleOutput outPut = new HandleOutput();        
        outPut.statusPreAutorizacao = status;        
        outPuts.add(outPut);                
        return outPuts;    
    }
}

When I execute this class in the anonymous window, the result is Success, but when the Einstein Bot executes the class, it gives an error:
System.QueryException: List has no rows for assignment to SObject

When I execute in the anonymous window, I execute this script:
Class.HandleInput handleInput = new Class.HandleInput();
handleInput.idAsset = X;

List<Class.HandleInput> inputParameters = new List<Class.HandleInput>();
inputParameters.add(handleInput);

List<Class.HandleOutput> outputs = Class.find(inputParameters);
System.debug(outputs.get(0).status);

Why the result is different from executing in anonymous and in Einstein Bot?
I have a Unit Test Apex, and I would like to schedule this test for execution every day in a specific hour
how to make this?
When I execute this query
List<AggregateResult> query = [
    SELECT Max(Id) Id, AccountId, Max(CustomField__c) 
    FROM Asset WHERE Status = 'X' 
    AND (CustomField__c = 'Z' 
    OR CustomField__c = 'Y') 
    GROUP BY AccountId LIMIT 1000 
];

The first time, happen an error:
Internal Salesforce.com Error

But the second time, I executed this query, the result with success 

User-added image

Why does this happen?
I have a batch apex class, and this class makes a SELECT with a limit of 1000.
after that, this class creates one campaign using insert, and processes others things, whatever.

the question is when I execute my class, it creates five campaigns in the same hour... how is this possible?
my class creates only one campaign.

the batch apex is executed multiple times at once when the volumetry of data is big?
I need to use this code:
List<Asset> assets = map.get(accountId);
For this, I created this map:
Map<Id, List<Asset>>
but I do not know how to assemble this map, I have a list of the Assets, and each Asset has a lookup of the Account