Not able to update Customer's custom field individually.
Hi Support,
I'm facing an issue when updating a custom field value for customer. I have 2 custom field for a customer. One is type= date and other is type text.
I am using lightspeed retail API to update custom field of a customer.
API ENdpoint = https://api.lightspeedapp.com/API/Account/{MYACCOUNTID}/Customer/{CUSTOMERID}.json?load_relations=["CustomFieldValues"]
1. When I updating both field in a single API call it os working, here is my json request body
{
"CustomFieldValues":{
"CustomFieldValue":[
{
"customFieldID": 7,
"value": "22-02-2020T00:00:00+05:00"
},
{
"customFieldID": 4,
"value": "This is test"
}
]
},
}
2. When I updating only date field, API request is working fie again. Here is my json request body:
{
"CustomFieldValues":{
"CustomFieldValue":[
{
"customFieldID": 7,
"value": "22-02-2020T00:00:00+05:00"
}
]
},
}
3. When I updating only text field it is throwing a error, here is my API request body [Not Working]
{
"CustomFieldValues":{
"CustomFieldValue":[
{
"customFieldID": 4,
"value": "This is test"
}
]
},
}
ERROR: Invalid CustomFieldValue date="2020-03-20T18:00:00-0600"
Could you please have a look into my request and let me know a solution.
Thanks
Answers
How it's configured your custom field type? It's a string, date, number...?
Because I was got this problem too, but someone goes to the lightspeed dashboard for any reason and change the customField type, what it should not be allowed to do after has some record.
As I mentioned I have two field One is type= date and other is type text.
When I updating a date field, it is working fine. But When I updating a text field it showing below error
ERROR: Invalid CustomFieldValue date="2020-03-20T18:00:00-0600"
Hello @Ankit Geeks,
The custom field type is date, this is why you can only enter a date value. The response provided misleads you, but the error message indicates that the custom field type is date.
yes I understood but I only want to update one field (text)
I'm not passing any value for date field.
Here is my request payload, customFieldID=4 is a type string field.
{
"CustomFieldValues":{
"CustomFieldValue":[
{
"customFieldID": 4,
"value": "This is test"
}
]
},
}
Workaround:
Save the value of the date (thats currently inside the custom field) in a variable:
var = "2020-10-10T07:00:00+00:00"
Remove everything after char(t) so:
var = "2020-10-10"
Write to your desired custom fields & the date field with your new variable var.
Not the best solution, but this seems te be a bug in the API.