<?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>query conversion to text</title><link>https://community.appian.com/discussions/f/new-to-appian/23311/query-conversion-to-text</link><description>When I convert the ff. to text, the column name gets included. How will I be able to get the content only? 
 I get this [projectName:Project Nature], when it should be Project Nature only 
 
 Code used: 
 a!save( ri!projectName, rule!CRP_ProjectName(ri</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: query conversion to text</title><link>https://community.appian.com/thread/89506?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 15:12:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e06efbba-113f-4f93-865f-e09674bb3fa7</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Harsha&amp;#39;s earlier answer is correct, though to be more clear and specific, we need to remember that the result of a!queryEntity is a DataSubset comprised of &amp;quot;.data&amp;quot; parameter as well as others like &amp;quot;.totalCount&amp;quot;, paging information, etc.&amp;nbsp; Since you directly reference the &amp;quot;.data&amp;quot; property from your code above, then the only thing your output will show is the &amp;quot;.data&amp;quot; part.&lt;/p&gt;
&lt;p&gt;The second thing to remember is that &amp;quot;.data&amp;quot; will be an &lt;em&gt;array of dictionary&lt;/em&gt; roughly matching the data type (i.e. CDT) being queried against by your DSE.&amp;nbsp; It will &lt;em&gt;always&lt;/em&gt; assume this to be an array of dictionaries since any given query could return one or many results.&amp;nbsp; Then each item in that array will be an individual dictionary (even when you&amp;#39;ve told the queryEntity to only return one column of data), meaning you would need to directly reference the data &lt;em&gt;property&lt;/em&gt; you want.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want your rule to return a single string (as opposed to an array of any type containing a single string entry), you&amp;#39;d actually need to &lt;em&gt;index&lt;/em&gt; the first returned item of &amp;quot;.data&amp;quot;, then get the name &lt;em&gt;property&lt;/em&gt; from that.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You should also consider what you want to have happen when the rule is called with no project ID passed in - at the moment it would simply query the first item in the DB and return that, which doesn&amp;#39;t seem correct.&amp;nbsp; The simplest way to handle this is usually to wrap the rule in if() logic to check for a null rule input, and if it&amp;#39;s null, return null (this will prevent subsequent code from being executed which is a plus).&lt;/p&gt;
&lt;p&gt;The below example expands slightly on the steps involved in such a way as to illustrate (if you look at the local variable values after execution) what each step of the data looks like.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;if(
  a!isNullOrEmpty(ri!projectId),
  null(),
  
  a!localVariables(
    local!rawQueryResult: a!queryEntity(), /* this should be replaced with your existing a!queryEntity() call, minus the &amp;quot;.data&amp;quot; part at the end, which we&amp;#39;re now doing on the next line */
    local!queryResultData: local!rawQueryResult.data,
    local!queryResultSingleRow: index(local!queryResultData, 1, null()),
    
    property(local!queryResultSingleRow, &amp;quot;projectName&amp;quot;, null())
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: query conversion to text</title><link>https://community.appian.com/thread/89502?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 10:43:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:39970466-5685-4f24-aff4-438c7303a0e7</guid><dc:creator>saarcenal</dc:creator><description>&lt;p&gt;This worked wonderfully! Thank you very much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: query conversion to text</title><link>https://community.appian.com/thread/89500?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 08:43:10 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6dfea6c8-d837-4c67-9c6c-a2e7e9123350</guid><dc:creator>Harsha Sharma</dc:creator><description>&lt;p&gt;You need to index the column from the output so that just the value is returned. Try this in your rule&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;a!save(
ri!projectName,
index(rule!CRP_ProjectName(ri!request.projectId),&amp;quot;projectName&amp;quot;,{})
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Alternatively, you can add index in the CRP_ProjectName rule as well. Depends on usability, where do you want to index. E.g.&lt;pre class="ui-code" data-mode="text"&gt;index(a!queryEntity(/*Lines of Code*/).data,&amp;quot;projectName&amp;quot;,{})&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>