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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 9
    Replies
I have an apex class like this:
01    public class Example {
02        
03        public class HandleInput {
04            @InvocableVariable(required=true)
05            public String id;
06        }
07        
08        public class HandleOutput {
09            @InvocableVariable(required=false)
10            public String name;
11            
12          @InvocableVariable(required=true)
13
14            public double value;
15        }
16        
17        @InvocableMethod
18        public static List<HandleOutput> function(List<HandleInput> inputParameters){
19            String id = inputParameters.get(0).id;
20            
21            ResponseIntegration response = new SomeIntegration().call(id); 
22            
23            List<HandleOutPut> outPuts = new List<HandleOutput>();
24            HandleOutput outPut = new HandleOutput();
25            //outPut.name = response.getName();
26            outPut.confidence = response.getValue();
27            
28            outPuts.add(outPut);    
29            return outPuts;
30        }
31    }

In Einstein Bot, when I put action apex, calling this class, the output shows me name and value
User-added image


Well, from the moment I commented line 25, and annotated the field as required=false (line 09), the Einstein bot must ignore the name field, and must KEEP the bot's name variable with the value it had before of this apex call, correct?

but this is not happening... the bot is not ignoring this field, it is setting NULL for the name field... I would like the field to keep the value it had before
 
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 an apex class like this:
01    public class Example {
02        
03        public class HandleInput {
04            @InvocableVariable(required=true)
05            public String id;
06        }
07        
08        public class HandleOutput {
09            @InvocableVariable(required=false)
10            public String name;
11            
12          @InvocableVariable(required=true)
13
14            public double value;
15        }
16        
17        @InvocableMethod
18        public static List<HandleOutput> function(List<HandleInput> inputParameters){
19            String id = inputParameters.get(0).id;
20            
21            ResponseIntegration response = new SomeIntegration().call(id); 
22            
23            List<HandleOutPut> outPuts = new List<HandleOutput>();
24            HandleOutput outPut = new HandleOutput();
25            //outPut.name = response.getName();
26            outPut.confidence = response.getValue();
27            
28            outPuts.add(outPut);    
29            return outPuts;
30        }
31    }

In Einstein Bot, when I put action apex, calling this class, the output shows me name and value
User-added image


Well, from the moment I commented line 25, and annotated the field as required=false (line 09), the Einstein bot must ignore the name field, and must KEEP the bot's name variable with the value it had before of this apex call, correct?

but this is not happening... the bot is not ignoring this field, it is setting NULL for the name field... I would like the field to keep the value it had before
 
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