<?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>Index vs property</title><link>https://community.appian.com/discussions/f/best-practices/37847/index-vs-property</link><description>what is the main difference and what to use where</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Index vs property</title><link>https://community.appian.com/thread/142291?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2024 14:22:24 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5a8ec590-9082-486f-ad91-883d0ab17724</guid><dc:creator>Mike Schmitt</dc:creator><description>[quote userid="280089" url="~/discussions/f/best-practices/37847/index-vs-property/142280"]&lt;p&gt;Normal difference is ,We go for Property function when we try to get the value of a property/Field in CDT or dictionary like &lt;strong&gt;property(CDT,&amp;quot;field&amp;quot;,default value)&lt;/strong&gt; it can be achieved through index too&lt;/p&gt;
&lt;p&gt;And we use index to get the value from array like &lt;strong&gt;index(Array,3,null)&lt;/strong&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;strong&gt;Thank you&lt;/strong&gt;, this is my normal soap box too.&lt;/p&gt;
&lt;p&gt;For code readability especially, i (100% of the time) recommend &lt;em&gt;property()&lt;/em&gt; be used for getting a &amp;quot;field&amp;quot; from a CDT, and &lt;em&gt;index()&lt;/em&gt; be used for getting the index i.e. position within an array, when it&amp;#39;s not 100% clear whether the array will have an entry at that index.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index vs property</title><link>https://community.appian.com/thread/142282?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2024 11:41:44 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:79a43f44-53e7-4ab3-a59a-94998235324a</guid><dc:creator>Karumuru Abhishek</dc:creator><description>&lt;p&gt;&lt;span&gt;Both functions do the same thing&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When accessing properties in a CDT (Complex Data Type) or a Dictionary, use the `property()` function. For example, `property(ri!myCdt, &amp;quot;userId&amp;quot;, null())` attempts to retrieve the &amp;quot;userId&amp;quot; dot property&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To look up an element in an array, use the `index()` function. For instance, `index(ri!myArray, 5, null())` tries to find the 5th item in the array. If the array does not contain that many elements, it will return null.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It&amp;#39;s crucial to clarify the purpose of function calls, especially when reading code. This way, it&amp;#39;s much easier to understand if the &amp;quot;index()&amp;quot; call is trying to find a property or an array index. This distinction can become quite messy, particularly when functions are nested&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index vs property</title><link>https://community.appian.com/thread/142281?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2024 11:40:59 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:df8f16a3-905e-40fb-adb0-752a6456bbff</guid><dc:creator>Partha</dc:creator><description>&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Both functions are almost work in same way&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;property() ,property(cdt,&amp;quot;name&amp;quot;,null)&amp;nbsp;to try to get the name.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;index(), index(array,2,null)&amp;nbsp;to try to find the 2nd index of the array&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Index vs property</title><link>https://community.appian.com/thread/142280?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2024 11:36:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:424f91e2-95c5-4edb-b7e2-2f877a381a02</guid><dc:creator>venkatrea696188</dc:creator><description>&lt;p&gt;Both are same , it clearly mentioned in Documentation that Property is alias of index&lt;/p&gt;
&lt;p&gt;Normal difference is ,We go for Property function when we try to get the value of a property/Field in CDT or dictionary like &lt;strong&gt;property(CDT,&amp;quot;field&amp;quot;,default value)&lt;/strong&gt; it can be achieved through index too&lt;/p&gt;
&lt;p&gt;And we use index to get the value from array like &lt;strong&gt;index(Array,3,null)&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>