- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2016 08:30 AM
Hello,
I am trying to create an input in a widget that functions the same as a List Collector (Glide List) catalog variable, but I can't tell if there is a directive out there that I can use.
I know that, for Reference Variables, there is a sn-record-picker directive, but I'm not sure if there are directives for the other types. Are there any other "Glide" types are there directives for, i.e. Lists/Duration, Date/Time, etc? I'm thinking they must be somewhere. The only place that I would think to find them would be in the Catalog Item widget, but that uses another directive <sp-cat-item item='item' /> to gather the variables, which I'm not sure I can even access.
Any ideas?
Thanks,
Brian
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2017 04:18 PM
Hi Brian to make a Glide list field, you can use the sn-record-picker directive. Here is an example:
HTML:
<sn-record-picker field="watch_list" table="'sys_user'" display-field="'name'" value-field="'sys_id'" default-query="'active=true'" multiple="true"></sn-record-picker>
Client script (you must set the field inside your client script):
function($scope, spUtil) {
var c = this;
$scope.watch_list = {
displayValue: variable_with_display_value_comma_separated, //This should not be null
value: variable_with_value_comma_separated, //This should not be null
name: 'watch_list'
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2017 08:37 AM
Of my knowledge it is only unofficially documented (however it is used in OOTB example widgets):
As for the mutliple attribute I did not see it documented anywhere and found it by reverse engineering.
As for other directives like this, I did not see documentation for them but here is a quick list but I did not look into how to use them:
- sn-user-profile
- sn-avatar-popover
- sn-avatar
- sn-user-avatar
- sn-group-avatar
- sn-choice-list
- sn-reference-picker
- sn-select-basic
- sn-table-reference
- sn-field-reference
- sn-sync-with
- sn-image-uploader
- sn-link-content
- sn-link-content-youtube
- sn-link-content-soundcloud
Also there seems to be directives for every type of fields but they don't seems to be made to be used stand alone as I was not able to properly use them without having the whole form widget loaded (sp-model).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 09:21 AM
Hi Laurent,
I was able to implement your code and i am still stuck in the issue where in i am not able to select the values from the watchlist however i am able to see the values in the drill down.
This is a bit urgent so any help would do.
Thanks,
Shahid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 05:35 PM
Hi Shahid,
I remember facing this issue. However I don't remember how to reproduce it. Could you look at your javascript console for any error.
Also maybe try to post your full widget code so I can test it.
Here is another topic which has examples of the multiple value reference field: How to get a watch list in widget in Service Portal ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2017 11:29 PM
HI Laurent,
Below is the code:-
HTML:-
<div class="filterband">
<div class="filter-liner container">
<div class="panel panel-default">
<div class="col-sm-2">
Select Choice
</div>
</div>
<div class="col-sm-7">
<sn-record-picker field="watch_list" table="'u_c_choice_definition'" display-field="'u_choice_name'" value-field="'sys_id'" default-query="'u_choice!=Retired'" search-fields="'u_choice_name'" multiple="true"></sn-record-picker>
</div>
</div>
</div>
Client Script:-
$scope.watch_list = {
displayValue: $scope.data.u_choice_name,
value: $scope.data.sys_id,
name: 'watch_list'
};
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'u_choice_name'){
$scope.data.u_choice_name = parms.newValue;
$scope.server.update();
}
});
Server Script:- No Server Script
I appreciate your help here.
Thanks,
Shahid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 09:07 AM
Hi,
Your $scope.data seems to be undefined which is causing error in the javascript console.
I'm not sure what you are trying to achive with the $scope.data.u_choice_name but as stated the value and display value should not me null.
Just to make it work you should try the following client script:
function($scope, spUtil) {
$scope.watch_list = {
displayValue: $scope.data.u_choice_name || [],
value: $scope.data.sys_id || [],
name: 'watch_list'
};
$scope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'u_choice_name'){
$scope.data.u_choice_name = parms.newValue;
$scope.server.update();
}
});
}