4 Replies Latest reply on Feb 14, 2019 5:43 AM by Nicole Schackert

    HTML

    VINCE RINNER
      Share This:

      So I want to be able to click on a hyperlink/html code to open our Dynamics NAV application customer card for a specific customer.

      I created a HTML form control with the code below and it works if I hard code a customer number in there "C012345". It opens our NAV application on that specific customer card. This is good.

       

       

      But what I want it to do is to insert the [nav_customer_number___cust] field into the control. This will get the current customer number in the ticket then open our NAV application with that specific customer.  Anyone know of a way to do this?

        • 1. Re: HTML
          Christopher Bradfield

          I wouldn’t expect the system to copy the vaule over on sceeen. You would need to use a on screen rule to try to concan the value (not sure if it would work) or write you on code to do the work.

          I dont think a onscreen rule wil work but that’s the only way OTB that I can think of doing it.

          • 2. Re: HTML
            Nicole Schackert

            You can not solve this with HTML. The field always has a different ID. If you go to the label you get problems if you have several tickets open at the same time.

            You need a Java for that. Something like this: (This goes to the ticket ID, you have to adjust it for you)

             

            (function () {

             

             

              var PATCH_ELEMENT_NAME = "********";

              var URL = "*****************************View=c739f09a-7bc3-480b-8a95-235b9344966e&FilterField1=Ticketnummer&FilterValue1={{id}}";

              var LABEL = "**********";

             

             

              var LinkPatcher = function LinkPatcher(patchElementName, url, label) {

                var _this = this;

             

             

                this.patchElementName = patchElementName;

                this.url = url;

                this.label = label;

             

             

                this.resolveUrlParameter = function (id) {

                  return _this.url.replace(/{{.+}}/, id);

                };

             

             

                this.buildLinkId = function (baseId) {

                  return "refLink-" + baseId;

                };

             

             

                this.removeByIdIfExists = function (id) {

                  var elementToRemove = document.getElementById(id);

                  if (elementToRemove) elementToRemove.parentNode.removeChild(elementToRemove);

                };

             

             

                this.createLink = function (id, element) {

                  var content = element.value || element.innerHTML;

                  if (!content) return;

                  var newLink = document.createElement("a");

                  newLink.href = _this.resolveUrlParameter(content);

                  newLink.id = id;

                  newLink.innerText = _this.label;

                  newLink.target = "_blank";

                  element.parentNode.insertAdjacentElement("beforeend", newLink);

                };

             

             

                this.keyUpHandler = function (event) {

                  var id = _this.buildLinkId(event.srcElement.id);

                  _this.removeByIdIfExists(id);

                  _this.createLink(id, event.srcElement);

                };

             

             

                this.findFootprintsElements = function () {

                  return [].slice.call(document.getElementsByTagName("label")).filter(function (entry) {

                    return entry.innerHTML.indexOf(_this.patchElementName) > -1;

                  }).map(function (entry) {

                    return entry.id.replace('-labelEl', '-bodyEl');

                  }).filter(function (newElementId) {

                    return newElementId && newElementId != '';

                  }).map(function (newElementId) {

                    return document.getElementById(newElementId).lastElementChild;

                  }).filter(function (newElement) {

                    return newElement;

                  });

                };

             

             

                this.init = function () {

                  var footprintsElements = _this.findFootprintsElements();

                  footprintsElements.forEach(function (control) {

                    control.removeEventListener("keyup", _this.keyUpHandler.bind(_this));

                    control.addEventListener("keyup", _this.keyUpHandler.bind(_this));

                    var newId = _this.buildLinkId(control.id);

                    _this.removeByIdIfExists(newId);

                    _this.createLink(newId, control);

                  });

                };

              };

              var linkPatcher = new LinkPatcher(PATCH_ELEMENT_NAME, URL, LABEL);

              linkPatcher.init();

            })();

            • 3. Re: HTML
              VINCE RINNER

              Apparently I need to learn more Java! Thanks for the detailed reply. I'll work on it and see but a simple cut and paste of your code didn't show anything.

              • 4. Re: HTML
                Nicole Schackert

                No copy and paste will not work in your case. This function refers to building a URL with the ticket number. The function has no Patch_Element_Name. no full URL and no label. The label in your case would be nav_customer_number___cust, if your field on the surface is also named.

                What I noticed in these functions is that the CodeBox where the function is must be under the field declared in the label field.

                So the CodeBox should be under your nav_customer_number___cust field.

                No idea why, but if the box is somewhere else, sometimes it does not work.