Show/Hide custom buttons based on a field value

Forums General discussion Show/Hide custom buttons based on a field value

Viewing 2 reply threads
  • Author
    Posts
    • #25054
      Maciek Grischke
      Participant

      I have a choice field Status with just two options: Open/Closed – this field is hidden.

      I want to add a “Close this ticket” button, but only when the ticket is Open (status field set to Open), and when the ticket is Closed (status field set to Closed), I want to hide “Close this ticket” button and show “Open this ticket” button instead.

      Is this possible?

      many thanks

    • #25058
      Maciek Grischke
      Participant

      Ok, I’ve managed to get it working by wrapping the jQuery inside a function and then calling the function with DFFS Rule.

      // Insert button if case is Open
      function showCloseButton() {
      // var statusValue = getFieldValue("Status");
      // if (statusValue = "Open") {
      jQuery("input[id$='_diidIOSaveItem']").before("<input type='button' id='CloseTicket' class='ms-ButtonHeightWidth' style='margin-right:4px;' value='Close this case' onclick='closeTicket()' />");
      // }
      }

      The above code could be used within different rules based on if else conditions, but in my case, I just called this function based on the rule condition, so sections I didn’t need I commented out.

      Hope this is the correct way for doing this.

      BTW, where can I read about what I can do with within DFFS using different JS tweaks? For example, setFieldValue, getFieldValue – I would like to know what is available to play with?

    • #25084
      Alexander Bautz
      Keymaster

      I’m glad you figured it out – and it looks just fine.

      I have no complete record of all functions you can use, but if you open the developer console and start typing spjs.utility. you will get a list of all the functions – and their name should tell you what they do. If you search in the forum you will find some of them referred to, and if you have any questions just ask in a thread in the forum.

      Alexander

Viewing 2 reply threads
  • You must be logged in to reply to this topic.