- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 08:55 AM
Hi All,
I created two knowledge bases in my environment 1 is KEDB and 2nd is IKDB(incident knowledge database). each knowledge as a different field so thats why i created UI policys .. its ok for me in form level..
issue with
whenever i published KEDB articles ,,KEDB field is visible and same time IKDB field is visible,,,,here we are using UI macros.. So, here how to create if condition in macros.
For example: If Knowledge base = KEDB selects visible only KEDb fields
{
else knowledge base =IKDB visible only for IKDB fields
}
Please find the below script how to write IF Else condition ?
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:choose>
<j:when test="${knowledgeRecord.article_type != 'wiki'}">
<div id="article" class="snc-article-content-text">
<b>
KB Number:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.number]</g2:no_escape>
<br/>
<b>
Problem Number:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_related_problem]</g2:no_escape>
<br/>
<b>
Known Error:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_known_error]</g2:no_escape>
<br/>
<b>
Workaround fix:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_workaround_fix]</g2:no_escape>
<br/>
<b>
Permanent fix:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_permanent_fix]</g2:no_escape>
<br/>
<b>
Third Party involved:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_third_party_involved]</g2:no_escape>
<br/>
<b>
Support team involved:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_support_team_involved]</g2:no_escape>
<br/>
<b>
Risk number:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_risk_number]</g2:no_escape>
<br/>
<b>
Additional comments:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_additional_comments]</g2:no_escape>
<br/>
</div>
</j:when>
<j:otherwise>
<div id="article" class="snc-article-content-text knowledge-wiki-text">
<g2:no_escape>$[NS:glideWikiModel.render(knowledgeRecord.wiki)]</g2:no_escape>
</div>
</j:otherwise>
</j:choose>
</j:jelly>
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 09:41 AM
The general syntax of the if statement is like this:
<j:if test="condition" >
<!-- this code gets run -->
</j:if>
In your case, the condition is going to be something like:
<j:if test="${kb_knowledge.kb_knowledge_base.getDisplayValue() == 'KEDB'">
<!-- Show the three fields -->
</j:if>
<j:if test="${kb_knowledge.kb_knowledge_base.getDisplayValue() == 'IKDB'">
<!-- Show the other three fields -->
</j:if>
THIS IS UNTESTED CODE. YOU NEED TO TEST AND ADJUST AS NECESSARY FOR YOUR CONDITIONS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 10:37 AM
Thank you chuck
Its working fine , thanks for your help.
Regards,
Naresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 07:37 AM
Hi chuck,
As you aware the above code for knowledge base,
I need small help again,
I rejected approvals in knowledge article, the rejected article also is visible in end users in self service.
I need to control only visible approvals articles.
Please suggest me where i need change the above code.
Regards,
Naresh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 10:02 AM
Try this. This is assuming your Title for knowledge bases are ":KEDB" and "IKDB"
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:choose>
<j:when test="${knowledgeRecord.article_type != 'wiki'}">
<div id="article" class="snc-article-content-text">
<b>
KB Number:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.number]</g2:no_escape>
<br/>
<b>
Problem Number:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_related_problem]</g2:no_escape>
<br/>
<j:if test="${knowledgeRecord.kb_knowledge_base.getDisplayValue()=='KEDB'}">
<b>
Known Error:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_known_error]</g2:no_escape>
<br/>
<b>
Workaround fix:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_workaround_fix]</g2:no_escape>
<br/>
<b>
Permanent fix:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_permanent_fix]</g2:no_escape>
<br/>
</j:if>
<b>
Third Party involved:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_third_party_involved]</g2:no_escape>
<br/>
<j:if test="${knowledgeRecord.kb_knowledge_base.getDisplayValue()=='IKDB'}">
<b>
Support team involved:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_support_team_involved]</g2:no_escape>
<br/>
<b>
Risk number:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_risk_number]</g2:no_escape>
<br/>
<b>
Additional comments:
</b>
<br/> <g2:no_escape>$[NS:knowledgeRecord.u_additional_comments]</g2:no_escape>
<br/>
</j:if>
</div>
</j:when>
<j:otherwise>
<div id="article" class="snc-article-content-text knowledge-wiki-text">
<g2:no_escape>$[NS:glideWikiModel.render(knowledgeRecord.wiki)]</g2:no_escape>
</div>
</j:otherwise>
</j:choose>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 10:36 AM
Hi Abhinav
thanks for your help .its working fine. but correct button is not visible here its visible help yes or no
Regards,
naresh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 10:37 AM
Because, you have already marked Chuck's response as correct. You can only mark one response as correct Glad to know it is working now.