How to put Glide Record query that one fields value should not StartsWith "CW"

VIKAS MISHRA
Tera Contributor

I am Doing Glide record for one table and there i need to put one query or Encoded Query that the field "Contract_ID" should not starts with string "CW".

Contract_ID is the string field , i only wants the record where contract id is not starting with "CW" i can see in the filter that i have one filter "Starts WIth" but i can not see the filter not Starts with.

1 ACCEPTED SOLUTION

Nikita30
Mega Sage

Hi Vikas,

Please use the below addQuery condition in your script.

a.addQuery('Contract_ID', 'NOT LIKE', 'CW%');
 
Please mark the response as Helpful/Correct, if applicable. Thanks!
 
Thanks,
Nikita
 
 
 

View solution in original post

3 REPLIES 3

Nikita30
Mega Sage

Hi Vikas,

Please use the below addQuery condition in your script.

a.addQuery('Contract_ID', 'NOT LIKE', 'CW%');
 
Please mark the response as Helpful/Correct, if applicable. Thanks!
 
Thanks,
Nikita
 
 
 

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello Vikas,

The solution from my point of view is to use SQL 'LIKE' operator which work even though it's not documented for GlideRecord:

gr.addQuery('name', 'NOT LIKE', 'StartString%');

Pls mark as helpful if solution works.

 

BR,
Nayan

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Kartik Sethi
Tera Guru
Tera Guru

Hi @VIKAS MISHRA 

It's true that we do not have any Operator for your requirement but there are some workarounds:

  1. Check the community article "DOES NOT START WITH filter"
  2. Or you can go for RegEx in the while loop after you do a GlideRecord Query

In script you can try the below-provided query (but this will not work on the List Filter😞

gr.addEncodedQuery('numberNOT LIKECW%')

Please let me know if you need any help with the code.


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik