<?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>Convert String into CDT</title><link>https://community.appian.com/discussions/f/data/11412/convert-string-into-cdt</link><description>Hi All, 
 
 I am getting the response from exec procedure like below: 
 [success:true,error:,parameters:[BOOKS_CURSOR:[quantity:23,author:Collectif,price:3.74,title:Peppa Pig: Fun at the Fair]; [quantity:7,author:Judith Simanovsky,price:4.99,title:Panda</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/51420?ContentTypeID=1</link><pubDate>Mon, 08 Jan 2018 09:32:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:96bed807-4e11-4032-9515-25678326f206</guid><dc:creator>Ravi Roshan</dc:creator><description>Hi Vivek,&lt;br /&gt;
&lt;br /&gt;
In similar way you can achieve your result.&lt;br /&gt;
&lt;br /&gt;
load(&lt;br /&gt;
  local!str: &amp;quot;Name:xyz;age:30;profession:Student&amp;quot;,&lt;br /&gt;
  local!concatedStr: concat(local!str,&amp;quot;;&amp;quot;),&lt;br /&gt;
  local!name: extract(local!concatedStr, &amp;quot;Name:&amp;quot;, &amp;quot;;&amp;quot;),&lt;br /&gt;
  local!age: extract(local!concatedStr, &amp;quot;age:&amp;quot;, &amp;quot;;&amp;quot;),&lt;br /&gt;
  local!profession : extract(local!concatedStr, &amp;quot;profession:&amp;quot;, &amp;quot;;&amp;quot;),&lt;br /&gt;
  {&lt;br /&gt;
    local!name,&lt;br /&gt;
    local!age,&lt;br /&gt;
    local!profession&lt;br /&gt;
  }&lt;br /&gt;
)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/51411?ContentTypeID=1</link><pubDate>Mon, 08 Jan 2018 07:54:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9a6998b1-899d-4ff7-8096-58fa90964256</guid><dc:creator>viveku3486</dc:creator><description>Hello Mike,&lt;br /&gt;
&lt;br /&gt;
I have similar kind of requirement but here my problem is I want to display the value in the form. So lets say if my string is in the form of &amp;quot;Name:xyz;age:30;profession:Student&amp;quot; then I want Name,age and profession to be displayed in different textfields. Is there a way to fetch each one of them separately?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50396?ContentTypeID=1</link><pubDate>Mon, 27 Nov 2017 12:34:21 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b1e9dd11-b613-43ff-b611-182d41577f25</guid><dc:creator>Mike Schmitt</dc:creator><description>You don&amp;#39;t really need a!forEach for this - did you try the code I posted above originally?  It would go in its own expression rule, which you could call via apply() in order to loop it over many entries.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50395?ContentTypeID=1</link><pubDate>Mon, 27 Nov 2017 12:31:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dcddea71-f222-4a3f-a9fa-574ae5ee198a</guid><dc:creator>rishub</dc:creator><description>, &lt;a href="/members/annap"&gt;annap&lt;/a&gt; : Actually the expression given by annap did not work for me as we are on 16.3 so foreach function &amp;amp; fv!index is not available to us. Can you please guide how we can use apply or applycomponents or any other expression to get the desired results?&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50258?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2017 14:31:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:edd9be00-db60-4d04-8a8b-49bf8758142c</guid><dc:creator>rishub</dc:creator><description>Thanks Mike &amp;amp; Annap.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50218?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2017 15:52:15 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:3edffe59-63fc-4e13-a1c3-c8c25313c609</guid><dc:creator>Mike Schmitt</dc:creator><description>(note that this is essentially what I suggested above ;-))&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50203?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2017 08:50:46 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f348cd1c-02d8-4cf9-bf23-5a7a43e4e832</guid><dc:creator>annap</dc:creator><description>try this, it will help you&lt;br /&gt;
&lt;br /&gt;
load(&lt;br /&gt;
  local!data: &amp;quot;[success:true,error:,parameters:[BOOKS_CURSOR:[quantity:23,author:Collectif,price:3.74,title:Peppa Pig: Fun at the Fair]; [quantity:7,author:Judith Simanovsky,price:4.99,title:Panda Goes to the Olympics]],result:]&amp;quot;,&lt;br /&gt;
  local!quantity: extract(local!data, &amp;quot;quantity:&amp;quot;, &amp;quot;,author&amp;quot;),&lt;br /&gt;
  local!author: extract(local!data, &amp;quot;author:&amp;quot;, &amp;quot;,price&amp;quot;),&lt;br /&gt;
  local!price: extract(local!data, &amp;quot;price:&amp;quot;, &amp;quot;,title&amp;quot;),&lt;br /&gt;
  local!title: extract(local!data, &amp;quot;title:&amp;quot;, &amp;quot;]&amp;quot;),&lt;br /&gt;
  cast(&lt;br /&gt;
    typeof(&lt;br /&gt;
      {&lt;br /&gt;
        type!Books()&lt;br /&gt;
      }&lt;br /&gt;
    ),&lt;br /&gt;
    a!forEach(&lt;br /&gt;
      local!quantity,&lt;br /&gt;
      {&lt;br /&gt;
        quantity: local!quantity[fv!index],&lt;br /&gt;
        author: local!author[fv!index],&lt;br /&gt;
    	price: local!price[fv!index],&lt;br /&gt;
        title: local!title[fv!index]&lt;br /&gt;
      }&lt;br /&gt;
    )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50197?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2017 00:08:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b9bece09-ce6f-4fb7-b64e-16d2493bdcfa</guid><dc:creator>rishub</dc:creator><description>&lt;a href="/members/coltonb"&gt;Colton Beck&lt;/a&gt;  When I am trying the data that I get  from rule in the expression by copying the data like you have done, it works but when I use local!value in that expression it  gives me blank result.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50193?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 20:40:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:76b5a88c-7a0a-4300-9747-a355e4c314ce</guid><dc:creator>Mike Schmitt</dc:creator><description>&lt;p&gt;I believe you need to use the extract() function. &amp;nbsp;I suggest making a modular expression rule specifically to handle this conversion, for ease of access and updating in the future. &amp;nbsp;I&amp;#39;ve written one previously to translate the results of the &amp;quot;getprocessmodeldetailsbyuuid()&amp;quot; plug-in function into dictionary, and it works fairly well.&lt;/p&gt;
&lt;p&gt;The following code assumes you will create it as an expression rule and the ri! will be the string (and that if at any point you want to do multiple book strings, you&amp;#39;ll apply() this rule over the list).&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;with(
  local!quantity: extract(ri!rawText, &amp;quot;quantity:&amp;quot;, &amp;quot;,author&amp;quot;),
  local!author: extract(ri!rawText, &amp;quot;author:&amp;quot;, &amp;quot;,price&amp;quot;),
  local!price: extract(ri!rawText, &amp;quot;price:&amp;quot;, &amp;quot;,title&amp;quot;),
  local!title: extract(ri!rawText, &amp;quot;title:&amp;quot;, &amp;quot;]&amp;quot;),

  {
    author: local!author,
    title: local!title, 
    quantity: local!quantity,
    price: local!price
  }
)
   &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In this example I establish each value as its own with() variable before wrapping up everything in a dictionary to be returned at the end.&amp;nbsp; This might seem slightly overcomplicated but separating the processing in such a way helps if you ever decide the dictionary names should be different, or if one particular field value needs pre-processing before being returned, etc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50187?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 19:40:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6bba84f8-ff27-45db-a6e2-ebd5ea6d5e7e</guid><dc:creator>Colton Beck</dc:creator><description>&lt;p&gt;It should be formatted as below, and your label names should match your CDT field names:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cast(
    typeof({type!Book()}),
        {{quantity:23,author:&amp;quot;Collectif&amp;quot;,price:3.74,title:&amp;quot;Peppa Pig: Fun at the Fair&amp;quot;},
        {quantity:7,author:&amp;quot;Judith Simanovsky&amp;quot;,price:4.99,title:&amp;quot;Panda Goes to the Olympics&amp;quot;}})&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Let me know if that works for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50186?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 19:34:36 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:787f1c79-ca12-490a-a3f6-c03aec2d81d2</guid><dc:creator>rishub</dc:creator><description>&lt;a href="/members/coltonb"&gt;Colton Beck&lt;/a&gt;  I tried to use it like&lt;br /&gt;
&lt;br /&gt;
cast(typeof(type!Book),local!value)  &lt;br /&gt;
&lt;br /&gt;
Here Book is my CDT &amp;amp; local!value is &lt;br /&gt;
[success:true,error:,parameters:[BOOKS_CURSOR:[quantity:23,author:Collectif,price:3.74,title:Peppa Pig: Fun at the Fair]; [quantity:7,author:Judith Simanovsky,price:4.99,title:Panda Goes to the Olympics]],result:]&lt;br /&gt;
&lt;br /&gt;
But this is giving error:&lt;br /&gt;
&lt;br /&gt;
Expression evaluation error at function &amp;#39;cast&amp;#39; [line 15]: Could not cast from Text to Type. Details: CastInvalidCould not cast from Text to Type. Details: CastInvalid&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50185?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 19:06:26 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:e494177a-0166-47ba-b2c3-0ad03a02f1ee</guid><dc:creator>Colton Beck</dc:creator><description>Where local!value contains your key:value parameters.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50184?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 19:03:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f6de0f2a-693b-471b-96bd-1bb560c72c61</guid><dc:creator>Colton Beck</dc:creator><description>&lt;p&gt;Look into the &lt;a href="https://docs.appian.com/suite/help/17.3/fnc_informational_cast.html"&gt;cast()&lt;/a&gt; function.&lt;br /&gt;Something like this should work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cast(
    typeof(type!Typeofyourcdt),
        local!value)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50183?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 19:00:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ec4b3a41-5135-45ad-ab69-74ced15d6cf6</guid><dc:creator>rishub</dc:creator><description>&lt;a href="/members/puspendup403"&gt;Puspendu Pal&lt;/a&gt;  Can you please guide how can I do that? The result is coming as single string.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Convert String into CDT</title><link>https://community.appian.com/thread/50182?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 18:53:52 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:35fa0ee5-0dd2-4446-9396-45c9b5fcc7d7</guid><dc:creator>Puspendu Pal</dc:creator><description>Hello,&lt;br /&gt;
&lt;br /&gt;
Your result  value is empty.  But you should be able to use the  index function recursively to get the  data.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>