Skip to content

displaying and updating notes via portal. The list is unaware of the … #6

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Generated files
This repository contains generated files and a checksum.

**Do not edit the files in this repository outside of an instance of ServiceNow.**

If you find yourself unable to import your repository due to the presence of files edited outside an instance of ServiceNow, merge commits that mix files from different revisions, or other data that does not match the checksum, you may recover using either of the following techniques:
* Remove the problem commits:
1. Clone your repository to a personal computer with the git command line tools installed and open a git command prompt in the repository root
Expand Down
10 changes: 10 additions & 0 deletions sn_source_control.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#############################################################
# This ServiceNow-created file contains the path to the app in this repo
# path=<path to app content in your repo>
# For example, if the app content resides in a folder named x_my_custom_app, the path value would be:
# path=/x_my_custom_app
# Update the path value when you move the app to a new repo location.
############################################################
#
#Sat Mar 16 11:55:56 PDT 2024
path=
32 changes: 32 additions & 0 deletions update/sp_instance_9c1b51a4c3c94e104de6bdbc05013141.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sp_instance">
<sp_instance action="INSERT_OR_UPDATE">
<active>true</active>
<class_name/>
<color>default</color>
<css/>
<glyph/>
<id/>
<order>1</order>
<roles/>
<short_description/>
<size>md</size>
<sp_column display_value="1">43295ae1094232007f44e1046c8ff615</sp_column>
<sp_widget display_value="Notes List">59f919e0c3c94e104de6bdbc05013114</sp_widget>
<sys_class_name>sp_instance</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-03-16 17:25:19</sys_created_on>
<sys_id>9c1b51a4c3c94e104de6bdbc05013141</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name/>
<sys_package display_value="CreateNotes" source="x_snc_createnotes">df5fd9a5090232007f44e1046c8ff69f</sys_package>
<sys_policy/>
<sys_scope display_value="CreateNotes">df5fd9a5090232007f44e1046c8ff69f</sys_scope>
<sys_update_name>sp_instance_9c1b51a4c3c94e104de6bdbc05013141</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-03-16 17:25:19</sys_updated_on>
<title/>
<url/>
<widget_parameters/>
</sp_instance>
<sys_translated_text action="delete_multiple" query="documentkey=9c1b51a4c3c94e104de6bdbc05013141"/>
</record_update>
32 changes: 32 additions & 0 deletions update/sp_instance_fc1b5da0c3c94e104de6bdbc0501317e.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sp_instance">
<sp_instance action="INSERT_OR_UPDATE">
<active>true</active>
<class_name/>
<color>default</color>
<css/>
<glyph/>
<id/>
<order>1</order>
<roles/>
<short_description/>
<size>md</size>
<sp_column display_value="2">cf295ae1094232007f44e1046c8ff616</sp_column>
<sp_widget display_value="Notes Body">6d6a1964c3c94e104de6bdbc05013192</sp_widget>
<sys_class_name>sp_instance</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-03-16 17:25:21</sys_created_on>
<sys_id>fc1b5da0c3c94e104de6bdbc0501317e</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name/>
<sys_package display_value="CreateNotes" source="x_snc_createnotes">df5fd9a5090232007f44e1046c8ff69f</sys_package>
<sys_policy/>
<sys_scope display_value="CreateNotes">df5fd9a5090232007f44e1046c8ff69f</sys_scope>
<sys_update_name>sp_instance_fc1b5da0c3c94e104de6bdbc0501317e</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-03-16 17:25:21</sys_updated_on>
<title/>
<url/>
<widget_parameters/>
</sp_instance>
<sys_translated_text action="delete_multiple" query="documentkey=fc1b5da0c3c94e104de6bdbc0501317e"/>
</record_update>
77 changes: 77 additions & 0 deletions update/sp_widget_59f919e0c3c94e104de6bdbc05013114.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sp_widget">
<sp_widget action="INSERT_OR_UPDATE">
<category>custom</category>
<client_script><![CDATA[api.controller=function($rootScope,$scope) {
/* widget controller */
var c = this;
c.selectItem = function(idx) {
var id = c.data.notes[idx].sys_id;
console.log('Note ID: ' + id);
$rootScope.noteID = id;
$rootScope.$emit('selectNote', id);
}
}]]></client_script>
<controller_as>c</controller_as>
<css/>
<data_table>sp_instance</data_table>
<demo_data/>
<description/>
<docs/>
<field_list/>
<has_preview>true</has_preview>
<id>notes_list</id>
<internal>false</internal>
<link><![CDATA[function link(scope, element, attrs, controller) { }]]></link>
<name>Notes List</name>
<option_schema/>
<public>false</public>
<roles/>
<script><![CDATA[(function() {
//create an array to populate with notes
data.notes = [];
var noteGR = new GlideRecord('x_snc_createnotes_note');
noteGR.addQuery('user', gs.getUser().getID());
noteGR.orderByDesc('sys_created_on');
noteGR.query();
while (noteGR.next()) {
var noteObj = {};
//use service portal helper method to get some display values
$sp.getRecordDisplayValues(noteObj, noteGR, 'number,title,sys_id');
//get the first 20 characters of the description
noteObj.note = noteGR.getValue('note').slice(0,20);
//push the populated obj into the array
data.notes.push(noteObj);
}
})();]]></script>
<servicenow>false</servicenow>
<sys_class_name>sp_widget</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-03-16 17:20:28</sys_created_on>
<sys_id>59f919e0c3c94e104de6bdbc05013114</sys_id>
<sys_mod_count>5</sys_mod_count>
<sys_name>Notes List</sys_name>
<sys_package display_value="CreateNotes" source="x_snc_createnotes">df5fd9a5090232007f44e1046c8ff69f</sys_package>
<sys_policy/>
<sys_scope display_value="CreateNotes">df5fd9a5090232007f44e1046c8ff69f</sys_scope>
<sys_update_name>sp_widget_59f919e0c3c94e104de6bdbc05013114</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-03-16 18:30:32</sys_updated_on>
<template><![CDATA[<div class="panel panel-default">
<div class="panel-heading clearfix">
<h3 class="panel-title pull-left">
${Notes}
</h3>
</div>
<div class="list-group">
<a class="list-group-item" ng-click="c.selectItem($index)" ng-repeat="note in data.notes">
<h4 class="list-group-item-heading">
{{note.title}}
</h4>
<p class="list-group-item-text">
{{note.note}}
</p>
</a>
</div>
</div>]]></template>
</sp_widget>
</record_update>
87 changes: 87 additions & 0 deletions update/sp_widget_6d6a1964c3c94e104de6bdbc05013192.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sp_widget">
<sp_widget action="INSERT_OR_UPDATE">
<category>custom</category>
<client_script><![CDATA[api.controller=function($scope,$rootScope) {
/* widget controller */
var c = this;

$rootScope.$on('selectNote', function(event,data) {
c.server.get({
action: 'getNote',
noteID: $rootScope.noteID
}).then(function(r) {
c.data.title = r.data.note.title;
c.data.note = r.data.note.note;
c.data.noteID = r.data.note.sys_id;
});
});

c.updateNote = function(updateType) {
c.server.get({
action: 'updateNote',
noteID: c.data.noteID,
noteBody: c.data.note,
noteTitle: c.data.title
}).then(function(r) {
});
}
}]]></client_script>
<controller_as>c</controller_as>
<css/>
<data_table>sp_instance</data_table>
<demo_data/>
<description/>
<docs/>
<field_list/>
<has_preview>false</has_preview>
<id>notes_body</id>
<internal>false</internal>
<link><![CDATA[function link(scope, element, attrs, controller) { }]]></link>
<name>Notes Body</name>
<option_schema/>
<public>false</public>
<roles/>
<script><![CDATA[(function() {
/* populate the 'data' object */

if (input && input.noteID) {
var note = new GlideRecord('x_snc_createnotes_note');
if (note.get(input.noteID)) {
if (input.action == 'getNote') {
data.note = {};
$sp.getRecordValues(data.note, note, "title, note, sys_id");
} else if (input.action == 'updateNote') {
note.title = input.noteTitle;
note.note = input.noteBody;
note.update();
}
}
}
})();]]></script>
<servicenow>false</servicenow>
<sys_class_name>sp_widget</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-03-16 17:22:23</sys_created_on>
<sys_id>6d6a1964c3c94e104de6bdbc05013192</sys_id>
<sys_mod_count>7</sys_mod_count>
<sys_name>Notes Body</sys_name>
<sys_package display_value="CreateNotes" source="x_snc_createnotes">df5fd9a5090232007f44e1046c8ff69f</sys_package>
<sys_policy/>
<sys_scope display_value="CreateNotes">df5fd9a5090232007f44e1046c8ff69f</sys_scope>
<sys_update_name>sp_widget_6d6a1964c3c94e104de6bdbc05013192</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-03-16 18:49:54</sys_updated_on>
<template><![CDATA[<div class="panel panel-default" ng-show="c.data.noteID">
<div class="panel-heading clearfix">
<div class="row">
<div class="col-md-12">
<input class="form-control" id="note-title" ng-model="c.data.title" ng-change="c.updateNote('title')" ng-model-options="{debounce: 1000}"/>
</div>
</div>
</div>
<div class="panel-body">
<textarea class="form-control" id="note-body" ng-model="c.data.note" ng-change="c.updateNote('body')" ng-model-options="{debounce: 1000}" ></textarea>
</div>
</div>]]></template>
</sp_widget>
</record_update>
22 changes: 22 additions & 0 deletions update/sys_scope_privilege_8b7e6d68c30d4e104de6bdbc0501311a.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_scope_privilege">
<sys_scope_privilege action="INSERT_OR_UPDATE">
<operation>execute</operation>
<source_scope display_value="CreateNotes">df5fd9a5090232007f44e1046c8ff69f</source_scope>
<status>allowed</status>
<sys_class_name>sys_scope_privilege</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2024-03-16 18:50:09</sys_created_on>
<sys_id>8b7e6d68c30d4e104de6bdbc0501311a</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_name>GlideRecord.update</sys_name>
<sys_package display_value="CreateNotes" source="x_snc_createnotes">df5fd9a5090232007f44e1046c8ff69f</sys_package>
<sys_policy/>
<sys_scope display_value="CreateNotes">df5fd9a5090232007f44e1046c8ff69f</sys_scope>
<sys_update_name>sys_scope_privilege_8b7e6d68c30d4e104de6bdbc0501311a</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_updated_on>2024-03-16 18:50:09</sys_updated_on>
<target_name>GlideRecord.update</target_name>
<target_scope display_value="Global">global</target_scope>
<target_type>scriptable</target_type>
</sys_scope_privilege>
</record_update>