SAP Knowledge Base Article - Public

2477558 - How to work with SFOdata.Background_InsideWorkExperience entity - SuccessFactors OData API

Symptom

While performing various CRUD operations on the SFOdata.Background_InsideWorkExperience entity, you are getting below error messages:

  • Error "For input string: \"\"", when passing blank value for the backgroundElementId field
  • Error message: "Single-valued key cannot be represented as a complex value" when not passing the field backgroundElementId in the Upsert operation
  • Error message: "Employee XXXXXX has no Edit access to record 123404. with the index 0" when passing a random value for the field backgroundElementId in the Upsert operation
  • Error message: "SQLException caught: IJ031070: Transaction cannot proceed: STATUS_MARKED_ROLLBACK"

Environment

  • SAP SuccessFactors HCM Suite
    • OData API

Cause

The reason for these errors is due to incorrect request data sent to the SFSF system.

Resolution

In order to resolve the issue, you need to ensure you pass the REQUEST in correct format.

This KBA explains how to perform various CRUD operations on the SFOdata.Background_InsideWorkExperience Entity

   Sample request for Query operation-

GET /odata/v2/Background_InsideWorkExperience?$filter=userId eq 'admin'&$format=json

   Sample request for Insert operation-

POST /odata/v2/ Background_InsideWorkExperience?

{
"usersId" : "MultJob1",
"testDate" : null,
"startDate" : "\/Date(1388563200000)\/",
"title" : "test12",
"testVarchar" : "[test4][http://www.example.com]",
"endDate" : "\/Date(1388563200000)\/",
"testInteger" : 0,
"testFloat" : null,
"division":"240", //division is configured as a picklist,insert the picklist option Id
}

   Sample request for Upsert operation to Insert a new record-

POST /odata/v2/upsert?
{
"__metadata":{"uri":" Background_InsideWorkExperience "},
" backgroundElementId " :0,// backgroundElementId=0 means this is the insert operation
"usersId" : "MultJob1",
“bgOrderPos”:-1, //Here set the bgOrderPos<0
"testDate" : null,
"startDate" : "\/Date(1388563200000)\/",
"title" : "test12",
"testVarchar" : "[test4][http://www.example2.com]",
"endDate" : "\/Date(1388563200000)\/",
"testInteger" : 0,
"testFloat" : null,
"division":"240", //division is configured as a picklist,insert the picklist option Id
}

   Sample request for Upsert operation to Update a new record-

POST /odata/v2/upsert?
{
"__metadata":{"uri":" Background_InsideWorkExperience "},
" backgroundElementId " :234,// backgroundElementId!=0 means this is the update operation, the id “234” is the original ID
"usersId" : "MultJob1",
“bgOrderPos”:10, // bgOrderPos=10, original bgOrderPos
"testDate" : null,
"startDate" : "\/Date(1388563200000)\/",
"title" : "test12",
"testVarchar" : "[test4][http://www.example3.com]",
"endDate" : "\/Date(1388563200000)\/",
"testInteger" : 0,
"testFloat" : null,
"division":"240",
}

   Sample request for Delete operation-

DELETE /odata/v2/ Background_InsideWorkExperience (backgroundElementId =2807L,userId='admin')?$format=json

Points to Note:

  1. While Inserting a new record using the 'Upsert' operation, you should pass the field 'backgroundElementId' in the request with a value '0'.
  2. But when updating an existing Background-element using the 'Upsert' operation, you need to pass the existing value of the 'backgroundElementId' field.

The field bgOrderPos

bgOrderPos will represent the order that the records are shown in the screen. If one user has 2 Background_InsideWorkExperience records, one will have bgOrderPos = 1 and the other will have bgOrderPos = 2. If you try to upsert a third record passing the value bgOrderPos = 2, an error will occur.

To prevent this, always pass the value bgOrderPos = -1 in the API call. This will make the new record be placed in the next position. So, if the user has 2 Background_InsideWorkExperience records and you upsert a third record with bgOrderPos = -1, it will be placed in the third position and will end up receiving the value bgOrderPos = 3.

Keywords

successfactors, success factors, odata, api, call, upsert, insert, update, new, change, remove, delete, Background entity, backgroundElementId, element id, bgorderpos, , KBA , LOD-SF-INT-API , API & Adhoc API Framework , LOD-SF-INT , Integrations , LOD-SF-INT-ODATA , OData API Framework , Problem

Product

SAP SuccessFactors HCM Suite all versions