Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Create a new attachment category in Aptify Smart Client (under Framework), name it as DOB, and scope it to Entity. Add Persons under Entities tab. Once DOB attachment category is created, we will need 3 JSON endpoints.

image2019-10-15_16-8-11.pngImage Removed   Image Added                 

image2019-10-15_16-8-44.pngImage RemovedImage Added

Here we can see the DOB category under persons attachment. We added one DOB attachment to it as given in below screenshot. Now, we will View and Download this attachment using our JSON endpoints.

DOB_Attachment_SmartClient.jpgImage RemovedImage Added

Anchor
b
b
JSON Endpoints

...

Here is the response as shown in POSTMAN:

View DOB Attachment.jpgImage RemovedImage Added


Anchor
bb
bb
getSingleDownload

...

Download the DOB attachment of the above person in Chrome browser. As we can see in the Screenshot below, we successfully downloaded the attachment which we uploaded initially through Smart Client.

DOB_Heath_Ledger_1.jpgImage RemovedImage Added

The code given below provides security to this endpoint. We will discuss about this in Security.

...

This endpoint uses the "Test Attachment PF” process flow which is under HDEB-10 (Code + Metadata) Attachments.zip → HDEB-10_PF_TestAttachment.cmpack.

image2019-10-15_14-38-3.pngImage RemovedImage Added

Info
titleUpload - Hardcoded entity and category

For the POC, Entity Name, and Category Id are hardcoded in the Business Logic.

...

Upload one more DOB attachment to the person as shown is the below screenshot, using this endpoint:

Upload Attachment.jpgImage RemovedImage Added

Now, refresh the Person record on Smart Client and we can see that there are two attachments. Second attachment uploaded by using JSON endpoint.

DOB_AttachmentS_SmartClient.jpgImage RemovedImage Added

Also, when we hit 'ViewAttachments' endpoint, we can see two attachments being returned.

View DOB AttachmentS.jpgImage RemovedImage Added

Anchor
c
c
Security

...

Whenever an unauthorized person tries to fetch an attachment, this give errors as given below:

image2019-10-15_15-33-2.pngImage RemovedImage Added

Deployment Instructions

...

  1. Extract the files from HDEB-10 (Code + Metadata) Attachments.zip.
  2. Unpack the PF's and DBO's CMPacks using CM tool.
  3. Paste FileUpload.json and DownloadAttachment.json files under “..\eBusiness\json\metadata\v1\Endpoints\ProfilePersons” folder.

image2019-10-15_15-16-22.pngImage RemovedImage Added

4. The above three endpoints are registered under HDEB-10 (Code + Metadata) Attachments.zip → ProfilePersonEndpoint.json file.

Code Block
languagejs
titleJSON - Registering attachment endpoints
collapsetrue
"UploadFile": {
      "$ref": "FileUpload.json#/UploadFile"
    },
    "ViewAllAttachments": {
      "$ref": "DownloadAttachment.json#/ViewAllAttachments"
    },
    "DownloadAttachment": {
      "$ref": "DownloadAttachment.json#/getSingleDownload"
    }

image2019-10-15_16-14-35.pngImage RemovedImage Added

5. Add the class 'AttachmentComponent.cs' from HDEB-10 (Code + Metadata) Attachments.zip  under 'MultipartFormDataProcessFlows' project in Visual Studio.

This class Implements “IProcessComponent” interface. This component is responsible for attaching the Attachment to the entity record specified by the Input Parameters.

image2019-10-15_16-1-46.pngImage RemovedImage Added