cancel
Showing results for 
Search instead for 
Did you mean: 

Service Layer - Delete or edit valid value - UserFieldsMD

Stef5
Explorer
0 Kudos

I am trying to update and reorder valid values of a UserField via Service Layer. 
If I remove the ValidValuesMD section, or if I try to add a new valid value, everything is working fine.
But as soon as I want to PATCH an existing value the PATCH is executed with a "duplicate value" error.

Could it be that updating "Valid Values" (Deleting, Updating) is not possible at all via Service Layer API?
I couldn't find any solution so far. Just adding seems to be possible. 
Many thanks in advance for any feedback. 

Error: 

{
    "error": {
        "code": -5002,
        "message": {
            "lang": "en-us",
            "value": "Duplicate value "
        }
    }
}
 
Example for Patch: 
PATCH https://localhost:50000/b1s/v1/UserFieldsMD(TableName='OOPR',FieldID=19)

{ "Description": "UDF01", "Name": "UDF01", "SubType": "st_Address", "TableName": "@UDT01", "Type": "db_Alpha",
"ValidValuesMD": [
{"Value": "1",
"Description": "TEST 1"
},
{
"Value": "3",
"Description": "Test 3"
},
{
"Value": "2",
"Description": "test"
}
]
}

Kind Regards

View Entire Topic
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Hi Stef5,

Kindly refer to the following blog post: SAP Business One Service Layer: Entity CRUD - Update

The blog discusses about the header B1S-ReplaceCollectionsOnPatch=true which you need to use for your scenario.

Header B1S-ReplaceCollectionsOnPatch=true sets the update method as REPLACE, which means the whole content will be replaced and the mismatched old rows will be deleted.

In case of any issue, please do not hesitate to write us back.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Stef5
Explorer
0 Kudos
Dear Ankit, thanks for your help. I will try that. Kind Regards Stef5
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Stef5,

We will await your response.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support