<?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>How to send Selected fields from CDT to API</title><link>https://community.appian.com/discussions/f/user-interface/18067/how-to-send-selected-fields-from-cdt-to-api</link><description>Hi All, 
 I have the below rule which I&amp;#39;m passing in the process parameters of an API. I am casting the cdt and sending the whole cdt as of now. Is there a way I can send only few fields from the cdt? If so how do I modify the below rule? Please help</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to send Selected fields from CDT to API</title><link>https://community.appian.com/thread/71056?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 14:41:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:df867cfe-f78e-4315-87dd-ad15f8efe1d6</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;This is one of my personal best practices for code clarity (which I enforce when possible with dev teams i&amp;#39;m on or managing) -- it becomes especially important when needing to nest array indexing with property fetching or vice versa (i&amp;#39;ve seen up to 3 or 4 nested index() calls before, where a majority of them are actually fetching properties).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since the functions are apparently an alias for each other, I believe there&amp;#39;s no reason not to use the proper name for the proper context.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send Selected fields from CDT to API</title><link>https://community.appian.com/thread/71055?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 14:14:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cab398a0-8568-4406-b232-6ec22f201308</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;Interesting, I&amp;#39;m not sure I&amp;#39;ve ever used that function before &lt;span class="emoticon" data-url="https://community.appian.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt; Although it does say at the bottom of the docs for the property function:&amp;nbsp;&lt;em&gt;See also index(): This function acts as an alias to the property() function especially when applied over custom data types.&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send Selected fields from CDT to API</title><link>https://community.appian.com/thread/71054?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 14:09:03 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:69899ecc-84a5-48ce-b913-1197bbee678f</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;Not to kvetch about it overly, but for code clarity reasons we should really be teaching&amp;nbsp;people to make use of the &lt;strong&gt;property()&lt;/strong&gt; when referring to CDT/dictionary properties, and reserve &lt;strong&gt;index()&lt;/strong&gt; for actual indexing (i.e. positional within an array).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send Selected fields from CDT to API</title><link>https://community.appian.com/thread/71053?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 14:00:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c3f3adc7-3d4d-42b9-8070-6b95b0b59cbc</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;In this example though, you don&amp;#39;t have to worry about it because I included a&amp;nbsp;single CDT type constructor (which would ensure that the final value returned is not an array). Also, if your JSON includes a list of values, the second expression should handle the list while ensuring the index() only returns one&amp;nbsp;value for each iteration.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send Selected fields from CDT to API</title><link>https://community.appian.com/thread/71048?ContentTypeID=1</link><pubDate>Wed, 18 Dec 2019 11:10:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:daa27414-0d0c-402f-898e-84e09f70522a</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;note that index() will always return a list, even if there&amp;#39;s only one (or even none) of the items you&amp;#39;re indexing on. This may then have implications for how the data is then passed on to your API (e.g. if the API is expecting JSON and is being strict on whether the data being passed is singular then this may cause a problem)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send Selected fields from CDT to API</title><link>https://community.appian.com/thread/71043?ContentTypeID=1</link><pubDate>Tue, 17 Dec 2019 21:54:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9944f15d-d4b3-4465-b234-e7a0ae1211fb</guid><dc:creator>Meena Kumari</dc:creator><description>&lt;p&gt;Thanks a lot Peter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send Selected fields from CDT to API</title><link>https://community.appian.com/thread/71039?ContentTypeID=1</link><pubDate>Tue, 17 Dec 2019 20:00:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5ab58779-2422-4d68-8747-9deaf6e294c2</guid><dc:creator>Peter Lewis</dc:creator><description>&lt;p&gt;The easiest way would be to only index the fields you want.&amp;nbsp;For example, you can use the type constructor to insert directly the fields you want to use like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!data: a!fromJson_19r2(ri!autoCaseCreationInput),
  type!TYMP_fileDetails(
    field1: index(local!data, &amp;quot;field1&amp;quot;, null),
    field2: index(local!data, &amp;quot;field2&amp;quot;, null),
    ...
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a little tedious, but it would allow you to get exactly which fields you want. If local!data could contain an array of files, then you could use a!forEach() around the expression I defined above like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(
  local!data: a!fromJson_19r2(ri!autoCaseCreationInput),
  a!forEach(
    items: local!data,
    expression: type!TYMP_fileDetails(
      field1: index(fv!item, &amp;quot;field1&amp;quot;, null),
      field2: index(fv!item, &amp;quot;field2&amp;quot;, null),
      ...
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>