Using Ticket Status Value to Disable Custom Field

I am trying to disable a custom field named “Validated by Lead” when the ticket Status is changed to “In Analysis”. I have tried testing this on my dev site multiple times with this code, and I can’t figure out what I am missing here. Any assistance would be greatly appreciated!

$(document).ready( function() {
  app.initialized().then(function(client) {
  window.client = client;client.data.get("ticket").then (
    function(data) {
    	 var estStatus = data.ticket.status_label;
    	if(estStatus === "In Analysis") { 
    	client.interface.trigger("disable", {id: "cf_validated_by_lead"}); 
  	}
    client.events.on("ticket.statusChanged", propertyChangeCallback);
    function propertyChangeCallback(event) {
      var eventData = event.helper.getData();
      var estStatus = eventData.status_label.new;
      console.log(estStatus);
      if(estStatus === "In Analysis") { 
      client.interface.trigger("disable", {id: "cf_validated_by_lead"}); 
    }
    if(estStatus !== "In Analysis") {
      client.interface.trigger("enable", {id: "cf_validated_by_lead"});
          }
    }
    });
});
});

Hello @lreynolds,

Welcome!

I tried this out myself although data.ticket.status_label and cutom_field were different it my case. The logic worked as intended.

I was wondering, if you can see any error in the browser console that can help me debug this issue?

Thanks for getting back with me Sarif! I was using custom_field in a similar app that was interactive with two custom fields. But since this is interacting with the default “Status” field, I figured the logic would be different. Are you saying I should try using data.ticket.custom_field in place of “data.ticket.status_label”? Also, for the default Status field, is “ticket.statusChanged” the correct event?

Either way, can you help point out the specific code that you are recommending that I replace in the sample code I provided? Thanks!

@lreynolds,

ticket.statusChanged is the correct event if you want to check every time status is Changed. Here are some questions that I have,

  1. What are the other ticket status entities other than open,closed,resolved,pending that is configured in your freshdesk account? From your question I can guess, In Analysis is one of those.
  2. Can you share the data payload that is being passed to client.data.get("ticket").then(function(data){...}) ?
  3. Can you make sure cf_validated_by_lead has not spelling mistakes and is the right ID?
  4. Looking at your code, I see this is frontend code. When you perform this interface trigger is console showing any errors? If yes, can you share me any browser console logs that you see.

@lreynolds, Were you able to over come this issue? Do you need any more help?