Populate choice list in a widget in html field

Lavanya11
Kilo Sage

I have a field named "department types " of type "choice" in a  user-defined table. I need to populate this field into a dropdown field in my widget portal. I am aware of this snrecordpicker, but to my knowledge I thinks it works with field of type "reference". I have heard about this ng.options. But I couldn't find any proper docs. Could someone please help me

 

2 REPLIES 2

Namrata Khabale
Giga Guru

Hey  Lavanya,

 

You can populate the dropdown with options from client script using an array, and set the default selected option by setting the ng-model variable (c.data.personalDetail.LevelOfAccess) as the desired cell in the array.

 

Here is example code:

 

HTML:

<select id="mySelect" ng-init="c.data.personalDetail.LevelOfAccess = c.options[0]"   ng-model="c.data.personalDetail.LevelOfAccess" ng-options="option.name for option in options" required></select>

 

Client script:

 

c.options = [{

 

name: 'None',

 

value: 'none'

 

}, {

 

name: 'Admin',

 

value: 'admin'

 

}, {

 

name: 'User',

 

value: 'user'

 

}];

 

You can get the currently selected option from client script using c.data.personalDetail.LevelOfAccess.value

 

For more details Refer the Link below:

https://community.servicenow.com/community?id=community_question&sys_id=e0f7cb2ddb1cdbc01dcaf3231f96...

 

 

HOPE THIS HELPS!!!! 

 

Mark Correct and Helpful if you find my response Worthy!!!

 

Best Regards,


Namrata.

Lavanya11
Kilo Sage

The choice entries are already in the field "department types" in the user defineed table. I just want to load the choice entries/options in the dropdown. My question is how I populate that options from that table.  But here you are giving the options in the client script. I have the options already in the field