Loading...

Integrating external healthcare platforms like Niko Health with Salesforce helps streamline document management and improve operational efficiency. In this guide, we will walk through the complete process of fetching a document from Niko Health using APIs and attaching it to a Salesforce account as a file.

This step-by-step implementation is useful when you want to automatically sync patient-related documents, invoices, prescriptions, or any external files into Salesforce.

Step 1: Set Up Named Credential

The first step is to configure a Named Credential in Salesforce. Named Credentials provide a secure and easy way to store authentication details and endpoint URLs for external systems.

As part of a Salesforce API integration, we will create a Named Credential for the Niko Health API endpoint. This helps avoid hardcoding sensitive information like usernames, passwords, or tokens directly in Apex code.

Why Use Named Credentials?

  • Secure authentication management
  • Simplifies API callouts
  • Supports OAuth and token-based authentication
  • Reduces maintenance effort

Configuration Includes:

  • Endpoint URL of Niko Health API
  • Authentication type
  • API credentials or token
  • Permission setup
  1. External Credentials:

    Step 1.1

  2. Name Credentials:

    Step 1.2 

  3. Name Principals:Step 1.3 
  4. Give the user permission to access this External Credential.Step 1.4 
  5. Give user external Credential Permission:Step 1.5 
  6. Once configured, Salesforce can securely communicate with the Niko Health system.

Step 2: Make First API Call (Fetch Documents List)

After setting up the Named Credential, the next step is to make an HTTP callout to the Niko Health API to fetch the list of available documents.

This initial step is a key component of a Salesforce Niko Health integration, enabling Salesforce to retrieve document metadata from the external system securely and efficiently.

Using Apex HttpRequest and HttpResponse, we send a GET request to the API endpoint.

Purpose of This API Call

The API returns metadata about documents, such as:

  • Document ID
  • File name
  • File type
  • Created date
  • Download URL

This response is usually returned in JSON format.

Example Flow

  1. Create HTTP request
  2. Set endpoint using Named Credential
  3. Set request method as GET
  4. Send request
  5. Receive response

This response will be used in the next steps to identify and download the required document.

Step 2

Step 3: Parse JSON Response

Once the API response is received, the JSON data must be parsed in Salesforce.

Salesforce provides methods like:

  • JSON.deserialize()
  • JSON.deserializeUntyped()

These methods help convert the raw JSON response into Apex objects or maps for easier access.

Why is Parsing Important?

The API response contains multiple fields and nested objects. Parsing helps extract specific values like:

  • Document ID
  • Download URL
  • File name

Without parsing, Salesforce cannot understand the JSON structure properly.

Best Practice

Create wrapper classes for structured and clean code when dealing with large API responses.

Step 3

Step 4: Extract Document Details

After parsing the response, the next step is to extract the required document details.

At this stage, we identify:

  • Which document needs to be downloaded
  • The exact download URL
  • File extension and name

Common Logic Used

You can filter documents based on:

  • Latest uploaded document
  • Specific file type
  • Matching patient/account information
  • Document category

These details are important because Salesforce will use them while saving the file.

Step 4

Step 5: Download the Document

Once the download URL is available, another API call is made to fetch the actual document file.

This API call generally returns the file content in binary format.

Process Includes

  • Creating another HTTP request
  • Sending GET request to download endpoint
  • Receiving file body from response

The document can be:

  • PDF
  • Image
  • Excel file
  • Text document

At this point, Salesforce receives the raw file data from Niko Health.

Step 5

Step 6: Convert File into Blob (Binary Large Data)

Salesforce stores files in Blob format. Therefore, the downloaded file content must be converted into a Blob before saving.

The HTTP response body is converted using:

Blob fileBody = response.getBodyAsBlob();

Why Blob Conversion is Required?

Blob is Salesforce’s binary data type used for:

  • PDFs
  • Images
  • Attachments
  • Documents

Without Blob conversion, the file cannot be stored in Salesforce Files.

Step 6


Step 7: Save File in Salesforce (ContentVersion)

Now the document is ready to be stored in Salesforce.

Salesforce Files are stored using the ContentVersion object. This approach strengthens Salesforce document management by centralizing files within the CRM and making them easily accessible to authorized users.

Required Fields

  • Title
  • PathOnClient
  • VersionData

Example Process

  1. Create ContentVersion record
  2. Add Blob data
  3. Insert the record into Salesforce

After insertion, Salesforce automatically creates a file in the Files section.

Benefits of Using ContentVersion

  • Modern Salesforce file storage
  • Better sharing capabilities
  • Version management support
  • Easy attachment to recordsStep 7


Step 8: Get ContentDocumentId

Once the ContentVersion record is inserted, Salesforce generates a related ContentDocumentId.

This ID is important because it represents the actual file stored in Salesforce.

