findOrdersByDocument
function allows you to locate orders associated with a customer using their document identifier, such as CPF or CNPJ. When executed within the Execute JavaScript block, it checks for the existence of orders in the system and, if found, returns a response containing an array with complete details about the orders associated with the given document — including customer information, purchased items, and payment status.
payload.document
.
findOrdersByDocument
function and retrieve the orders associated with the provided document.
payload.orders = await findOrdersByDocument(payload.document)
to retrieve orders associated with the document provided by the customer. In this way, the document stored in the variable payload.document
is used by the findOrdersByDocument
function to fetch the related orders. The result is stored in payload.orders
as an array containing the orders.
Código utilizado no exemplo
for
and if/else
structures. These commands enable detailed and conditional formatting of the displayed information. To deepen your knowledge about Reportana® Script and explore more examples, please consult the complete documentation: Reportana® Script - Documentation.
findOrdersByEmail
Function