Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
+1
person also asked this
people also asked this
Replies
13 replies
Subscribers
10 subscribers
Views
11608 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Compare Data Changes in CDT
Shashank
over 8 years ago
HI ,
I am trying to capture the audit trail , for data changes in a CDT.
Is there any OOTB function , which might be helpful
Thanks
OriginalPostID-239248
Discussion posts and replies are publicly visible
0
Sachin
A Score Level 1
over 8 years ago
@Shashank please find the below shared component
forum.appian.com/.../summary
hope this is helpful
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
jagadeesh
Certified Lead Developer
over 8 years ago
Yes above one helped you to get changed attributes data from your CDTs. but your CDTs should contains primitive data types and shouldn't contain array variables
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chetany
A Score Level 1
over 8 years ago
It also will not work if the CDT is nested
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@shashankb Is it temporary or are you trying to persist it to the database? If it's later, did you consider delegating it to the database?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shashank
over 8 years ago
@sikhivahans , it is temporary only , i am not considering persisting the data for now as @chetany mentioned , the plugin is not able to handle nested cdts , I am still trying to figure out a way for that , any suggestion on that part also would be helpful , according to my requirement , the rule should be a generic one , which can handle any type of CDT and get the differences in data ( latest and the very previous one only)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shashank
over 8 years ago
@Bolluru Mahesh Sachin Anand , thanks for the shared component , it was helpful , but i am still trying to figure out a way to handle nested CDTs
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
Using some ideas from
forum.appian.com/.../e-238884
you should be able to implement a recursive expression to handle nested CDTs. First expression gets all field names. Then you create an expression that is applied to all fields in the CDT. It checks if the datatype is a multiple and/or a CDT. If yes, it calls the first expression on the sub structure.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
Did some small tests. It might not work for all cases, but can be a start:
CdtDiff(cdt1, cdt2):
=with(
local!fieldNames: apply(xpathsnippet(_, "name(*)"), xpathsnippet(toxml(ri!cdt1), "/*/*")),
apply(rule!CdtDiffField(ri!cdt1, ri!cdt2, _), local!fieldNames)
)
CdtDiffField(cdt1, cdt2, fieldName):
=with(
local!fieldOneType: runtimetypeof(index(ri!cdt1, ri!fieldName, null)),
local!fieldTwoType: runtimetypeof(index(ri!cdt2, ri!fieldName, null)),
local!fieldOneExits: tostring(index(ri!cdt1, ri!fieldName, "x_#")) <> "x_#",
local!fieldTwoExits: tostring(index(ri!cdt2, ri!fieldName, "x_#")) <> "x_#",
if(and(local!fieldOneExits, local!fieldTwoExits, local!fieldOneType = local!fieldTwoType),
if(local!fieldOneType < 1000,
{field: ri!fieldname, same: ri!cdt1[ri!fieldName] = ri!cdt2[ri!fieldName]},
{field: ri!fieldname, children: apply(rule!CdtDiff(_,_), merge(ri!cdt1[ri!fieldName], ri!cdt2[ri!fieldName]))}
),
false
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Shashank
over 8 years ago
@stefanh , thanks a lot it was very helpful, the "xpathsnippet" would be of great use to me , never thought of xpathsnippet for getting the field names
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 8 years ago
You are welcome :-)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>