Wednesday, June 17, 2026

Integrating AI API with SPFx Web Part

AI is becoming an important part of modern applications. One useful use case in SharePoint is connecting AI APIs inside an SPFx web part.

This post will explain at high level ,how we can connect an AI API with an SPFx web part and create a simple 'Document Summary' solution.


Solution Architecture


Process
  1. SPFx web part reads document content from SharePoint
  2. Document content is sent securely to AI API
  3. AI service generates summary of the document
  4. SPFx web part displays summary to the user
Technology Stack
  • SharePoint Framework (React + TypeScript)
  • Microsoft SharePoint Online
  • REST API or Microsoft Graph API
  • AI API such as OpenAI, Azure OpenAI, or custom AI service
  • Azure Function or Backend API for secure communication

Frontend – SPFx Web Part


Read Document Content

The SPFx web part can read document content using SharePoint APIs/ PnP / Graph APIs.

Example:

const apiUrl = `${webAbsoluteUrl}/_api/web/GetFileByServerRelativeUrl('${fileUrlEncoded}')/$value`;

const response = await context.spHttpClient.get( apiUrl, SPHttpClient.configurations.v1 );

const content = <get text content from response based on different file type>


Calling AI API

After reading the document content, send it to AI service.

Example:

let headers = {
    'Content-Type': 'application/json'
};

headers.Authorization = `Bearer ${openAiKey}`;

let requestBody = {
    messages: [
        { 
        role: 'system', 
        content: 'You are a helpful summarization assistant.' 
        },
        { 
        role: 'user', 
        content: `Summarize this document. Document text:\n${content}` 
        }
    ],
    max_tokens: <maxTokens>
};

requestBody.model = <model>;

const result = await fetch(apiUrl, {
    method: "POST",
    headers,
    body: JSON.stringify(requestBody)
});

const summary = await result.json();

The AI service will process the document and return the summary.


Security Consideration

Do not keep API keys directly inside frontend code.

Recommended approach:

  • SPFx sends request to Azure API or Azure Function
  • Backend stores API key securely
  • Backend calls AI provider
  • Response is returned back to SPFx web part

This helps in protecting API keys and keeps the solution secure.


Conclusion

Integrating AI APIs with SPFx web parts can make SharePoint applications smarter and more useful. The future of SharePoint development is AI-powered intelligent solutions.

Sunday, December 28, 2025

SharePoint Online + Acumatica Integration Architecture (Using SPFx & OAuth2)

Modern SPFx + OAuth2 + Acumatica ERP Integration

Integrating SharePoint Online with Acumatica ERP allows organizations to bring core ERP data—such as Stock Items, Customers, Vendors, Sales Orders, and Cases—directly into a modern SPFx web part. This post shows how authentication, tokens, and data flows work together in a secure enterprise-ready design.


🌐 High-Level Architecture

The following diagram shows the full end-to-end architecture:


Figure 1 — SharePoint–Acumatica Integration Architecture


1️⃣ Solution Overview

The SPFx web part enables users to:

  • Filter and browse Acumatica entities
  • Select entity items and display fields in real time
  • Optionally save entity fields into a SharePoint list
  • Work with either cached or live ERP data

2️⃣ Architecture Components

🔹 SharePoint Online

  • Hosts SPFx UI
  • Stores selected entity data in lists
  • Authenticates via Microsoft Entra ID (MSAL)

🔹 SPFx Web Part

  • React-based UI
  • Calls backend API using access token
  • Stores access + refresh tokens
  • Displays live or saved Acumatica data

🔹 Integration API (Azure Function / App Service)

  • Handles authentication to Acumatica
  • Stores and refreshes tokens
  • Executes REST calls securely

🔹 Acumatica ERP

  • Exposes REST API
  • Supports OAuth2 & Azure AD SSO
  • Returns requested entities

3️⃣ Authentication Flows

Three authentication models can be used depending on business and security needs.

🔵 Flow A: Service Account (Admin Credentials)

A backend service account authenticates to Acumatica and returns ERP data to SharePoint. This is easiest for read-only, system-level operations.

🟢 Flow B: User Credentials (OAuth 2.0 Authorization Code)

Users enter their Acumatica credentials. Access token is issued per user, respecting their permissions in Acumatica.

🟣 Flow C: Azure AD SSO (Recommended)

Provides seamless login between SharePoint and Acumatica using the same Entra ID identity.


4️⃣ Token Lifecycle

SPFx stores and uses the following:

  • Access Token
  • Refresh Token
  • Expiry Time

When the access token expires, the refresh token is used to obtain a new one automatically. No user interaction needed.


5️⃣ Data Delivery Modes

🔹 Local Mode (Cached Data)

  • Selected entity fields saved in SharePoint list
  • Fast page load
  • Best for stable master-data

