- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2017 07:47 AM
Hi Team,
How to get watch list for a particular ticket opened in service portal.
How to create a widget for this?
Any suggestions or ideas will help me a lot.
Thanks.
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2017 05:42 PM
Hi Nithin,
Here is a quick widget I made, however it does not have any save functionality so you would have to add that. Also the sn-record-picker does not allow to add an email address as the usual watch list field does. If your goal is only to display a read of what was set on creation than this would do the job by simply setting sn-disabled="true".
HTML:
<div ng-if="data.canRead" class="panel panel-primary b">
<div class="panel-heading">
<h4 class="panel-title pull-left">
${Watch list}
</h4>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<div class="text-center text-italic text-muted">
<sn-record-picker field="watch_list" sn-disabled="!data.canWrite" table="'sys_user'" display-field="'name'" search-fields="'name'" value-field="'sys_id'" default-query="'active=true'" multiple="true"></sn-record-picker>
</div>
</div>
</div>
Client script:
function($scope, spUtil) {
var c = this;
$scope.watch_list = {
displayValue: c.data.displayValue,
value: c.data.value,
name: 'watch_list'
};
}
Server script:
(function() {
var table = $sp.getParameter('table')
var sys_id = $sp.getParameter('sys_id')
var gr = new GlideRecord(table);
if(gr.get(sys_id)){
data.canRead = gr.watch_list.canRead();
data.canWrite = gr.watch_list.canWrite();
if(data.canRead){
data.displayValue = gr.getDisplayValue('watch_list');
data.value = gr.getValue('watch_list');
}
}
})();
I know this is incomplete but I hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2021 05:14 PM
I did a bit of digging, and there is actually old documentation on the subject. https://docs.servicenow.com/bundle/paris-application-development/page/script/useful-scripts/task/t_AddFldSrvcCatCkout.html
This old documentation can be adapted to the portal. So no need to use the special_instructions or a business rule.
In my modifications attempt I did not do anything to cache the value like the other values are, which means that if the checkout window is closed, the watch list value is lost unlike other values.
In the client script add your watch list object (I did put it just after var c = this)
c.watchList = {
displayValue: '',
value: '',
name: 'watch_list'
}
Update the additionParms of triggerCheckout function with:
var additionalParms = {'sysparm_requested_for': c.requestedFor.value,
'special_instructions': c.special_instructions,
'delivery_address': c.deliverTo,
'sysparm_processing_hint': 'setfield:request.watch_list=' + c.watchList.value
};
Update the else case where c.server.update() is used.
...
else {
c.data.delivery_address = c.deliverTo;
c.data.special_instructions = c.special_instructions;
c.data.requested_for = c.requestedFor.value;
c.data.watch_list = c.watchList.value;
...
In your server script, using the documentation I linked add script to set the hint of the first item of the cart.
...
if (data.action !== 'order_now') {
cartJS = new sn_sc.CartJS(cartName, '' + gs.getUser().getID());
if(localInput.watch_list){
var cartItemGr = new GlideRecord('sc_cart_item');
cartItemGr.addQuery('cart', cartJS.getCartID());
cartItemGr.query();
if(cartItemGr.next()){
cartItemGr.hints = "<hints><entry key='sysparm_processing_hint' value='setfield:request.watch_list=" + localInput.watch_list + "'/></hints>";
cartItemGr.update();
}
}
...
I hope it helps you and that you are able to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2021 02:22 AM
Hi Laurent,
This is awesome! Thank you so much it is working now!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2018 03:18 PM
//In the server script for that custom widget
//change this:
data.displayValue = dV == '' ? [] : dV;
data.value = sV == null ? [] : sV;
//to this:
data.displayValue = dV == '' ? "" : dV;
data.value = sV == null ? "" : sV;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2020 05:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2020 09:50 AM
Why doesn't ServiceNow create OOB widget that only shows your tasks that you have been added to the watchlist. Why is this so hard to do.