How to apply "field is not empty" in GlideRecord addCondition?

PhoenixMing0912
Giga Expert

Hi all,

I want to seach a non-empty String field in a table by using addCondition.

I went through the following tutorial:

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideQueryConditionAPI

 

But looks like xx != ""  is not working. Anyone could help?

9 REPLIES 9

@PhoenixMing0912 

Glad that my response helped.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

If not, please let us know if you need some more assistance.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Dhananjay Pawar
Kilo Sage

Hi,

Any update on this?

If this has resolved kindly mark appropriate response as correct and close the thread, So others will refer same in future.

Thanks,

Dhananjay.

Yash Agrawal1
Tera Guru

Hello User,

Along with the above suggestion, below will also work.

var grchange = new GlideRecord('change_request');
grchange.addQuery('state',3);
grchange.addQuery('short_description','');
if(grchange.next())
{
   gs.addInfoMessege('Found');
}

Please Mark it helpful/correct if my answer helps in any way to resolve your query.
Reach out to me if any more help required.

Regards

Yash.K.Agrawal

PhoenixMing0912
Giga Expert

I have given some test.

Actually, my requirement is "addCondition" used for "addJoinQuery", not a normal query.

The following worked for filtering non-empty value for field "aaa".

gr.addCondition("aaa", "!=", "");

 

@PhoenixMing0912 

Glad to know.

if you think there is any response that helps you please mark that helpful & correct so that this thread can be closed. Happy Coding!

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader