Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

sysparm_query to treat nulls as null?

SN E
Tera Contributor

I am doing a query against the sys_user table like so:

https://dev123456.service-now.com/api/now/table/sys_user?sysparm_limit=10

I notice some users have a department like this:

"department": ""

And others have a department like this:

"department": {
  "link": "https://123456.service-now.com/api/now/table/cmn_department/5d7f17f03710200044e0bfc8bcbe5d43",
  "value": "5d7f17f03710200044e0bfc8bcbe5d43"
},

 

This is problematic in a Java / Jackson context, as one is an empty String and the other is an Object.  Convention dictates the empty String example would be either a null, or absent altogether from the response.

 

Is there a way to tell the query interface, "Send me nulls as null" or "Don't send me fields that are null", rather than, on my end, having to account for certain Objects being null if they're represented as blank Strings?

 

Thanks!

 

1 ACCEPTED SOLUTION

-O-
Kilo Patron

You could add "sysparm_display_value" with value "all" to the URL in which case all fields would be represented as objects. That way by looking @ property "value" you could tell that the field is null, or not by checking that it is an empty string or not.

View solution in original post

1 REPLY 1

-O-
Kilo Patron

You could add "sysparm_display_value" with value "all" to the URL in which case all fields would be represented as objects. That way by looking @ property "value" you could tell that the field is null, or not by checking that it is an empty string or not.