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

HI Laurent,



What is the difference between your script and mine?



I am just being curious about it. Knowing about it would help a lot.



Thanks,


Shahid


In the displayValue and value I've kept your $scope.data.u_choice_name but added || []. What this does is set that attribute to an empty arrway if the previous is undefined.



However, if your field should be empty at start then you should set thème as an empty array directly. Ex: displayValue: []


Hi Laurent,



You saved me. That is an awesome trick. That helped me a lot.  



I am very new to angular and Service Portal in Service now.



Can you help me in broadcasting the value selected on this field to other widgets?



Or can you provide me any document from where i can take help?



I wanted to post a new questions for it , but i was not sure if you will be able to view that and help me out.



This help would really push me a lot towards knowing more about service portal. I really appreciate your help here.



Thanks and RGDs,


Shahid


If you wanted me to see a new question you could have mentionned me (@user) shahid.



Here is a blog post to broadcast events between widgets: Using Events to Communicate Between Widgets - ServicePortal.io - Service Portal, CMS, and Custom App...



It is pretty well explained so you shouldn't have problem implementing this.


Hi Laurent,



I have added a new question (Broadcasting on Service Portal ) where in i have described the issue properly.



Can you please have a look and help me?



Thanks,


Shahid