SAP Knowledge Base Article - Public

2556173 - How to read / update picklist fields via Odata API - Syntax

Symptom

When updating or inserting a value for a picklist field for instances that still uses the legacy picklist system (Not MDF picklist), the payload syntax is a little different. This article will explain how to build this payload.

Environment

SAP SuccessFactors Recruiting Management

Resolution

The example below show how to update a picklist field:

When updating or inserting values in a picklist field, instead of the final value, you must provide the id for the disired picklist value that you want to use. Here is an example of a payload upsearting the picklist field (state) on the candidate entity.

../odata/v2/Candidate
{ "primaryEmail": "candidate@sap.com", "firstName": "Education", "lastName": "Master", "country": "BR", "cellPhone": "55 51 9999-9999", "state":{"id":"480"} }

The above example is the correct syntax when updating/inserting a picklist field. You must provide the id for the desired picklist option to be inserted into the field.

The example below show how to read a picklist field:

Lets conside the example:

Job Requisition ID = 101 where Field ID "status" is a Picklist field:

Request:

.../v2/JobRequisition?$format=JSON&$filter=jobReqId eq 101 &$select=status

Response:

{
"d": {
"results": [
{
"__metadata": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/JobRequisition(101L)",
"type": "SFOData.JobRequisition"
},
"status": {
"__deferred": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/JobRequisition(101L)/status"
}
}
}
]
}
}

it does not contain much information about that picklist,
then let's use $expand for that:

Request:

.../v2/JobRequisition?$format=JSON&$filter=jobReqId eq 101 &$expand=status&$select=status

Response:

{
"d": {
"results": [
{
"__metadata": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/JobRequisition(101L)",
"type": "SFOData.JobRequisition"
},
"status": {
"results": [
{
"__metadata": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/PicklistOption(11388L)",
"type": "SFOData.PicklistOption"
},
"id": "11388",
"status": "ACTIVE",
"sortOrder": 5,
"minValue": "-1",
"externalCode": null,
"optionValue": "-1",
"maxValue": "1",
"childPicklistOptions": {
"__deferred": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/PicklistOption(11388L)/childPicklistOptions"
}
},
"parentPicklistOption": {
"__deferred": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/PicklistOption(11388L)/parentPicklistOption"
}
},
"picklistLabels": {
"__deferred": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/PicklistOption(11388L)/picklistLabels"
}
},
"picklist": {
"__deferred": {
"uri": "https://apisalesdemo8.successfactors.com:443/odata/v2/PicklistOption(11388L)/picklist"
}
}
}
]
}
}
]
}
}

Note: the value of a picklist does not appear via ODATA, the OptionId is the usefull information.

See Also

2464195 - How to upsert/insert data for a Parent and Child object in one request using Odata API

2284463 - How to perform an Odata API Upsert call via Chrome Rest extension

Keywords

update, insert, picklist, Odata, Picklist, update, expand. , KBA , LOD-SF-RCM-INT , Integration Center & Intelligent Services , How To

Product

SAP SuccessFactors HCM Suite all versions ; SAP SuccessFactors Recruiting all versions