Hi,
we have requirement like we are calling one SP to get some data from DB. now we need to cast that SP response to one of the CDT.
we tried by casting some thing like
if( local!SPResponse.success,cast( typeof( { 'type!{urn:com:appian:types}<CDT Name>'() } ), local!SPResponse.result ), {} )
we are getting the results with target CDT having all the value are null. do we need to write any looping to assign individual elements or OOB casting will do for the same.
Please let us know if we are missing any thing for the same. if you can provide some sample it will be more help ful :)
Thanks in Advance.
Discussion posts and replies are publicly visible
try like this
if( local!SPResponse.success, 'type!{urn:com:appian:types}<CDT Name>'( id: index( local!SPResponse.result, "id", null ), xyz: index( local!SPResponse.result, "xyz", null ), abc: index( local!SPResponse.result, "abc", null ) ), {})
Thanks for the reply. its giving only one record. but my SP gave multiple Dictionary objects. i tried by looping but its not working. any thing more to add.
load( local!SPResponse, if( local!SPResponse.success, a!forEach( items: local!SPResponse.result, expression: 'type!{urn:com:appian:types}<CDT Name>'( id: index( fv!item, "id", null ), xyz: index( fv!item, "xyz", null ), abc: index( fv!item, "abc", null ) ) ), {} ))
with this we are getting only one record with targeted CDT. means data will be coming like
List of <CDT Name>: 1 item
<CDT Name>
id: 1;2;3;
xyz:"avc;xyz:aaa"
abc:"111;222;333"
all the data from the element is binding to target element with ";" separated.
Thanks.
is local!SPResponse.result dictionary ?
Casting as 'type!{urn:com:appian:types}<CDT Name>?list'() should do the trick.
Thanks!!!
Regards,
Hema
Yes. response from SP is some thing(default selected Formatted radio button) like
Dictionary success:
true
error: null (Text)
parameters: Dictionary
result: List of Dictionary: 7 items
Dictionary
id: 1
xyz: "4"
abc: "12345"
id: 2
xyz: "d"
abc: "1244"
id: 3
xyz: "4sk"
abc: "58474"
Thanks
can you share screen shot of what your sp is returning in rule
i hope this is issue is because of the result is coming like
{{{id:1,abc:"data",xyz:"124"},{id:2,abc:"data1",xyz:"234"},{id:2,abc:"data1",xyz:"234"}}}
if that is the value also it will work
load( local!data: { { { id: 1, abc: "data", xyz: "124" }, { id: 2, abc: "data1", xyz: "234" }, { id: 2, abc: "data1", xyz: "234" } } }, a!forEach( items: local!data, expression: { cdtId: fv!item.id, cdtABC: fv!item.abc, cdtXYZ: fv!item.xyz } ))
This issue being resolved by calling local!SPResponse.result[1] at for look items. Thanks for the help and support.