How to render a boolean field in a form as HTML with images or colored text

has_change_pending in Part/CAD/Document forms is a check box. I want to make it 

- An image, if true show one image, if false show another

Or

- A colored text, if true show in one color, if false show in another color

Trying with making the field as HTML and add some tags, not much familiar with them, so wanted to ask here.

Parents
  • Hi Amitosh,

    This is an interesting use case. I'd recommend looking at the OOTB form for an Express ECO. There is a field on the form titled "EDR_Status" which is very similar to what you're attempting to do. All manipulation of this field happens during the form's onFormPopulate event "Express Fill EDR Status Field". Specifically, the function "populateEdrStatus" will be helpful.

    You should be able to write some javascript which quickly looks at the boolean property, and then assigns the correct image/text to the HTML element you've created.

    Tanks,

    AJ

  • I could change the field to HTML, 

    <img src="../customer/ChangePending.png" style="width: 36px; height: 36px;" name="has_change_pending"></img>

    And wrote a method on onFormPopulate to decide to show the image or not

    if(top.aras.getItemProperty(document.item, "has_change_pending", "") != "1")
    {
      hideChangePendingImage(true);
      return;
    }

    hideChangePendingImage(false);

    function hideChangePendingImage(hide)
    {

      var image = document.getElementsByName("has_change_pending")[0];
      if(hide)
      {
        image.style.display = "none";
      }
    }

Reply
  • I could change the field to HTML, 

    <img src="../customer/ChangePending.png" style="width: 36px; height: 36px;" name="has_change_pending"></img>

    And wrote a method on onFormPopulate to decide to show the image or not

    if(top.aras.getItemProperty(document.item, "has_change_pending", "") != "1")
    {
      hideChangePendingImage(true);
      return;
    }

    hideChangePendingImage(false);

    function hideChangePendingImage(hide)
    {

      var image = document.getElementsByName("has_change_pending")[0];
      if(hide)
      {
        image.style.display = "none";
      }
    }

Children
No Data