I have a CDT (say CDTA) which contains a field for doc id that represents document in appian.
CDTB would contain the bad doc ids doesn't exist in appian anymore that i need to delete using delete datastore smartsvc
CDTC would contain the ones with doc ids that exist that i need to update using write to datastore smart svc
in simple terms, CDTC = CDTA (all records) - CDTB (bad records)
How can that be accomplished without having to loop twice ?
I am using following to filter out the bad records (CDTB)
a!localvariables(
local!data : ri!docsdata,
local!docstodelete: a!foreach(
items: local!data,
expression : if(isobjectexists("Document", fv!item.Doc_id), fv!item, {}
),
local!docstodelete.data
)
Then i tried using difference(CDTA,CDTB) but that doesn't work .. ;-(
Discussion posts and replies are publicly visible
you could use a wherecontains based on the the doc ID and then a revome to obtain only the good records.
Are you using difference() at the field level? If I'm understanding correctly, you have CDTA as an input which contains all documents, you are building CDTB based on docIds in CDTA that do not exist, and you want to build CDTC based on document IDs in CDTA that DO exist. That should be achievable with difference():
a!localVariables( local!CDTA: { {docId: 11}, {docId: 22}, {docId: 33}, {docId: 44}, {docId: 55}, {docId: 66} }, local!CDTB: { {docId: 33}, {docId: 44} }, difference( local!CDTA.docId, local!CDTB.docId ) )