Skip to Content
Technical Articles
Author's profile photo Ka Shun Wong

Upsert Custom MDF Attachment via OData

This blog is to demonstrate the steps to upsert an attachment in custom MDF through OData API.

 

Below are the steps for proof-of-concept:

1. Create custom MDF (Admin Center > Configuration Object Definitions)

  • API Visibility = Editable
  • Subject User Field = externalCode

  • set externalCode’s data type as ‘User’ so that it can be used in Employee Profile
  • create field cust_attachment with data type ‘Attachment’

  • Always a practice to set the RBP control for custom MDF

 

2. Create Configuration UI (Admin Center > Manage Configuration UI)

  • Set externalCode as not visible (which will auto-fill user ID)

 

3. Configure People Profile (Admin Center > Configure People Profile)

 

4. Update RBP for ESS/MSS/Admin Users (Admin Center > Manage Permission Roles)

  • User Permissions > Employee Views (so as to show custom MDF in People Profile)
  • User Permissions > Miscellaneous Permissions (so as to maintain the custom MDF records)

 

5. Update RBP for OData API Access User (Admin Center > Manage Permission Roles)

  • Administrator Permissions > Manage Integration Tools > OData API Attachment Import
  • Administrator Permissions > Manage Integration Tools > OData API Attachment Export

 

6. Refresh OData Metadata (Admin Center > OData API Metadata Refresh And Export)

 

7. OData API – Step 1: Import file to Attachment entity (via Postman)

  • POST URL: https://apisalesdemo2.successfactors.eu:443/odata/v2/Attachment
  • Body:
    • userId: the user ID of OData API User (Mandatory)
    • fileName: file name (Mandatory)
    • module: GENERAL_OBJECT for custom MDF (Mandatory)
    • fileContent: the attachment file in base64 encoded format (Mandatory)
  • Send the OData request

  • Attachment ID (ie. 7447) is returned (keep this ID for later use)

 

8. OData API – Step 2: Insert custom MDF record to employee with attachment ID (via Postman)

  • POST URL: https://apisalesdemo2.successfactors.eu:443/odata/v2/cust_AttachmentODataInsert
  • Body:
    • (Key) effectiveStartDate: in Unix EPOCH time format
    • (Key) externalCode: employee’s user ID
    • cust_attachmentNav
      • link to entity Attachment (with attachment ID 7447)

  • Response Message

 

9. Check in People Profile

 

Using Postman to send OData queries is only for proof-of-concept purpose and in real project, you may use other programming language to develop a end-to-end process scenario.

 

Reference:

  1. SAP KBA 2599554 – Odata attachment upsert to custom MDF Object not reflecting attachments in UI
  2. SAP SuccessFactors HCM Suite OData API: Reference Guide

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Anuj Kumar
      Anuj Kumar

      Hello Carson,

      I am trying the same thing however I am getting below error (I have super admin right).

      [COE0018]No permission to access the attached file ABCDEF.jpg. Attachment in field cust_attachment does not belong to the user XXXXXX.

       

      I am not sure what causing this problem as I tried with all different parameters.

      Any suggestions.

      Best Regards,

      AK

      Author's profile photo jaideep shetty
      jaideep shetty

      Hi Anuj Kumar,

       

      Did you find the cause or solution for your issue?

       

      Thank You,

      JD

      Author's profile photo Vivian Smid
      Vivian Smid

      Hi Anuj Kumar.

       

      I have the same issue.

      Did you find the solution??

      Author's profile photo Naveen V
      Naveen V

      Hi All

      I have same issue .. As per the document all are configured correctly but still i get below error

      [COE0018]No permission to access the attached file Testpdf.pdf. Attachment in field cust_interimReport does not belong to the user apiuser.
      Can anyone suggest how to solve this issue
      Regards
      Naveen V
      Author's profile photo Vishwas Nanjundaswamy
      Vishwas Nanjundaswamy

      Hi Naveen,

       

      Even I was facing the same issue. I am able to solve it now.

      In the above blog, if you carefully observe, there are 2 different userID used.

      In step 7, you need to pass UserID=API User. In your case it should be apiuser.

      In step 8, you can use the actual employee's userID which you are testing.

       

      Regards,

      Vishwas N

      Author's profile photo Jaime Julio
      Jaime Julio

      Thanks, It worked!!