Good day

Today I have a use case that builds on my previous blog, Create a custom MDF Object with multiple records.  To build on this use case, I have a new requirement that should allow attachments to be automatically added to the record that already exists.

I first want to mention this blog as the input for my blog, as it certainly has helped a lot in the beginning stages.

I have started out building a custom MDF that allows users to create multiple records for their qualifications.  Furthermore, I will be enhancing the offering by allowing attachments not only to be manually uploaded but to be upserted via an API as well.  This will add the ability for attachments to be sent by the provider, and instead of uploading it in SuccessFactors, you can upsert via CPI (by retrieving it from a secured location, upserting it to SFSF, and adding it to the user).  For the purposes of this blog, I will be using Postman in my illustrations.

What sets my use case apart is:  I have a parent and child scenario (which allows me to create multiple records), which means I want to add the attachment to the child entity.  Secondly, I also do not want to create a new record, since I want to add the attachment to an existing qualification record.

Things to keep in mind before starting

  • Attachments cannot be uploaded to your custom MDF directly, since inline editing is not allowed
  • It would be a two-step process
    • First import the attachment
    • Secondly, add the attachment to the MDF Record that exists
  • I have added the externalCode for the child entity to my UI, to enable me to quickly identify the record in question
  • The effective start date from the parent needs to be added in your payload, in EPOCH time
  • Uploaded attachments can be found via Manage Documents in the instance


Add attachment via OData

First off, start by uploading the attachment to your instance.  For me, I will POST to the Attachment endpoint:

My payload body also contains:

  • userId – IMPORTANT:  this is the userID of the API User
  • fileName – this can be any desired naming convention
  • module – GENERAL_OBJECT
  • fileContent – upload the attachment to Base64 Encode, download the text output, and use the string in the text file in your payload

Your status response should be Status: 201 Created, with the attachmentId that is required for the next POST.

Add Attachment to Record

The next is a POST:

Importantly, your payload body should contain:

  • uri – the CHILD custom MDF
  • PARENT externaCode (effectively the userID of the PERSON since it is of Data Type = User)
  • PARENT effective date (epoch format)
  • externalCode – this is for the child entity record
  • attachmentNav – with the attachmentID obtained in the previous post

The attachment will then be added to the record previously created.

As always, feel free to ask me for any additional input if I missed any steps, or add comments or suggestions.




Tags: OData
Randa Khaled

Randa Khaled

Author Since: November 19, 2020

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x