Need to add another field value to the kb_view UI page

bobbyd
Mega Contributor

I have a requirement that involves adding an additional field to the top section of the kb_view ui page.   Currently the Article, Published and Last Modified fields are available on the page.   I need to add a new field called Role, then query the Knowledge article to display the role that is listed.   I have attached a screen shot.   Has anyone done this before?

1 ACCEPTED SOLUTION

coolboy
Mega Expert

Hi Bobby Douglas


There is macro called kb_article_header u need to modifiy that but in that case u own it and in future relse u will not get Updates.So better to create a custom macro and call that in UI page.


And roles is a glide list so u might have to create a array and publish each element.


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">




  <div class="kb_article_header_short_description">$[kb.short_description.getDisplayValue()]</div>


  <!-- outputs an article's header info: number, publication date, modification date -->


  <div class="kb_article_header_info">


  <span style="font-weight:bold;">${gs.getMessage("Article")}:</span>$[SP]$[JS,HTML:kb.number]


  <span style="font-weight:bold;padding-left:8px;">$[kb.published.sys_meta.label]:</span>$[SP]$[kb.published.getDisplayValue()]


  <g2:evaluate var="jvar_updated_date">


  var dgo = kb.sys_updated_on.getGlideObject();


  var dt = new GlideDateTime(dgo);


  dt.getLocalDate().getDisplayValue();


  </g2:evaluate>


  <span style="font-weight:bold;padding-left:8px;">${gs.getMessage("Last modified")}:</span>$[SP]$[jvar_updated_date]


<span style="font-weight:bold;padding-left:8px;">${gs.getMessage("Roles")}:</span>$[kb.roles]


  </div>


</j:jelly>



Please mark ur question as marked .If it has helped u.


View solution in original post

5 REPLIES 5

coolboy
Mega Expert

Hi Bobby Douglas


There is macro called kb_article_header u need to modifiy that but in that case u own it and in future relse u will not get Updates.So better to create a custom macro and call that in UI page.


And roles is a glide list so u might have to create a array and publish each element.


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">




  <div class="kb_article_header_short_description">$[kb.short_description.getDisplayValue()]</div>


  <!-- outputs an article's header info: number, publication date, modification date -->


  <div class="kb_article_header_info">


  <span style="font-weight:bold;">${gs.getMessage("Article")}:</span>$[SP]$[JS,HTML:kb.number]


  <span style="font-weight:bold;padding-left:8px;">$[kb.published.sys_meta.label]:</span>$[SP]$[kb.published.getDisplayValue()]


  <g2:evaluate var="jvar_updated_date">


  var dgo = kb.sys_updated_on.getGlideObject();


  var dt = new GlideDateTime(dgo);


  dt.getLocalDate().getDisplayValue();


  </g2:evaluate>


  <span style="font-weight:bold;padding-left:8px;">${gs.getMessage("Last modified")}:</span>$[SP]$[jvar_updated_date]


<span style="font-weight:bold;padding-left:8px;">${gs.getMessage("Roles")}:</span>$[kb.roles]


  </div>


</j:jelly>



Please mark ur question as marked .If it has helped u.


kb_view_custom.xml u can modify this


bobbyd
Mega Contributor

Thank you so much Ankush, this worked perfectly!


SnowDEV2
Kilo Expert

 I have a similar requirement to show affected region field value when search for knowledge on incident short description

I used below line of code in kb_article_header ui macro but no luck. Is there any other modification required in order to achieve this requirement?

 

<span style="font-weight:bold;padding-left:8px;">${gs.getMessage("Affected Region")}:</span>$[kb.u_affected_region.getDisplayValue()]