You need to sign in to do that
Don't have an account?
Arthur Almeida 12
Different results executing in Anonymous Window and in Einstein Bot
I have this class:
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:
When I execute in the anonymous window, I execute this script:
Why the result is different from executing in anonymous and in Einstein Bot?
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 solved my problem add the "without sharing" keyword to my class.