Invoice creation using document intelligence
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I need to create a new invoice record whenever an inbound email comes in with attachment and need to extract the values from the attachment using document intelligence and map the values to the invoice record.
Could any one help me on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
This is a pretty cool use case! I've implemented something similar for processing vendor invoices automatically.
You'll want to break this into a few pieces:
First, set up an inbound email action to trigger when emails come in with attachments. That part's straightforward - create the email processing rule and have it call a Script Include or Business Rule.
For the document intelligence piece, you'll need to use ServiceNow's Document Intelligence API. The key is getting your attachment content and sending it to the ML service:
```javascript
var docIntel = new DocumentIntelligence();
var result = docIntel.processDocument(attachmentSysId, 'invoice'); // or whatever model you're using
```
The tricky part is mapping the extracted data to your invoice fields. Document Intelligence returns a JSON structure with the extracted values, but you'll need to handle cases where the extraction isn't perfect. I usually build in some validation logic:
```javascript
if (result.invoice_number && result.invoice_number.confidence > 0.8) {
invoiceGR.number = result.invoice_number.value;
}
```
One heads up - make sure you have the right Document Intelligence models trained for your invoice formats. The out-of-box models are decent but you might need to train custom ones depending on your vendors.
Are you planning to auto-create the invoices or queue them for review? I've found it's usually better to create them in a "pending review" state first until you're confident in the extraction accuracy.
What's your current setup like - are these coming from specific vendors or a mixed bag?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Currently I have created a inbound email action to create an invoice and copy the attachments to invoice record.
Now I want to extract the values from attachment using flow desingner and update the invoice record.
I have a document intelligent use case which is trained with some invoices and stores the data in invoice staging table .
I need to call this doc intelligence use case in the flow desingner and update the invoice record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Ah, you're already past the email setup - nice! For calling Document Intelligence from Flow Designer, you'll want to use a "REST Message" action or create a custom Flow Designer action that wraps the API call.
If you go the REST Message route, create one that points to your Document Intelligence endpoint. In your flow, you'd:
1. Get the attachment sys_id from your invoice record
2. Use REST Message action to call Document Intelligence with that attachment
3. Parse the response to map extracted values to your invoice fields
4. Update the invoice record
Since you mentioned your use case stores data in an invoice staging table, you might want to query that staging table instead if the processing already happened. Something like:
```javascript
var staging = new GlideRecord('your_invoice_staging_table');
staging.addQuery('source_attachment', attachmentSysId);
if (staging.next()) {
// Use staging.field_name to update your invoice
}
```
Are you getting the attachment sys_id properly in your flow? That's usually where people hit the first snag when trying to pass data to Document Intelligence.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
No, I am getting issue for passing the attachment sys id to Document task.
I have created these two flows but document task is not getting completed so the extraction is failing.
