<?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>Add custom fields to a data subset</title><link>https://community.appian.com/discussions/f/data/18330/add-custom-fields-to-a-data-subset</link><description>Hello Everyone I am practicing Appian I have a case where I am fetching data from database using expression rule now I want to add a custom field to each record that is returned with the data subset 
 please Notice that this field doesn&amp;#39;t exist on the</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Add custom fields to a data subset</title><link>https://community.appian.com/thread/72194?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2020 09:20:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0a457a1a-f18c-48dd-a9c4-7143791aea20</guid><dc:creator>ManuelHTG</dc:creator><description>&lt;p&gt;It is not a very good approach or practice to do that, because any change that you would do on the CDT would not be reflected on your expression rule. It would be much better to add those custom fields on the CDT. In general, what you are suggesting is not a good practice.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Anyways, the solution from &lt;a href="/members/evanr"&gt;Evan Rust&lt;/a&gt; would solve your problem.You don&amp;#39;t need though to create a second CDT to cast, you can directly provide the structure.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;this would give you a dictionary with the structure with id, name and ranking (always 2)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;load(

local!student: rule!APP_QE_getStudent(id:null).data,

{

a!forEach(

items: local!student,

expression{

id: fv!item.id,

name: fv!item.name,

ranking: 2


}


)


}


)


&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add custom fields to a data subset</title><link>https://community.appian.com/thread/72193?ContentTypeID=1</link><pubDate>Wed, 19 Feb 2020 00:09:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:0c7739d4-db9b-4946-a831-9c4152e6acc9</guid><dc:creator>Robert Shankin</dc:creator><description>&lt;p&gt;Maybe this plugin will help you&lt;/p&gt;
&lt;p&gt;&lt;a href="/b/appmarket/posts/cdt-manipulation"&gt;https://community.appian.com/b/appmarket/posts/cdt-manipulation&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Add custom fields to a data subset</title><link>https://community.appian.com/thread/72182?ContentTypeID=1</link><pubDate>Tue, 18 Feb 2020 22:22:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:17f886d1-c652-4e26-9a0d-8b5f54954305</guid><dc:creator>Evan Rust</dc:creator><description>&lt;p&gt;If you already have a CDT that maps to that table, you can create a second helper CDT that does not map to any table (i.e. do not publish in a data store), but that has all of the same fields plus an additional field that you use for your &amp;quot;custom value&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then, in your expression rule you can call a!forEach and use a type constructor to build the CDT you&amp;#39;re looking to build.&lt;/p&gt;
&lt;p&gt;a!forEach(&lt;/p&gt;
&lt;p&gt;items:local!myItems /*this is the result of some query you did to grab the data from the table*/&lt;/p&gt;
&lt;p&gt;expression:type!mySecondCDT(&lt;/p&gt;
&lt;p&gt;field1:local!myItems.field1&lt;/p&gt;
&lt;p&gt;fieldN:local!myItems.fieldN&lt;/p&gt;
&lt;p&gt;customField:1234 /*put whatever you want here*/&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then if you need this in a datasubset type, just use todatasubset() over it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>