Compare Data Changes in CDT

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

Parents
  • 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
    )
    )
Reply
  • 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
    )
    )
Children
No Data