Service Portal Input Directives

Brian Treichel
Tera Guru

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

1 ACCEPTED SOLUTION

LaurentChicoine
Tera Guru

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'


        };


}


View solution in original post

14 REPLIES 14

larstange
Mega Sage

Hi



Take a look at the "Slush Bucket" widget. The ootb version is very simple, but you can modify it to be able to receive input about table and condition an then you can include it in other widgets.


Thanks for the response!



I was thinking something more along the lines of the List Collector that shows up for Catalog Items in Service Portal. The one with the single input box that adds each item to it on the same line. The reason being that the list I am using would quite long, so I would rather the typeahead be used to find it.



It would be nice if there was a way to figure out what directive they used.


LaurentChicoine
Tera Guru

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'


        };


}


Awesome, thanks a lot. Is this documented anywhere? If not, are there any other variable types that can be used like this?