Mobile Multiple Choice field

Pedro Grilo1
Mega Sage

Hi all,

 

I am working on a request to have a Choice field displayed on a input screen in the Mobile Agent app.

My field is a List field with a specific set of choices:

PedroGrilo1_0-1695397648570.png

 

I added it to one input screen as a Choice with MultiSelect set to true, I can do the multiple choice selection and save it without any problems. However, when I go back to the input screen, the choices are not pre-selected.

I have a variable that is getting the existing choice list but it doesn't work.

 

I have these input configurations:

PedroGrilo1_2-1695398756855.png

And the variable is getting data from the field:

PedroGrilo1_3-1695398818531.png

 

Any ideas?

 

Thanks in advance!

 

 

 

 

4 REPLIES 4

Zachi
Tera Contributor

I face exact same issue.

Did you find a solution?

Hi!

 

I found no solution for the exact behavior.

As a workaround, I have set the Input Type to Reference, and set the the attributes on the input to lookup to search on the sys_choice table for the dictionary entry.

PedroGrilo1_0-1730372875093.png

I hope it helps!

Pedro

SN Arch Guy
Giga Guru

I'm seeing a similar issue I think, I can't get Incident Category and Subcategory to work on my mobile form, even though other choice fields work just fine. I think the only distinction is that both Category and Subcategory are dependent on other fields and the other choice fields are not. See my post at Solved: While creating new incident in Now mobile app, Cat... - ServiceNow Community for more detail.

 

I'm thinking the workaround shared in this post, to use a reference field, might work. How do you write the condition so that it uses another mobile input field? For example, the Subcategory reference condition would have to use the value selected for Category. Can you share screen prints of that?

camiloza
Tera Contributor

Hi, 

Not sure exactly of the behaviour of your choice field. However, if it helps use a data source. 

If you navigate from the Mobile App builder, after selecting your scope, go to all records and look for data source. 

There you can create a query to get each of the actual selected items and set them back to the choice or reference field. 

On the attributes you would need to define 2 specific one. The DataSourceId which would provide you a list of the data Sources that you have created, and select the one you used. And then define a "ElementIdentifier" which is another attribute, which is basically any name you want to give to this element to use in the data source code. 


(function DataSource(valuesMapper, context) {
var gr = new GlideRecord('sys_user'); 
gr.addEncodedQuery('sys_idIN' + context.watch_list);
gr.query();

while (gr.next()) { // Could also be itetaring muliple records from the same table using the 'while' iterator

    valuesMapper.addRecordMapping('watch_list_users',gr,'sys_id'); // Map the field sys_id to a UI element that has element identifier of "watch_list_users". The element identifier could be any String, it's easier to map the column's name as the element identifer.

    
}
})(valuesMapper, context);

Here is an example of the data source I created. I used a reference field in my case, so I also needed the attributes multiSelect and the targetTable to sys_user. 

I wouldn't use in my case the sourceTable or SourceField, as I don't want it to behave like the original field, but that is on every case to evaluate. 

Let me know if this helps.