I wanted to create a multiselect type field on widget can anyone help on this question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 07:13 AM
Hi All,
I wanted to create a multi select/list collector type field(not checkbox) values to be reference to choices table, could any one help on this
Thanks,
MD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2024 01:52 AM
Hello,
Here are some steps that might help you. If the Multi-select/List field is not created on target required table, please do so as first step (provide the reference as sys_choice table as required)
HTML of the Widget looks something like this:
<div>
<label for="multiSelect">Select Choices</label>
<select id="multiSelect" class="form-control" multiple>
<option ng-repeat="choice in c.data.choices" value="{{choice.value}}">
{{choice.label}}
</option>
</select>
</div>
Define a Client side as follows:
(function() {
var choices = [];
var grChioce = new GlideRecord('sys_choice');
grChioce.addQuery('name', <yourTable>);
grChioce.addQuery('element', <yourField>);
grChioce.query();
while (grChioce.next()) {
choices.push({
value: grChioce.value.toString(),
label: grChioce.label.toString() //adding Label is required for display purpose
});
}
data.choices = choices;
})(); //self calling function, no need to call again
Hope this helps!
Regards, Akash
_____________________________________________________________________________
Please mark it as helpful👍 or Accept Solution✔️ based on the response to your query.
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2024 01:09 AM