How to add Breadcrumbs on Incident table?

keerthilatha
Tera Expert

Hi Team,

How to add Breadcrumbs on Incident table? Actually I need breadcrumb on incident table, the parent table is Intake (ticket)

TKT0012345 > INC0012345

For this we need to create the following scripts:

1) UI Formatter (Incident Parent Breadcrumbs)

2) UI Macro (intake_parent_crumbs: By using OOB UI macro I've updated the script):

<?xml version="1.0" encoding="utf-8"?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
        <j2:if test="$[!${ref_parent}.isNewRecord() ${AND} !${ref_parent}.parent.nil()]">
              <g2:evaluate var="jvar_crumbs">
                      //get real glide record
                      var gr = new GlideRecord(${ref_parent}.getTableName());
                      gr.get(${ref_parent}.getUniqueValue());

                      //parent crumb functions - script include
                      var pc = new IncidentParentCrumbs(gr);
                      var crumbs = pc.getCrumbs();
                      crumbs;
              </g2:evaluate>
              <j2:if test="$[!jvar_crumbs.nil()]">
                      <td class="breadcrumb_container">
                      <g2:no_escape>
                              ${gs.getMessage("Parents")}: $[jvar_crumbs]
                      </g2:no_escape>
                      </td>
              </j2:if>
      </j2:if>
</j:jelly>

****************************************************************************************************

3) Script Include (IncidentParentCrumbs):

/*
* Called from incident Parent Breadcrumbs formatter via the intake_parent_crumbs ui macro.
* Used to show the hierarchy of parent records.
*/
var IncidentParentCrumbs = Class.create();
IncidentParentCrumbs.prototype = Object.extendsObject(ParentCrumbs, {

      /**
      * get the breadcrumb string with html formatting
      */
      getCrumbs: function() {
              if (!this.child || !this.child.isValidRecord()) {
                      return;
              }
              if (!this._hasValidParent(this.child)) {
                      return;
              }

              this._addCrumb(this.child, false);
              this._buildParentCrumb(this.child);

              return this.crumbs;
      },

      _buildParentCrumb: function(gr) {
              var parent = this._getParent(gr);
              this._addCrumb(parent, true);

              if (this._hasValidParent(parent)) {
                      //check for parent limit
                      if (this.limitCounter >= this.limit) {
                              gs.log("IncidentParentCrumbs - parent count limit (" + this.limit + " reached while processing: " + this.child.getDisplayValue());
                              this._addTooManyParentsInfo();
                              return;
                      }

                      //check for recursion
                      if (this.recordsSeen[parent.getUniqueValue()]) {
                              gs.log("IncidentParentCrumbs parent recursion found while processing: " + this.child.getDisplayValue());
                              return;
                      }

                      //track parents processed
                      this.recordsSeen[parent.getUniqueValue()] = true;

                      //increment counter
                      this.limitCounter++;

                      //process the parent
                      this._buildParentCrumb(parent);
              }
      },

      _getParentField: function(gr) {
              return (gr.getTableName() == "incident" ? "intake" : "parent");
      },

      _hasValidParent: function(gr) {
              return JSUtil.notNil(gr.getValue(this._getParentField(gr)));
      },

      _getParent: function(gr) {
              return gr[this._getParentField(gr)].getRefRecord();
      },

      type: "IncidentParentCrumbs"

});

But, I'm getting following error on Incident form:

find_real_file.png

Please help on this issue, and let me know if any issues

3 REPLIES 3

nayanawadhiya1
Kilo Sage

Hey,



You want create FILTERs?


If yes, then goto System Definition -> Filters


Create New Filters for INCIDENT TABLE.


Thank you for your quick response.



But, I don't want filters, I need breadcrumb on incident form like RITM and Task. Please see the below screenshot for the same:



find_real_file.png



Thanks & Regards,


Latha


Have You check on Form Layout for Breadcrumb in Incident Form.


find_real_file.png