Custom field data not saving after code is run

3 Comments

  • Amie SuccessCX

    HeyJesse Spalding,

    In general, when you make an update to a ticket field, you do then need to submit the ticket so it saves the changes you've made. Submitting the ticket normally requires the agent to also select a status at the same time.

    Perhaps you will need to include a submit function into your code here where you are adding the status into the update you're making.

    https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket

    I not a developer by nature but I hope this helps. :)

    1
  • Hanna Jordan

    Hi, I think the problem is that you are using theticket.save()method inside theticketFields:changedevent handler. This will cause an infinite loop of saving and changing the ticket fields, which may prevent the custom field data from being saved properly. A possible solution is to use a flag variable to check if the custom field data has been updated before saving the ticket. For example:

    Hope this helps,
    Hanna fromCodeIT

    var updated = false; // flag variable

    client.on('ticketFields:changed', function(e) {
    if (e.fieldId === 'status') {
    var status = e.value;
    if (status === 'solved') {
    client.get('ticket.customField:custom_field_360000000000').then(function(data) {
    var customField = data['ticket.customField:custom_field_360000000000'];
    如果(customField ! = = '是的'){
    client.set('ticket.customField:custom_field_360000000000', 'Yes');
    updated = true; // set flag to true
    }
    });
    }
    }
    });

    client.on('ticket.save', function() {
    如果(更新){/ /切ck flag before saving
    return true;
    } else {
    return false;
    }
    });

    1
  • Ahmed Zaid
    User Group Leader Community Moderator

    HiJesse Spalding,

    In your payloadticketCustomFieldData, you should changefieldstocustom_fields. That should the update issue.

    However, the app seems to perform the update every time it is loaded since it will always register with has_run as false. So, every time the ticket is opened, the fields will be updated.

    I believe your use case can benefit more from aZIS apprather than a ZAF one.

    1

Pleasesign into leave a comment.

Powered by Zendesk