Server Script If Statements
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2017 01:57 PM
Hi Experts, I'm trying to code a widget in Service Portal that serves up the correct Knowledge Article based on a person's role and location. There's an added layer of complexity when either the Role or Location or even both do not match. In those cases, I would like them to be served up with a default article. Here are some of the scenarios:
Roles | Location | Knowledge Articles |
Analyst | Washington, DC | KB 100 |
Analyst | New York, NY | KB 200 |
Analyst | San Francisco, CA | KB 300 |
Washington, DC | KB 400 | |
Analyst | KB 500 |
KB 100 - 300 are pretty self explanatory. If those combinations are the same as the User, then they get served with those articles. However, if a User is an Analyst but not in any of those three cities, I would like them to be served with KB 500. If a User is in DC but is not an Analyst, I want them to be served with KB 400. Finally, if the User is not an Analyst and not in one of those three cities, I want them to be served with KB 600.
I have a beginner's understanding of angular js, so getting the Knowledge Article values for the first three cases I think looks like this:
var hr = new GlideRecord('my_hr_cases');
hr.addQuery('hr_profile', gs.getUserID());
var ka = new GlideRecord('my_knowledge');
if(hr.hr_profile.user.location == ka.location && hr.position.role == ka.role)
{
data.article = ka.knowledge_article.getHTMLValue();
}
else if()
I'm stuck in how to expand on this so the other scenarios would provide the correct Knowledge Article values. My end step is to dynamically set URL based on these combinations with HTML:
<a id="KA_link" href="/kb_view.do?sysparm_article={{data.article}}" target="_blank">The Right Article</a>
Any help is greatly appreciated.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 06:52 AM
Hi Goran and joemccarty, yea unfortunately I'm on Helsinki. Will bring this up to the group though, that's a pretty awesome upgrade. Thanks!