cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with updating fields in organization unit using c4codataapi

prat2
Explorer
0 Kudos
656

Hi all,

I have a requirement to update Employee in Organisation unit in C4C.

I am using standard odata service (c4codataapi) for this purpose.

entity: OrganisationalUnitEmployeeAssignmentCollection

property that i am trying to update: JobID and EmployeeID

Property of the Fields

I am sending a PATCH request with the following path and with json data

/sap/c4c/odata/v1/c4codataapi/OrganisationalUnitEmployeeAssignmentCollection('00163E832F9B1EE9A3850019AE940236')

{
    "EmployeeID": "10000021"
}

I am getting an error , <message xml:lang="en">Change not possible; object does not exist</message>

Internal server Error : 500

When i do the GET for the same request , I get the Object.

Am i missing something?

Best regards,

Prat

View Entire Topic
leonardo_felini
Advisor
Advisor
0 Kudos

Hi Pratyush,

I made some tests in our internal system, and was able to reproduce the same error. In fact, it seems that it is not possible to change the employee ID from an object of the OrganisationalUnitEmployeeAssignment collection, as it is a key field. In this context, the "updatable" property that you mentioned means that the object can be removed in case of a DELETE request, rather than meaning it's value can be changed.

So the best approach for this would be to perform two operations. First send a DELETE request to the collection object ('00163E832F9B1EE9A3850019AE940236'), and then perform a POST operation with the required data (the new employee ID) to create a new entry in the collection.

Kind regards,

Leonardo

Support Consultant | SAP Product Support

Community:

SAP Business ByDesign: https://www.sap.com/community/topics/business-bydesign.html

SAP Cloud for Customer: https://www.sap.com/community/topics/cloud-for-customer.html

prat2
Explorer
0 Kudos

Thank you Leonarda for confirmation. I was doing the same thinking as a work around.

Regards

Prat

papsoc
Explorer
0 Kudos

@leonardo_felini @prat2 

The root cause of the issue, is that the incoming value is the same with the current value in the object.

If you try to Patch passing the value <d:EndDate>9999-12-31T00:00:00</d:EndDate> without changing anything else and the current value is 9999-12-31T00:00:00 the request will fail, with the known error message.

If you try to pass the value 9999-12-30T00:00:00, that will work. I don't know why that happens, but makes no sense for a Patch request.