-
Notifications
You must be signed in to change notification settings - Fork 909
Add incidenthelper snippet #1877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # IncidentHelper - getOpenIncidents | ||
|
|
||
| **Purpose:** Script Include (client-callable via GlideAjax) that returns a JSON array of active incident records. | ||
|
|
||
| **Usage Example** | ||
| ```js | ||
| var ga = new GlideAjax('IncidentHelper'); | ||
| ga.addParam('sysparm_name','getOpenIncidents'); | ||
| ga.getXMLAnswer(function(response){ | ||
| var list = JSON.parse(response || '[]'); | ||
| console.log(list); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
|
|
||
| // IncidentHelper - Script Include | ||
| var IncidentHelper = Class.create(); | ||
| IncidentHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, { | ||
| getOpenIncidents: function() { | ||
| var gr = new GlideRecord('incident'); | ||
| gr.addQuery('active', true); | ||
| gr.orderByDesc('sys_created_on'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you ordering descending on created on? Add this to your readme or a comment. |
||
| gr.setLimit(50); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you limiting to 50? Can you add this to the readme or include a comment? |
||
| gr.query(); | ||
|
|
||
| var list = []; | ||
| while (gr.next()) { | ||
| list.push({ | ||
| number: gr.getValue('number'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps you can include in the readme that this code now only pushes these attributes, and not the full Incident? |
||
| short_description: gr.getValue('short_description'), | ||
| sys_id: gr.getValue('sys_id'), | ||
| priority: gr.getValue('priority') | ||
| }); | ||
| } | ||
| return JSON.stringify(list); | ||
| }, | ||
| type: 'IncidentHelper' | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an example of what the output will look like? This will help others more easily understand what the code does.