🔹 Live Mode (Real-Time API Calls)

  • Data fetched from Acumatica on every page load
  • No duplication of ERP data in SharePoint
  • Ideal for dynamic data (orders, quantities, QC updates)

6️⃣ High-Level Data Flow

  1. User opens the SharePoint page
  2. SPFx authenticates using MSAL
  3. SPFx queries the Integration API
  4. API manages token lifecycle
  5. Acumatica returns requested entity data
  6. SPFx outputs or stores the data

7️⃣ Why This Architecture Works

  • Secure (OAuth2 + Azure AD)
  • No credentials stored client-side
  • Supports real-time and cached modes
  • Scalable using Azure Functions
  • Works with enterprise SSO


Part 1 - Acumatica Files -> SharePoint DMS Integration

Part 2 - SharePoint DMS -> Acumatica Files Integration

Displaying SharePoint Files Inside a Custom Acumatica Screen

Allow Users to Fetch Files From SharePoint Into Acumatica Entities

Many organizations use SharePoint Online as their primary document management system while relying on Acumatica as their ERP. A common requirement is enabling users to view SharePoint files inside Acumatica and selectively attach them to ERP entities such as:

  • Sales Orders
  • Purchase Orders
  • Vendor Profiles
  • Customer Accounts
  • Cases / Projects
  • Quality Documents (QC)
  • Any custom entity

This article describes an architecture where a custom Acumatica screen displays files from a SharePoint library. Users can select a document and import it into Acumatica as an attachment.


1. Overview

A custom screen is added to Acumatica that connects to a SharePoint document library. The integration supports:

  • Viewing SharePoint files within Acumatica
  • Filtering files based on metadata
  • Previewing files
  • Selecting one or multiple files
  • Attaching selected files into Acumatica entities

The integration works using either:

  • Azure AD SSO (user identity flows from Acumatica to SharePoint), or
  • Azure App Authentication (client credentials for system-to-system calls).

2. Authentication Options

Option 1 — SSO Authentication (Recommended)

  • Acumatica user logs in via Azure AD
  • The same identity is used to call SharePoint
  • No additional login required
  • Ensures user-based permissions on SharePoint
  • True single sign-on experience

Option 2 — Azure App (Client Credentials)

  • Background service or Acumatica server calls SharePoint
  • Uses App Registration (Client ID + Secret or Certificate)
  • Useful when document visibility does not depend on user rights
  • Consistent system identity for auditing

Both models allow Acumatica to securely communicate with SharePoint using the Microsoft Graph API.


3. What the Custom Screen Does

3.1 Fetch SharePoint Files

The custom screen retrieves the following information from SharePoint:

  • File names
  • Versions
  • Metadata
  • Approval status
  • Last modified date
  • Secure, time-bound download URL

Files are displayed inside Acumatica using a grid or panel.

3.2 Select and Import

  • User selects one or more files
  • Acumatica requests the file binary from SharePoint
  • File is securely returned via API
  • Document is attached to the selected entity (SO, PO, Vendor, etc.)

3.3 Metadata Mapping

Typical metadata synced from SharePoint:

  • Document Category
  • Entity ID (e.g., SO000234)
  • Entity Type (SalesOrder, PurchaseOrder, Customer, Vendor)
  • Uploaded By
  • Approval Workflow Status

4. Architecture

High-Level Flow

Acumatica Custom Screen → Integration API (optional) → Microsoft Graph → SharePoint Library

Steps in Detail

  1. User opens the custom screen in Acumatica
  2. Screen retrieves SharePoint library items
  3. Metadata and file information is displayed
  4. User selects files and clicks Import
  5. SharePoint returns the file binary
  6. Acumatica attaches the document to the target entity

If an Azure Function is used as middleware, it handles:

  • OAuth2 / SSO token management
  • Secure Graph API calls
  • Normalized JSON responses

5. Typical Use Cases

Finance

Attach invoice PDFs or bank receipts stored in SharePoint to AP/AR transactions.

Procurement

Link vendor quotes, contracts, and specifications to Purchase Orders.

Sales

Attach proposals, agreements, and customer documents.

Quality (QC)

Pull approved certificates and inspection reports into Acumatica.

Projects

Attach drawings, CAD files, and site documentation stored centrally.


6. Benefits

  • Centralized document management in SharePoint
  • No manual download and re-upload
  • Approval-driven governance before ERP usage
  • Consistent security using Azure AD
  • Improved user experience within Acumatica
  • Full audit trail using SharePoint and ERP metadata
  • Higher data quality through metadata mapping

7. Conclusion

This integration allows Acumatica to consume approved, metadata-rich documents directly from SharePoint, providing a seamless and secure way to attach files to ERP entities.

Result:

  • SharePoint for document storage
  • Approval workflows via SharePoint / Power Automate
  • Acumatica for business processing


Part 1 - Acumatica Files -> SharePoint DMS Integration

Part 3 - Acumatica Entity -> SharePoint List/Pages Integration