<?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>appian and maps</title><link>https://community.appian.com/discussions/f/general/25956/appian-and-maps</link><description>Hello, 
 I am trying to represent the following structure using maps in Appian (for those familiar with C# or Java ... something equivalent to Dictionary&amp;lt;int, List&amp;lt;Object&amp;gt;): 
 So the list looks something like this: 
 { { taskId: 100, dependsOnTaskId:</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/102269?ContentTypeID=1</link><pubDate>Mon, 03 Oct 2022 10:23:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b332e839-3aed-494f-af69-7ba586704c2a</guid><dc:creator>dgomezcid</dc:creator><description>&lt;p&gt;Hi there again,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So I finally created a recursive method that prevents duplicates from being added to the map. It is a bit ugly, but it does the trick.&lt;/p&gt;
&lt;p&gt;Thank you for all your help&lt;/p&gt;
&lt;p&gt;David&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/101527?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 22:21:02 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6bf6d68a-d570-4646-b361-2a1c942c5eaf</guid><dc:creator>dgomezcid</dc:creator><description>&lt;p&gt;Hello Stewart,&lt;/p&gt;
&lt;p&gt;Your approach sounds good!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If a new dependency is going to cause a circular dependency, it should be discarded. Therefore:&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;a - should that end up as just a ? Yes&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;a - should that end up as a-&amp;gt;b ? or b-&amp;gt;a ? a-&amp;gt;b&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;b - should that end up as a-&amp;gt;b-&amp;gt;c ? Yes&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;a - should that end up as a-&amp;gt;b-&amp;gt;c ? or b-&amp;gt;c-&amp;gt;a ? a-&amp;gt;b-&amp;gt;c&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;x-&amp;gt;x - should that end up as a-&amp;gt;b-&amp;gt;c-&amp;gt;x ? Yes&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/101525?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 21:09:37 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:bd63b195-a62c-436c-9790-c4ce51f5f899</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;The approach I would take would be to break the problem down into some smaller problems:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;generate the output a per my original example&lt;/li&gt;
&lt;li&gt;remove duplicate nodes from the output&lt;/li&gt;
&lt;li&gt;remove the circular dependencies&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So I need to know the &amp;quot;rules&amp;quot; that you want to apply for step 3. What should the result be for the&amp;nbsp;following examples?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;a - should that end up as just a ?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;a - should that end up as a-&amp;gt;b ? or b-&amp;gt;a ?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;b - should that end up as a-&amp;gt;b-&amp;gt;c ?&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;a - should that end up as a-&amp;gt;b-&amp;gt;c ? or b-&amp;gt;c-&amp;gt;a ?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;x-&amp;gt;x - should that end up as a-&amp;gt;b-&amp;gt;c-&amp;gt;x ?&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;On easy to implement option might be just to remove the duplicate items, but that might not be the right answer, so it depends on what rules you want to apply as to what the solution needs to look like.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/101517?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 16:58:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:8a04b22d-30d1-45d1-bcc3-547aa0528d68</guid><dc:creator>dgomezcid</dc:creator><description>&lt;p&gt;Hi there again,&lt;/p&gt;
&lt;p&gt;Duplicate node: yes, figured that one out already, thank you!&lt;/p&gt;
&lt;p&gt;Circular dependency: Ideally, the verification would be done while creating the map from the list, eliminating this way, the need to reprocess it later on. The initial list is arbitrary, I do not have control over the different items might contain. However, I do have to guarantee that no circular dependencies are created.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A circula dependency could potentially happen at any moment ( [-&amp;gt;] translates to&amp;nbsp; &amp;quot;depends on&amp;quot;)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;a-&amp;gt;a&lt;/p&gt;
&lt;p&gt;a-&amp;gt;b-&amp;gt;a&lt;/p&gt;
&lt;p&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;b&lt;/p&gt;
&lt;p&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;a&lt;/p&gt;
&lt;p&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;x-&amp;gt;x&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;I am not sure at this time what would be more efficient, preventing such an scenario or extending the current code&amp;nbsp;as you mentioned.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you again&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/101516?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 16:58:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d48fc2a9-2469-4e99-b64f-09ee8fbc1e5f</guid><dc:creator>ujjwalr0002</dc:creator><description>&lt;p&gt;&lt;a href="/members/stewart.burchell"&gt;Stewart Burchell&lt;/a&gt; I was thinking can we create a temporary CDT which can have a column of multiple type.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/101515?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 16:40:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:801107ff-2b28-4d21-9f2a-52bd73595c59</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Well that&amp;#39;s a totally different ball game...&lt;/p&gt;
&lt;p&gt;Circular Dependency: firstly, are you asking how to prevent such a scenario being written to this data structure in the first place, or how to extend the current code to take your data structure generate something that does not have such a dependency (and if so, what are the rules that govern this?)&lt;/p&gt;
&lt;p&gt;Duplicate Node: I already showed you how to removed duplicates for the output by using fn!union() so you can use that on your input before you process it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/101514?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 16:34:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3ee52f0d-8eea-4b17-8e58-7415853833cd</guid><dc:creator>dgomezcid</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;a class="internal-link view-user-profile" href="/members/stewart.burchell"&gt;Stewart&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Thank you so much for your quick replay, I very much appreciate it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How would you prevent adding circular and duplicated tasks?&lt;/p&gt;
&lt;p&gt;{&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; taskId: 100,&lt;br /&gt;&amp;nbsp; &amp;nbsp; dependsOnTaskId: 101&lt;br /&gt;&amp;nbsp; },&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;taskId&lt;/span&gt;: 100,&lt;br /&gt;&amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;dependsOnTaskId&lt;/span&gt;: 121&lt;br /&gt;&amp;nbsp;},&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;taskId&lt;/span&gt;&lt;span&gt;: 101,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;dependsOnTaskId&lt;/span&gt;&lt;span&gt;: 123&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;},&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;taskId&lt;/span&gt;&lt;span&gt;: 103,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;dependsOnTaskId&lt;/span&gt;&lt;span&gt;: 0&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;},&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;span&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;taskId&lt;/span&gt;&lt;span&gt;: 123,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;dependsOnTaskId&lt;/span&gt;&lt;span&gt;: 100&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;},&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;/*duplicated node*/&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;taskId&lt;/span&gt;&lt;span&gt;: 123,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;dependsOnTaskId&lt;/span&gt;&lt;span&gt;: 100&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;100 -&amp;gt; 101 -&amp;gt; 123 -&amp;gt; 100 (circular dependency)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you again for your time!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: appian and maps</title><link>https://community.appian.com/thread/101507?ContentTypeID=1</link><pubDate>Tue, 20 Sep 2022 15:23:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:28fc43da-47b4-4da7-93ba-f8420417c672</guid><dc:creator>Stewart Burchell</dc:creator><description>&lt;p&gt;Hi - this seems to work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!sourceData: {
    a!map(taskId: 100, dependsOnTaskId: 101),
    a!map(taskId: 100, dependsOnTaskId: 121),
    a!map(taskId: 101, dependsOnTaskId: 123),
    a!map(taskId: 103, dependsOnTaskId: 0),
    a!map(taskId: 123, dependsOnTaskId: 5)
  },
  local!result: a!forEach(
    items: local!sourceData.taskId,
    expression: a!map(
      taskId: fv!item,
      dependencies: local!sourceData.dependsOnTaskId[wherecontains(fv!item, local!sourceData.taskId)]
    )
  ),
  fn!union(local!result,local!result)
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;...with output of:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/11/pastedimage1663687379543v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;I did notice that your expected output value for &amp;#39;dependancies&amp;#39; for taskId 103 is blank, whereas your source data has a value of 0. I am assuming you wanted 0. If not then you&amp;#39;ll have to add a specific clause to output &amp;#39;null&amp;#39; when the actual value is 0.&lt;/p&gt;
&lt;p&gt;If you want an explanation as to what&amp;#39;s going on&amp;nbsp; I&amp;#39;m happy to provide you with one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>