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
Replies
11 replies
Subscribers
7 subscribers
Views
4921 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I want to update an A cdt with another B cdt which is subset of A cdt. Is there
shaoyongw
over 7 years ago
I want to update an A cdt with another B cdt which is subset of A cdt. Is there any existing function or an easy way to achieve this goal?
OriginalPostID-218216
OriginalPostID-218216
Discussion posts and replies are publicly visible
0
Tim
Certified Lead Developer
over 7 years ago
Do the field attributes have the same name? If so you can just save the PV into the subset PV, Appian will map the values by attribute name
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sparshs
over 7 years ago
You can use a script task to do that , you just have to map the values from B cdt to A cdt in the output expression. Rest Appian will take care.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sidhant Behura
over 7 years ago
You can create a expression rule and pass cdtA and cdtB into it. Use type!cdtA() and map the cdtA fields with cdtB fields.
Ex:
type!cdtA(
id: if(APP_isnull(ri!cdtB.id),ri!cdtA.id,ri!cdtB.id)
name: if(APP_isnull(ri!cdtB.name),ri!cdtA.name,ri!cdtB.name)
gender: if(APP_isnull(ri!cdtB.gender),ri!cdtA.gender,ri!cdtB.gender)
age: ri!cdtA.age /* If age field is present only in cdtA and not in cdtB */
)
This way you can update the cdtA efficiently preserving the non-common fields also.
Lets me know if the information was helpful.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 7 years ago
You can also use updatecdt function to update specific fields. Say if you have 10 field in your cdt and you want to update only one field (which is also a cdt as in your case), then try something like
updatecdt(
ri!parentCDT,
{
childCDT: rule!returnModifiedChildValues(ri!parentCDT.childCDT)
}
)
Here rest of the 9 field values will be preserved.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Sidhant Behura
over 7 years ago
@kumaraveln - Correct me if I am wrong updatecdt is not OOTB i.e its a shared component and it is compatible till Appian 7.6 version. Please share some light on the expression rule returnModifiedChildValues().
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
mohammedz
A Score Level 2
over 7 years ago
Hi Shaoyongw,
Create a expression rule with two rule inputs of type (AnyType) and pass your A CDT and B CDT
Define in fn!type that to which CDT you want to update.. Follow the code like below it will do what actually you want to do in a Expression Rule
'type!{urn:xxxx:xxxxxx}<CDT_NAME>'(
name:ri!ACDT.name,
age:ri!BCDT.age,
address:ri!ACDT.address,
workStream:ri!BCDT.workStream
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 7 years ago
@sidhantb: Yes., its not OOTB but we are still using it in 16.1 without any issue. I did not understand the use case here completely so just thought of sharing an option to easily update CDTs. When we use updatecdt() we don't need to do any type casting and no need to mention all the fields as we do for updatearray() or normal variable to variable mapping.
It will be useful when we update very few fields among a large CDT.
And rule!returnModifiedChildValues here is just to do any data manipulation they want to do with the child cdt values. Like updating a lastModifiedDate field inside the child.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
kumaraveln
over 7 years ago
@shaoyongw: If you could paste the screenshot of your CDTs here, we could get a clear picture of what you are trying to achieve.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
mohammedz
A Score Level 2
over 7 years ago
Guyz it's just an small requirement
.. if we do type cast in Expression rule or by mapping in case of process modelling will do the job .... whatever user wants for his own requirement ...
Chill .... !!!!!!!!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
shaoyongw
over 7 years ago
Thank you all for your response! At last, I use @sidhantb's way to update the cdt.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>