Is it possible to generate a JSON file in the NW system that contains invoice information in a specific format and send it to an AWS Lambda function via an API call?
Yes this is possible using many features across the platform.
I think the most straightforward approach would be as follows. This assumes the AWS Lambda has been setup to be reachable via an API Gateway:
- Create a table definition. This table will map values into the JSON. Use as many fields as you need; you can specify the shape of the JSON later.
- In Endpoint Definitions, create a new endpoint for the AWS Lambda API. On the Request page, you can add headers and query params to the request, as well as mapping fields from the table into the JSON. Enter the table you created into the “Request Mapping Table” field. This will allow you to map fields from the table into JSON using the “Field Map” subtable.
- You will need to configure a response code set for this endpoint using Endpoint Response Set Definitions. This just tells the system which response codes to “accept”. If a code is not listed here, we will retry multiple times to make the endpoint call and fail generically if we cannot complete it. This includes 200 responses if not listed.
- In Logic Block builder, use the Call External Endpoint action. Select the endpoint you just made for the endpoint to call. Set the Source Type to “Table”; it will pull in the table from the endpoint. You should add a filter so that it finds your specific record.
- This assumes you previously inserted a record into this table with the values populated that you need for your JSON.
- You will need to trigger this Logic Block somehow. It could be a row action, field event, trigger, called by another LB, whatever, but it needs to be called by something.
- You can then use the Response Handling to work with the response of the endpoint call. Basic “DSN Handling” will output the response to a new Data Source, allowing you to select the fields from it like you would a normal record from a table.
Let me know if this fits your case or if you have follow-up questions!
2 Likes