0

Please teach me how to use this global function :-)

This code can be used in global functions and I want to make use of it.  I know I can call it from a Form/Tab as needed but how?

"--- This controls the HUD icons top right ---";
function UIHide(options : text) do
    var html := "";
    for items in split(options, ",") do
        html := html +
            switch items do
            case "print":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-print{display: none;}</style>"
            case "trash":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-trash{display: none;}</style>"
            case "copy":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-copy{display: none;}</style>"
            case "add":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-add{display: none;}</style>"
            case "line":
                "<style>div.component.br{display: none;}</style>"
            default:
                ""
            end
    end;
    html
end;
function UIShow(options : text) do
    var html := "";
    for items in split(options, ",") do
        html := html +
            switch items do
            case "print":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-print{display: inline;}</style>"
            case "trash":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-trash{display: inline;}</style>"
            case "copy":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-copy{display: inline;}</style>"
            case "add":
                "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-add{display: inline;}</style>"
            case "line":
                "<style>div.component.br{display: none;}</style>"
            default:
                ""
            end
    end;
    html
end

9 replies

null
    • Daniel_Berrow
    • 11 mths ago
    • Reported - view

    Looks to me like you can just

    UIHide("print,trash,add")
      • Alan_Cooke
      • 11 mths ago
      • Reported - view

       Thanks, I created a formula field and added that to it as the formula.  The result:

      <style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-print{display: none;}</style><style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-trash{display: none;}</style><style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-add{display: none;}</style>

      Icons still there.

      Clearly I am doing something wrong.

      • Sean
      • 11 mths ago
      • Reported - view

       You're going to kick yourself 😉

          end;
          html(html)
      end

      • Alan_Cooke
      • 11 mths ago
      • Reported - view

       I know :-).  And more so with this question.  Where do I put this? 

       said:
       end;     html(html) end
      • John_Halls
      • 11 mths ago
      • Reported - view

       Alan Cooke Hi Alan. It replaces the last three lines of your original code

      This

          end;
          html
      end

      Becomes this

          end;
          html(html)
      end

      Regards John

      • Alan_Cooke
      • 11 mths ago
      • Reported - view

      John HallsThank you!  I got that code from somewhere a long time ago and to date have never been able to use it :-)

      Here is the full 'corrected' code?

      "--- This controls the HUD icons top right ---";
      function UIHide(options : text) do
          var html := "";
          for items in split(options, ",") do
              html := html +
                  switch items do
                  case "print":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-print{display: none;}</style>"
                  case "trash":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-trash{display: none;}</style>"
                  case "copy":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-copy{display: none;}</style>"
                  case "add":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-add{display: none;}</style>"
                  case "line":
                      "<style>div.component.br{display: none;}</style>"
                  default:
                      ""
                  end
          end;
          html
      end;
      function UIShow(options : text) do
          var html := "";
          for items in split(options, ",") do
              html := html +
                  switch items do
                  case "print":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-print{display: inline;}</style>"
                  case "trash":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-trash{display: inline;}</style>"
                  case "copy":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-copy{display: inline;}</style>"
                  case "add":
                      "<style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-add{display: inline;}</style>"
                  case "line":
                      "<style>div.component.br{display: none;}</style>"
                  default:
                      ""
                  end
          end;
          html(html)
      end

    • Alan_Cooke
    • 11 mths ago
    • Reported - view

    Okay.  So I add a formula field and paste this in:  

    UIHide("print,trash,add")

    Nothing happens apart from the formula displays:

    <style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-print{display: none;}</style><style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-trash{display: none;}</style><style>div.hud-menu-button.i-32-24.i-light-grey.i-setting-add{display: none;}</style>

    All the icons listed still show.

      • Daniel_Berrow
      • 11 mths ago
      • Reported - view

       You added the html(html) to the second function, not the first, it needs to be added to both

      • Alan_Cooke
      • 11 mths ago
      • Reported - view

      Brilliant!  Works a treat.

Content aside

  • Status Answered
  • 11 mths agoLast active
  • 9Replies
  • 163Views
  • 4 Following