M.App Enterprise Discussions

Discuss topics with other M.App Enterprise Product pioneers and experts to get the most out of it.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Contributor
Posts: 27
Registered: ‎05-11-2018
Accepted Solution

Filtered list in mobile

Hi,

 

I am trying to filter a list by user in the Mobile app.

In my shell.xaml I have the following filter:

 

<Entity.Filters>
	<Filter Id="ASSIGNED_TO" Sql="ASSIGNED_TO = @{System.UserId}" IsDefault="True" />
</Entity.Filters>

How in my list.xaml can I implement the filter?

 

<List.ShellActions>
        
</List.ShellActions>
    <ListCell Name="STREET_NAME" Title="Street" />  
    <ListCell Name="ASSIGNED_TO" Title="User"/>	

 

Thank You

Ciaran

Highlighted
Technical Evangelist
Posts: 775
Registered: ‎11-12-2015

Re: Filtered list in mobile

Hi Ciaran,

 

You can use a Search against the list as a Filter here.

 

Using your 'ASSIGNED_TO' Filter example it would look something like:

<List.ShellActions>
   <SearchShellAction Filter="ASSIGNED_TO" />
</List.ShellActions>

HTH

Highlighted
Staff
Posts: 105
Registered: ‎10-25-2016

Re: Filtered list in mobile

Hi Ciaran,

 

you can also have a look at Lab 5b (https://community.hexagongeospatial.com/t5/M-App-Enterprise-Tutorials/How-to-setup-a-Mobile-App-Part...) how to apply a filter to a specific list.

 

If you specify IsDefault="True" to your entity filter, it will be applied at synchronization level. If you set it to IsDefault="False", you can use it as default filter on a list or e.g.: to filter items of a picker.

 

Regards

Christian

 

 

Highlighted
Contributor
Posts: 27
Registered: ‎05-11-2018

Re: Filtered list in mobile

Hi Christian,

 

That works perfect

 

Thank you

Ciaran

Highlighted
Occasional Contributor
Posts: 17
Registered: ‎03-16-2020

Re: Filtered list in mobile

I have the same issue 

I need to filter two lists from one entity but it takes one filter only on the two lists!!

it takes the one who is the value of IsDefault="True".

 

and if I put the value "True" in the two filters, it's sync and not view any records in the two lists. 

 

and if I put the value "False" in the two filters, it does not filter in the two lists. 

 

here are my Entity Filters

<Entity.Filters>
	<Filter Id="change_id" Sql="change_id Like @{change_id}" />
					
	<Filter Id="id1" Sql="sec ='مركز مغاغة' AND change_status=3"  IsDefault="False"/>
								
	<Filter Id="id2" Sql="sec ='مركز مغاغة' AND change_status=6" IsDefault="True" />
</Entity.Filters>

and here are my Navigations

<Navigation Id="PointNavigation">
				
                 <List Id="PointList" Title="قائمة المتغيرات المكانية لأول مرة" View="PointList" Entity="{x:Reference points_menia}">
								
				<List.Filters>

					<FilterRef Filter="{x:Reference id1}" Title="قائمة المتغيرات المكانية لأول مرة" />

			        </List.Filters>
					
				<Form Id="PointForm" Title="قائمة إدخال البيانات " View="PointForm" Entity="{x:Reference points_menia}" Target="PointList" />		
					
		</List>
</Navigation>
				
<Navigation Id="PointNavigationSecond">
				
                <List Id="PointList2" Title="قائمة المتغيرات المكانية لأعادة الرد" View="PointList" Entity="{x:Reference points_menia}">
					
			<List.Filters>

			  <FilterRef Filter="{x:Reference id2}" Title="قائمة المتغيرات المكانية لأعادة الرد"  />

			</List.Filters>	
							
			<Form Id="PointForm2" Title="قائمة إدخال البيانات " View="PointForm" Entity="{x:Reference points_menia}" Target="PointList2" />		
						 
		</List>
					
</Navigation>

 am I miss something??

 

Highlighted
Staff
Posts: 37
Registered: ‎07-16-2019

Re: Filtered list in mobile

Hello @poula123 

 

By your code it looks to me like your two filters are mutually exclusive. In that case this filter:

 

 

<Filter Id="id2" Sql="sec ='مركز مغاغة' AND change_status=6" IsDefault="True" />

 

 

Will only load the rows where change_status is '6'. All other rows are not even syncronized to the app. Having two mutually filters set to default will act like a logical 'AND'  there for two mutually exclusive filters will return 0 results and you wont get anything in the app.

 

If you want to apply different filters for different lists, set the filters to IsDefault="False" and apply the corresponding filter to each list adding a IsDefault="True"  like this:

 

...
<List.Filters> <FilterRef Filter="{x:Reference id1}" Title="قائمة المتغيرات المكانية لأول مرة" IsDefault="True" /> </List.Filters>

I notice there is another filter on your code, don't know what it is for but make sure that one is not exclusive too.

 

 

 

Highlighted
Occasional Contributor
Posts: 17
Registered: ‎03-16-2020

Re: Filtered list in mobile

hello,

 

I still have the same issue

 

I need to customize different filters to two different two lists

 

I wrote those filters in the entity

 

<Filter Id="governorate_idd" Sql="governorate_id = 15" IsDefault="True"/> 
<Filter Id="sector_sheben" Sql="sector_id = 247" IsDefault="False" /> 

and wrote those in Navigations

 

<Navigation Id="PointNavigation">
<List Id="PointList" Title="قائمة المتغيرات المكانية" View="PointList" Entity="{x:Reference change_points_details_qalubiah}">
<List.Filters>
<FilterRef Filter="{x:Reference governorate_idd}" Title="قائمةالمتغيرات المكانية فى شبين القناطر" />
</List.Filters>
<Form Id="PointForm" Title="قائمة إدخال البيانات " View="PointForm" Entity="{x:Reference change_points_details_qalubiah}" Target="PointList" />		
</List> 
</Navigation>
			
<Navigation Id="PointNavigation_sheben">
<List Id="PointList_sheben" Title="شبين القناطر" View="PointList" Entity="{x:Reference change_points_details_qalubiah}">
<List.Filters>
<FilterRef Filter="{x:Reference sector_sheben}" Title="قائمةالمتغيرات المكانية فى شبين القناطر" IsDefault="True"/>
</List.Filters>
<Form Id="PointForm_sheben" Title="قائمة إدخال البيانات " View="PointForm" Entity="{x:Reference change_points_details_qalubiah}" Target="PointList" />	 	
</List> 
</Navigation>
			

am I miss something??

Highlighted
Occasional Contributor
Posts: 17
Registered: ‎03-16-2020

Re: Filtered list in mobile

I know where is the error

 

in the filter, I used field which is in a foreign entity 

 

so I wrote the name of the entity before field name in SQL statement

 

and here the right code

 

<Filter Id="sector_sheben" Sql="change_points_details_qalubiah.sector_id in (247)" IsDefault="False" />