Updating custom object after changing the schema of the object

Answered

10 Comments

  • Official comment
    Shannon Anahata
    Comment actions Permalink

    Hi everyone following along on this thread! Engineering have done some digging into this and have been unable to replicate this issue, attempting multiple variations of possible replication steps. If anyone following continues to have issues, please submit a ticket to our Advocacy team, and we'll work toward getting the exact replication steps to understand the issue. 

  • Joey
    Comment actions Permalink

    Hi there-

    May I ask you to please confirm the Content-Type header you are sending in with your request? These requests must include an "application/merge-patch+json" content-type header.

    0
  • Lydia
    Comment actions Permalink

    The content header is correct for patch as I could update the old records with the old schema and now I can update new records created with the new schema. The issue is with the old records (created with the old schema) when I'm trying to update them including the new 2 attributes (new schema). In those cases, the API is returning the error number 422 maybe because it's trying to search for the attributes in that node of the graph database but they do not exist because the node was created before they were added to the schema. 

    To clarify a little: Originally, when the object was created for first time, I had the following schema

    {
    "data": {
    "key": "custom_object",
    "schema": {
    "properties": {
    "code": {
    "type": "string",
    "description": "Unique identifier"
    },
    "startdate": {
    "type": "string",
    "description": "Start date"
    }
    },
    "required": [
    "code",
    "startdate"
    ]
    }
    }
    }

    In my app I could create records, update and delete them. After a few days working with the object, the client realise that it was missing information like end date and type where the type is a required attribute. So I added those attributes to the schema:

    {
    "data": {
    "key": "custom_object",
    "schema": {
    "properties": {
    "code": {
    "type": "string",
    "description": "Unique identifier"
    },
    "startdate": {
    "type": "string",
    "description": "Start date"
    },
    "enddate": {
    "type": "string",
    "description": "End date"
    },,
    "type": {
    "type": "string",
    "description": "Type"
    }
    },
    "required": [
    "code",
    "startdate",
    "type"
    ]
    }
    }
    }

    The app can create records based on the new schema. It can update or delete them without issues. The problem appears when the user wants to update the new type attribute in an old record (that it was created when the schema didn’t have the end date or type attributes). In those cases, the patch call includes values for type because it’s a required attribute now. But that patch call returns error number 422 (UnprocessableEntity - object has missing required properties). In those cases, how do you update the records? Is there a way already implemented in the API?

    Thanks.

     

    0
  • Joey
    Comment actions Permalink

    Hey there LC-

    I spoke with a colleague about this and your original guess was correct, these older records will have to be recreated.

    0
  • Lydia
    Comment actions Permalink

    Thanks for the answer, Joseph. Although I think that is not a good solution. In my particular case, the custom object has a relationship with ticket, so it has 2 relationship records associated. If I delete the existing records, I have to delete the related records in the relationship objects, and then recreate all again (as the Zendesk ids are changed and I don´t want to have orphan records).

    Is there any place where I can suggest a change in the way this is managed in Sunshine? Thank you.

    0
  • Greg Lange
    Comment actions Permalink

    I agree with LC that there should be a better way to do this - I have close to 100,000 records created with relationships between them.  While I have not had to change/add an attribute yet I'm sure I will eventually.  Deleting all these records and recreating them (especially with the rate limit) will be a significant hassle.

    1
  • Bryan - Community Manager
    Comment actions Permalink

    Hi @LC and @Greg -- this has been brought up from other customers as well. I've passed along your comments to product management, too. This is a new and evolving area. More features are coming, especially around ease of use things like this, but I can't say exactly when or how they might look like. But know that you're being heard. And thanks for the feedback -- keep it coming everyone.

    0
  • Lydia
    Comment actions Permalink

    Thanks for the update, Bryan.

    0
  • Lydia
    Comment actions Permalink

    Hi Shannon,

    Would you mind let me know how I open a ticket with Advocacy team? I could send them more specific details about my particular case so they can investigate.

    Thanks.

    0
  • Bryan - Community Manager
    Comment actions Permalink

    Hi LC -- we'll take this offline. Please look for an email related to this and thanks in advance for your help!

    0

Post is closed for comments.

Powered by Zendesk