Why Do We Need ContentDocumentId?

The Content Document Id is used to:

  • Link the file to Salesforce Account
  • Share files with users
  • Access file records later

You can retrieve it by querying the inserted ContentVersion record.

Final Step

Using ContentDocumentLink, the document can be attached directly to the Salesforce Account.

This completes the entire process to Fetch Document from Niko Health and Attach it to Salesforce Account, ensuring that users can access important files without leaving Salesforce.

Step 8


Conclusion

Integrating Niko Health with Salesforce for document synchronization improves automation and reduces manual work. By using Named Credentials, API callouts, JSON parsing, Blob conversion, and Salesforce Files, organizations can seamlessly manage external documents directly within Salesforce.

This approach provides:

  • Secure integration
  • Automated document handling
  • Better record management
  • Centralized file storage in Salesforce

Organizations looking to implement similar solutions can leverage expert Salesforce services and Salesforce integration services from HIC Global Solutions to build secure, scalable, and efficient healthcare integrations. With this implementation, healthcare and operational teams can access important documents without switching between systems.

Watch Live Demo

Integrating external healthcare platforms like Niko Health with Salesforce helps streamline document management and improve operational efficiency. In this guide, we will walk through the complete process of fetching a document from Niko Health using APIs and attaching it to a Salesforce account as a file.

This step-by-step implementation is useful when you want to automatically sync patient-related documents, invoices, prescriptions, or any external files into Salesforce.

Step 1: Set Up Named Credential

The first step is to configure a Named Credential in Salesforce. Named Credentials provide a secure and easy way to store authentication details and endpoint URLs for external systems.

As part of a Salesforce API integration, we will create a Named Credential for the Niko Health API endpoint. This helps avoid hardcoding sensitive information like usernames, passwords, or tokens directly in Apex code.

Why Use Named Credentials?

  • Secure authentication management
  • Simplifies API callouts
  • Supports OAuth and token-based authentication
  • Reduces maintenance effort

Configuration Includes:

  • Endpoint URL of Niko Health API
  • Authentication type
  • API credentials or token
  • Permission setup
  1. External Credentials:

    Step 1.1

  2. Name Credentials:

    Step 1.2 

  3. Name Principals:Step 1.3 
  4. Give the user permission to access this External Credential.Step 1.4 
  5. Give user external Credential Permission:Step 1.5 
  6. Once configured, Salesforce can securely communicate with the Niko Health system.

Step 2: Make First API Call (Fetch Documents List)

After setting up the Named Credential, the next step is to make an HTTP callout to the Niko Health API to fetch the list of available documents.

This initial step is a key component of a Salesforce Niko Health integration, enabling Salesforce to retrieve document metadata from the external system securely and efficiently.

Using Apex HttpRequest and HttpResponse, we send a GET request to the API endpoint.

Purpose of This API Call

The API returns metadata about documents, such as:

  • Document ID
  • File name
  • File type
  • Created date
  • Download URL

This response is usually returned in JSON format.

Example Flow

  1. Create HTTP request
  2. Set endpoint using Named Credential
  3. Set request method as GET
  4. Send request
  5. Receive response

This response will be used in the next steps to identify and download the required document.

Step 2

Step 3: Parse JSON Response

Once the API response is received, the JSON data must be parsed in Salesforce.

Salesforce provides methods like:

  • JSON.deserialize()
  • JSON.deserializeUntyped()

These methods help convert the raw JSON response into Apex objects or maps for easier access.

Why is Parsing Important?

The API response contains multiple fields and nested objects. Parsing helps extract specific values like:

  • Document ID
  • Download URL
  • File name

Without parsing, Salesforce cannot understand the JSON structure properly.

Best Practice

Create wrapper classes for structured and clean code when dealing with large API responses.

Step 3

Step 4: Extract Document Details

After parsing the response, the next step is to extract the required document details.

At this stage, we identify:

  • Which document needs to be downloaded
  • The exact download URL
  • File extension and name

Common Logic Used

You can filter documents based on:

  • Latest uploaded document
  • Specific file type
  • Matching patient/account information
  • Document category

These details are important because Salesforce will use them while saving the file.

Step 4

Step 5: Download the Document

Once the download URL is available, another API call is made to fetch the actual document file.

This API call generally returns the file content in binary format.

Process Includes

  • Creating another HTTP request
  • Sending GET request to download endpoint
  • Receiving file body from response

The document can be:

  • PDF
  • Image
  • Excel file
  • Text document

At this point, Salesforce receives the raw file data from Niko Health.

Step 5

Step 6: Convert File into Blob (Binary Large Data)

Salesforce stores files in Blob format. Therefore, the downloaded file content must be converted into a Blob before saving.

The HTTP response body is converted using:

Blob fileBody = response.getBodyAsBlob();

Why Blob Conversion is Required?

