Application Integration - How to use the Javascript-Task on an DocAI Result Object

HI everyone,

can anyone explain, how it would be the best way to filter and work with results from DocAI Tasks in Application Integration. The solution to this might be applicable to working with any Objects/Arrays in the Javascript Task.

About my setup:
- Document AI with Invoice Parser
- Application Integration

When i get the Data from DocAI i am using a Data Mapper task to get the response.document.entities into an local Integration variable. I then want to extract the data from a few keys into my own variables i can filter on in the flow.

My Data Mapper looks currently like this:

thomasrose_0-1687164772522.png

I would really want to make this a little cleaner with some javascript but am unable to get the Javascript task to work for me, always getting an error when i am trying to set a variable:

thomasrose_1-1687164864269.png

And the logs tell me: 

 

Message: instance type (array) does not match any allowed primitive type (allowed: ["object"]) Schema Path:""

 

thomasrose_2-1687164998995.png

Can anyone provide me some informations or good examples of the Javascript Task?

Solved Solved
0 1 303
1 ACCEPTED SOLUTION

Hi @thomasrose,

Welcome to the Google Cloud Community!

You should look into the JavaScript Task documentation. Try changing your executeScript method to this format, as shown in the given documentation:

function executeScript(event) {
 
event.log(event.getParameter("var1"));
 
}

You can also get in touch with Google Cloud Support if the above option doesn't work. Let me know if it helped, thanks!

View solution in original post

1 REPLY 1

Hi @thomasrose,

Welcome to the Google Cloud Community!

You should look into the JavaScript Task documentation. Try changing your executeScript method to this format, as shown in the given documentation:

function executeScript(event) {
 
event.log(event.getParameter("var1"));
 
}

You can also get in touch with Google Cloud Support if the above option doesn't work. Let me know if it helped, thanks!