Create a multiselect/list collector field in a custom Widget and map to a table in service now

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2018 02:53 PM
I am trying to create a list collector field in a custom form widget.
I have populated the list using an array in the server script.
However when I try to map this form widget to the table field in backend of servicenow the value is blank. If I remove the *multiple="multiple" in line 3 below, I am able to select one item from the dropdown and this value gets mapped to the table field correctly. Does anyone know a good way to map a multiselect field on the portal to a list collector in the system?
HTML
<div class="form-group col-lg-4">
<label class="col-lg-4 control-label" for="specialty">Specialties:</label>
<select id="specialty" name="specialty" class="form-control" multiple="multiple"
ng-model="c.specialty"
ng-options="specialty.name for specialty in c.data.specialties">
</select>
</div>
Client script
c.data.specialty = c.specialty;
c.data.specialtySysId = c.data.specialty.sys_id;
Server script
data.specialties = [];
var grSpecialty = new GlideRecord('u_contract_specialties');
grSpecialty.orderBy('u_specialty');
grSpecialty.addEncodedQuery('u_type=specialty');
grSpecialty.query();
while(grSpecialty.next()){
data.specialties.push({
'name': grSpecialty.getValue('u_specialty'),
'sys_id': grSpecialty.getUniqueValue()
});
if(input) {
var grNewReq = new GlideRecord('u_joinder');
grNewReq.initialize();
grNewReq.setValue('u_specialties', input.specialtySysId);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2018 05:33 PM
Is this on a catalog item? Can you provide how to set this up so others can try it to help you?
When asking a question about a problem caused by your code, you will get much better answers if you provide code (which you did) people can use to reproduce the problem. That code should be…
- Minimal – Use as little code as possible that still produces the same problem
- Complete – Provide all parts needed to reproduce the problem
- Verifiable – Test the code you're about to provide to make sure it reproduces the problem