Solved

Client Script Filter on User Def field not working

  • 20 November 2020
  • 6 replies
  • 63 views

Badge +1

I am able to run script below in SQL (the select part of it) and it returns the results as expected; however on Mobile the line-code field is greyed out and won’t allow selections.  I have confirmed that user_def1 is passed down to mobile.

This is something i’m doing in order to filter out select line codes from appearing on Mobile screen.

populateListFromQuery("non_part_usage", "line_code", "select description, line_code from line_code where npu_code = 'EXP' and line_code_type <> 'CYL' and line_code_type <> 'R'and user_def1 <> 'PR' order by sequence asc", true);

icon

Best answer by Steve Hurst 26 November 2020, 17:56

Hi @Jacksonc 

The problem is being caused because some of your line code records have NULL values in user_def1. Mobile treats these differently. In order to fix your sql query in your script you need to replace your populateListFromQuery line with the following which adds in specific handling for null values:

 

populateListFromQuery("non_part_usage", "line_code", "select description, line_code from line_code where npu_code = 'EXP' and line_code_type <> 'CYL' and line_code_type <> 'R' and (user_def1 <> 'PR' or user_def1 IS NULL) order by sequence asc", true);

This should then work.

Regards

Steve

View original

6 replies

Userlevel 3
Badge +2

Hi @Jacksonc 

Are you able to provide a bit more detail on what you are trying to do?

Which screen re you applying this script to? I assume it is in the populate event?

Have you modified the line_code field?

Maybe some screenshots might help?

Regards

Steve

Userlevel 6
Badge +13

Hi @Jacksonc,

Usually you would use the mobile designer to apply filters like this one.

Have you tried the mobile designer? Is there an issue you have hit that has made you look somewhere other than the designer?

Kind regards,

Lee Pinchbeck

Badge +1

Hi @Steve Hurst 
I”m running a client script to populate the ‘Fees’ (DebriefMileage) screen on mobile with only select Line Codes - those with the field ‘user_def1’ not populated with ‘PR’, see 1st screenshot.  The script runs fine in SQL only returns those line codes that do not have ‘PR’, however when i refer to this in my refresh script to populate values, it greys out the line code selection field on mobile - so it doesn’t like the “...user_def1 <> ‘PR’..” in the populateListFromQuery line
 

 

Badge +1

Hi @Lee Pinchbeck   I am relatively new to this so thanks for your patience.  I”ve never tried filtering in mobile studio, mostly i’ve been doing this in client scripts to refresh/populate screen fields.  I took a stab at it, see screenshot below; however this did not make any difference - still showed line codes with the field ‘user_def1’ populated with ‘PR’
 

 

Userlevel 3
Badge +2

Hi @Jacksonc 

The problem is being caused because some of your line code records have NULL values in user_def1. Mobile treats these differently. In order to fix your sql query in your script you need to replace your populateListFromQuery line with the following which adds in specific handling for null values:

 

populateListFromQuery("non_part_usage", "line_code", "select description, line_code from line_code where npu_code = 'EXP' and line_code_type <> 'CYL' and line_code_type <> 'R' and (user_def1 <> 'PR' or user_def1 IS NULL) order by sequence asc", true);

This should then work.

Regards

Steve

Badge +1

@Steve Hurst Not sure if you got me earlier reply, but thanks so much Steve.  This works perfectly now

Reply