function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arthur AlmeidaArthur Almeida 

Einstein Bot - How to use variable in Object Search Custom Value

I have two 'Object Search' in my Chatbot.

The first Object Search is to find a Product, and I save the result in a custom variable. This works normally.

The second Object Search would is to find the Machines of Product, and I need to find all Machines where Product = {!product.Id}, for the example:

User-added image

But this gives an error.
 
Error: Exception when invoking /support/conversations/0X9e00000004CDF/invocations/1rle00000008OOEAA2: [{"message":"; nested exception is: \n\tcommon.exception.ApiQueryException: \nProduto_da_Maquininha__c WHERE Produto_do_Bot__c = '{!ProdutoSelecionado[0].Id}'\n

He would should replace {!ProdutoSelecionado[0].Id} for Id value...

How to use a variable in Custom Value of Object Search?
Best Answer chosen by Arthur Almeida
SwethaSwetha (Salesforce Developers) 
Thanks for sharing the fix that worked for you. Reposting here so it can help others facing the same scenario.

The solution was to use Action Apex instead of Object Search, because, in Action Apex, we can pass variable in Custom Value.

Please consider marking the answer best to close the thread.Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
HI Arthur ,

Based on https://help.salesforce.com/articleView?id=sf.bots_service_deliver_knowledge_articles.htm&type=5 
>The chatbot should work in a custom user context.
>The bot can deliver up to three records and hold three fields for each record.

Can you make sure these are considered in your scenario?Thanks
SwethaSwetha (Salesforce Developers) 
Thanks for sharing the fix that worked for you. Reposting here so it can help others facing the same scenario.

The solution was to use Action Apex instead of Object Search, because, in Action Apex, we can pass variable in Custom Value.

Please consider marking the answer best to close the thread.Thank you
This was selected as the best answer