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 or data corrupted inside the system.
Resolution
In order to resolve the issue, you need to ensure you pass the REQUEST in correct format. On this KBA we will use Background_InsideWorkExperience as an example, but this might apply to any other Background Entity.
1ST CAUSE: INCORRECT REQUEST
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:
- While Inserting a new record using the 'Upsert' operation, you should pass the field 'backgroundElementId' in the request with a value '0'.
- 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.
2ND CAUSE: DATA CORRUPTED
The issue STATUS_MARKED_ROLLBACK can happen when you are trying to insert data into for a Background object for a user that is not on the system anymore, meaning that the user has been purged but for some reason its Background data is still available on the system. Usually on these scenarios you cannot find any data from this user on standard objects such as from Employee Central or UDF (User entity), but still, when querying the background object the API returns data for this user.
On such scenarios, you must delete the data from this user on the affected background entity. For that, you should perform an API call as below:
- HTTP Method: DELETE
- URI: https://<api-server>/odata/v2/Background_Attendance_Status(backgroundElementId =0L,userId='103149')?$format=json
Once the record is deleted, your integrations won't try to upsert this corrupted record and the issue shouldn't happen again.
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
SAP Knowledge Base Article - Public