Can't change custom field through the SDK

Hi,

I`m trying to update one custom field (total) on a ticket using the sdk, but it doesn’t update the field.
Is there something I’m missing?

Here goes the sample code for the custom field:


document.addEventListener("DOMContentLoaded", renderApp);

function renderApp() {
  app
    .initialized()
    .then(function (client) {
      client.events.on("app.activated", function () {
        supportDemo(client);
      });
    })
    .catch(handleErr);
}

function supportDemo(client) {
  client.interface
    .trigger("setValue", {
      id: "custom_field total",
      value: 3,
    })
    .then(function (data) {
      client.interface.trigger("click", { id: "updateProperties" });
      console.log("success:", data);
    })
    .catch(function (error) {
      console.log("error:", error);
    });
}

Hi @Alexa_Diaz,

The name of the custom fields used will be formatted in a certain way for this operation. It will be prefixed with “cf_” text. So, the field name total will become cf_total.

Try to update the field with this formatted custom field name as shown below.

client.interface.trigger(“setValue”, { id: “cf_total”, value: 3 })

Also, according to the documentation, updating all the ticket properties is not possible programmatically from the app. It will only be done by the agent manually.
However, you can intercept when it happens manually and do any validation and even stop updating the properties if required with this Intercept event.

Hi Raviraj, thanks for your quick response.

Unfortunately, I did it exactly as you indicate me (using the name “cf_total_433766”, where total_433766 is the custom field name according to the object I received by querying the ticket via client.data.get(‘ticket’)) and the promise goes to the catch handler with an “undefined” error, and the form field stays unchanged.

Do you have any other idea I can try on?

Thank you.

Alexa.