<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Creating Web API which can handle Nulls</title><link>https://community.appian.com/discussions/f/integrations/25604/creating-web-api-which-can-handle-nulls</link><description>Hi everyone, 
 
 I&amp;#39;m trying to do a simple web API which can handle nulls values, but I&amp;#39;m having problems using the if statement to set it up. Can someone please help me. Thank you 
 
 filter: a!queryFilter( 
 field: &amp;quot;name&amp;quot;, 
 operator: &amp;quot;=&amp;quot;, 
 value:</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Creating Web API which can handle Nulls</title><link>https://community.appian.com/thread/100003?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 15:51:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:78815c7c-a44d-41ed-b5db-18ec23c120c7</guid><dc:creator>frankt54</dc:creator><description>&lt;p&gt;Thank you, it work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Web API which can handle Nulls</title><link>https://community.appian.com/thread/100002?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 15:45:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2cc335bd-c885-4a46-9fa5-83fef0aa0cae</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Oh in that case you just don&amp;#39;t need what I put in lies 3-6 - just replace that whole part with null. Once you do that, the filter will return null if the name parameter is null, and a filter of null just means don&amp;#39;t apply a filter (i.e. return everything).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Web API which can handle Nulls</title><link>https://community.appian.com/thread/99998?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 15:37:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:02908a7d-c85f-46a7-8cc3-86f23903ce88</guid><dc:creator>frankt54</dc:creator><description>&lt;p&gt;Perfect, but I forgot to mentioned that i need to use a if statement. this is the instructions I have to follow.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:120px;top:432.405px;" dir="ltr"&gt;The filter works with the test request, but if an external system did not send a query parameter&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:120px;top:457.854px;" dir="ltr"&gt;then the Web API would return an error. In the third part, update the filter to return all of the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:120px;top:483.302px;" dir="ltr"&gt;data if the query parameter is null.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:150px;top:534.198px;" dir="ltr"&gt;1.&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:165.551px;top:534.198px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:534.198px;" dir="ltr"&gt;In line 14, after the filter parameter but before the a!queryFilter() function, add the if()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:559.647px;" dir="ltr"&gt;function&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:150px;top:585.095px;" dir="ltr"&gt;2.&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:165.551px;top:585.095px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:585.095px;" dir="ltr"&gt;Add the closing parenthesis for the if() function after the parenthesis on line 19. You can&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:610.543px;" dir="ltr"&gt;hard return after the parenthesis on line 19 and add the new parenthesis on line 20.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:150px;top:635.991px;" dir="ltr"&gt;3.&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:165.551px;top:635.991px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:635.991px;" dir="ltr"&gt;Hard return after the&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:349.112px;top:635.991px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:354.83px;top:635.991px;" dir="ltr"&gt;if(&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:375.688px;top:635.991px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:381.407px;top:635.991px;" dir="ltr"&gt;on line 14&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:150px;top:661.439px;" dir="ltr"&gt;4.&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:165.551px;top:661.439px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:661.439px;" dir="ltr"&gt;Use the following parameters (if you use the parameter names for this function,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:686.888px;" dir="ltr"&gt;remember to use them for all parameters) in the if() function to say, &amp;ldquo;if the query&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:712.336px;" dir="ltr"&gt;parameter for name is null, return the full list from the database; else use the filter to&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:180px;top:737.785px;" dir="ltr"&gt;return filtered results&amp;rdquo;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:210px;top:763.232px;" dir="ltr"&gt;a.&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:225.167px;top:763.232px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:240px;top:763.232px;" dir="ltr"&gt;condition:&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:319.888px;top:763.232px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:325.608px;top:763.232px;" dir="ltr"&gt;isnull(http!request.queryParameters.name)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:210px;top:788.681px;" dir="ltr"&gt;b.&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:225.676px;top:788.681px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:240px;top:788.681px;" dir="ltr"&gt;valueIfTrue:&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:339.094px;top:788.681px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:344.814px;top:788.681px;" dir="ltr"&gt;null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:210px;top:814.129px;" dir="ltr"&gt;c.&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:224.004px;top:814.129px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:240px;top:814.129px;" dir="ltr"&gt;valueIfFalse:&lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:343.11px;top:814.129px;" dir="ltr"&gt; &lt;/span&gt;&lt;span style="font-family:sans-serif;font-size:18.3333px;left:348.831px;top:814.129px;" dir="ltr"&gt;a!queryFilter(...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Web API which can handle Nulls</title><link>https://community.appian.com/thread/99995?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 15:32:35 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:71b6182f-7d30-4b2d-9f72-135f4c73d726</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;There is actually a separate &amp;quot;is null&amp;quot; operator, so you probably would want to separate this out by using conditional logic around your entire Query Filter. Something like this would work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;filter: if(
  a!isNullOrEmpty(http!request.queryParameters.name),
  a!queryFilter(
    field: &amp;quot;name&amp;quot;,
    operator: &amp;quot;is null&amp;quot;
  ),
  a!queryFilter(
    field: &amp;quot;name&amp;quot;,
    operator: &amp;quot;=&amp;quot;,
    value: http!request.queryParameters.name
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;One other important note: the vale you have there for &amp;quot; &amp;quot; is technically not null - a space and null are not considered equivalent in Appian.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>