- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2020 11:34 AM
Hey folks,
I'm trying to update an embedded widget using sn-record-picker to also display location next to the email. I've read several articles about dependencies or providers with widgets but that's all beyond me at the moment so I'm not sure where to start. I can't tell where this gets its data or where to update anything.
This article is the closest I've found, but it's described in general way that assumes you know the basics of what they are talking about.
Any help would be appreciated!
HTML:
<div ng-class="c.getClass()" ng-if="::options.layout !== 'separate_widget'">
<button tabindex="0" class="share-kb btn btn-default" ng-click="c.openModal()">Share Knowledge Article</button>
</div>
<div class="panel panel-default" ng-class="c.getClass()" ng-if="::options.layout === 'separate_widget'">
<button tabindex="0" class="share-kb btn btn-default" ng-click="c.openModal()">Send Knowledge Link</button>
</div>
<script>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Share Knowledge</h4>
</div>
<div class="panel-body wrapper-xl">
<div>Email to User(s)</div>
<div>
<sn-record-picker field="data.emailTo" table="'sys_user'" display-field="'name'" display-fields="'email'" value-field="'sys_id'" search-fields="'name'"
default-query="'active=true^nameISNOTEMPTY^emailISNOTEMPTY^emailENDSWITH@davita.com'" multiple="true" page-size="50" ></sn-record-picker>
</div>
<div style="margin-top:10px">
Message (link to article will automatically be included)
</div>
<div>
<textarea ng-model="data.message" rows="10" cols="60" />
</div>
</div>
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.shareArticle()">${Share Article}</button>
<button class="btn btn-primary" ng-click="c.closeModal()">${Cancel}</button>
</div>
</div>
</script>
Client Script:
function($uibModal, $scope) {
var c = this;
//Setup the input data so the client will get it
//populated for the picker
c.data.emailTo = {value:'',displayValue:''};
c.openModal = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate',
scope: $scope
});
};
c.shareArticle = function() {
//Make sure the required fields are filled out
if (c.data.emailTo.value == '') {
alert('You must select at least one person to send the article to.');
return;
}
//Pass it off to the server
c.server.update();
//Close the modal when it comes back
c.modalInstance.close();
};
c.closeModal = function() {
c.modalInstance.close();
};
}
/*
* With the requirement to allow a Distribution List to be used as an
* email address, a free form text field was added to the form. This
* method makes sure the address ends in a davita.com domain. Can be
* used for other validation in the future, but for now, this is all it does.
* NOTE: This requirement was pulled out on 2-26-2020
*
* param {string} sEmailAddress the email address to
* returns true if the email is valid or false otherwise
*/
function isValidEmail(sEmailAddress) {
var regex = /.+@davita.com$/i;
return regex.test(sEmailAddress);
}
Server Script:
(function() {
//Make sure something is being submitted and this isn't an initial load
if(input) {
//Build an object with additional information to pass to the mail script
//NOTE: The email notification will assume the list of users is in param1
var oOtherInformation = {};
oOtherInformation.userMessage = input.message;
//For now, set the From and Reply To to the user sending the information
var grCurrentUser = gs.getUser();
oOtherInformation.fromName = grCurrentUser.displayName;
oOtherInformation.fromEmail = grCurrentUser.email;
//Retrieve the article to send into the notification through the event
var grArticle = new GlideRecord('kb_knowledge');
grArticle.get($sp.getParameter('sys_id'));
//Finally, write the event
gs.eventQueue('davita.knowledge.share.notification', grArticle, input.emailTo.value, JSON.stringify(oOtherInformation));
}
})();
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2020 11:40 AM
Hi,
You need to mention either display-field or display-fields, not both.
Change this line
<sn-record-picker field="data.emailTo" table="'sys_user'" display-field="'name'" display-fields="'email'" value-field="'sys_id'" search-fields="'name'" default-query="'active=true^nameISNOTEMPTY^emailISNOTEMPTY^emailENDSWITH@davita.com'" multiple="true" page-size="50" ></sn-record-picker>
TO
<sn-record-picker field="data.emailTo" table="'sys_user'" display-fields="name, email,location" value-field="'sys_id'" search-fields="'name'" default-query="'active=true^nameISNOTEMPTY^emailISNOTEMPTY^emailENDSWITH@davita.com'" multiple="true" page-size="50" ></sn-record-picker>
Mark the comment as a correct answer and also helpful if it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2020 11:40 AM
Hi,
You need to mention either display-field or display-fields, not both.
Change this line
<sn-record-picker field="data.emailTo" table="'sys_user'" display-field="'name'" display-fields="'email'" value-field="'sys_id'" search-fields="'name'" default-query="'active=true^nameISNOTEMPTY^emailISNOTEMPTY^emailENDSWITH@davita.com'" multiple="true" page-size="50" ></sn-record-picker>
TO
<sn-record-picker field="data.emailTo" table="'sys_user'" display-fields="name, email,location" value-field="'sys_id'" search-fields="'name'" default-query="'active=true^nameISNOTEMPTY^emailISNOTEMPTY^emailENDSWITH@davita.com'" multiple="true" page-size="50" ></sn-record-picker>
Mark the comment as a correct answer and also helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 12:03 PM
Thank you for the reply.
Unfortunately that did not work. After the change the email box was unresponsive, and it resized it for some reason. Seems to have broken the look-up functionality of it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 02:12 PM
You were mostly there. The display-fields needed another set of '' around the fields to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 12:52 PM
Updated main section with more information from the widget.