Blob is Salesforce’s binary data type used for:

  • PDFs
  • Images
  • Attachments
  • Documents

Without Blob conversion, the file cannot be stored in Salesforce Files.

Step 6


Step 7: Save File in Salesforce (ContentVersion)

Now the document is ready to be stored in Salesforce.

Salesforce Files are stored using the ContentVersion object. This approach strengthens Salesforce document management by centralizing files within the CRM and making them easily accessible to authorized users.

Required Fields

  • Title
  • PathOnClient
  • VersionData

Example Process

  1. Create ContentVersion record
  2. Add Blob data
  3. Insert the record into Salesforce

After insertion, Salesforce automatically creates a file in the Files section.

Benefits of Using ContentVersion

  • Modern Salesforce file storage
  • Better sharing capabilities
  • Version management support
  • Easy attachment to recordsStep 7


Step 8: Get ContentDocumentId

Once the ContentVersion record is inserted, Salesforce generates a related ContentDocumentId.

This ID is important because it represents the actual file stored in Salesforce.

Why Do We Need ContentDocumentId?

The Content Document Id is used to:

  • Link the file to Salesforce Account
  • Share files with users
  • Access file records later

You can retrieve it by querying the inserted ContentVersion record.

Final Step

Using ContentDocumentLink, the document can be attached directly to the Salesforce Account.

This completes the entire process to Fetch Document from Niko Health and Attach it to Salesforce Account, ensuring that users can access important files without leaving Salesforce.

Step 8


Conclusion

Integrating Niko Health with Salesforce for document synchronization improves automation and reduces manual work. By using Named Credentials, API callouts, JSON parsing, Blob conversion, and Salesforce Files, organizations can seamlessly manage external documents directly within Salesforce.

This approach provides:

  • Secure integration
  • Automated document handling
  • Better record management
  • Centralized file storage in Salesforce

Organizations looking to implement similar solutions can leverage expert Salesforce services and Salesforce integration services from HIC Global Solutions to build secure, scalable, and efficient healthcare integrations. With this implementation, healthcare and operational teams can access important documents without switching between systems.

Watch Live Demo

No Data Found.

Related Articles
How to Configure Salesforce for Google Chat Integration

Google Chat integration with Salesforce connects team communication with Salesforce data, helping teams receive important updates without constantly switching between platforms. It makes collaboration simpler and keeps sales teams informed. The integration works across three key components: Salesforce: Acts as the source system for business information, record updates, and automation. Google Cloud Console: Provides the […]

Read More
How to Integrate Tasks Between NikoHealth and Salesforce

How to Integrate Tasks Between NikoHealth and Salesforce Tasks play an important role in healthcare workflows and can be associated with Patients, Orders, Invoices, Documents, and Assigned Staff Members. With MultiSync Made Easy, organizations can synchronize Task records while maintaining these important relationships. This Niko Health image-based workflow also makes it easier to understand how […]

Read More
How to Build an AI-Powered Salesforce Record Assistant Using LWC and Models API

Sales representatives often work with Salesforce records that contain a lot of information, including emails, tasks, events, and Chatter activity. Going through all this information manually can make it easy to miss important details. With Salesforce LWC and Models API, you can build an AI-powered record assistant that brings this information together, summarizes important details, […]

Read More
How to Build an AI Email Generator for Salesforce Cases Using Salesforce Models API

Support agents spend a lot of time writing the same kind of customer emails, whether it is a case update, resolution message, or simple follow-up after an issue. An email generator for Salesforce can help reduce this repetitive work by creating a first draft directly from the Case record, using the information already available in […]

Read More
How to Integrate Purchase Orders Between NikoHealth and Salesforce

Purchase Orders are used to manage inventory procurement, vendor orders, product replenishment, and supply chain operations. Using MultiSync Made Easy, organizations can synchronize Purchase Orders between NikoHealth and Salesforce while maintaining relationships with: Vendors Products Purchase Order Items Locations In this guide, we will configure: NikoHealth → Salesforce Purchase Order Synchronization Salesforce → NikoHealth Purchase […]

Read More
How to Integrate Invoices Between NikoHealth and Salesforce

Invoices are a critical part of the healthcare billing process. They contain billing information, insurance details, diagnosis codes, service lines, HCPCS codes, charges, balances, and payment-related information. Using NikoHealth with Salesforce, organizations can automatically synchronize Invoice records between both platforms while maintaining relationships with: Orders Patients With Salesforce NikoHealth integration through MultiSync Made Easy, organizations […]

Read More
Our Location worldwide
Indian Flag India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203669505
United States of America Flag USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
United Kingdom Flag UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
CA Flag Canada
HIC Global Solutions INC
6D - 7398 Yonge St #1124 Thornhill, ON L4J 8J2 Canada +1(262) 310-7818