Is it possible to map specific fields from one CDT to another within an expressi

Is it possible to map specific fields from one CDT to another within an expression rule? So far I have been unsuccessful. Code is below - any suggestion would be greatly appreciated!


with(
cacData : rule!CAC_getExceptionByIDAndNotStatus(ri!crsExceptionID, "Cleared"),
crsData: rule!CAC_getCRSExceptionCollateralByActivityIdAndCollateralCode(pv!cacData.activityID, pv!cacData.typecode),

cacData.crsExceptionID : crsData.ActivityId_Int,
cacData.description : crsData.Description_txt,
cacData.exceptionType : crsData.Type_Txt,
cacData.crsStatus : crsData.Status_Txt,
cacData.deadlineDate : crsData.DeadlineDate_Dte,
cacData.addedDate : crsData.AddedDate_Dte,
cacData.descriptionLine1: crsData.Description1_Txt,
cacData.descriptionLine2: crsData.Description2_Txt,
cacData.recordcd : crsData.RecordCd_Txt,
cacData.loanNumber : crsData.LoanNbr_Int,
cacData.customerNumber : toInteger(crsData.Customer_Dec),
cacData.tiedTable : crsData.TiedTable_Txt,
ca...

OriginalPostID-157746

OriginalPostID-157746

  Discussion posts and replies are publicly visible

  • ...cData.cusipissue : crsData.CusipIssue_Txt,
    cacData.cusipissuer : crsData.CusipIssuer_Txt,
    cacData.lastpriceingdate : crsData.LastPriceing_Date,
    cacData.locationcode : crsData.LocationCode_Txt,
    cacData.recorddate : cacData.recorddate,
    cacData.typecode : crsData.TypeCode_txt,
    cacData.unitsballance : if(isnull(crsData.UnitsBallance_Dec), 0, crsData.UnitsBallance_Dec),
    cacData.unitsvalue : if(isnull(crsData.UnitsValue_Dec), 0, crsData.UnitsValue_Dec),
    cacData.unitspledged : crsData.UnitsPledged_Dec,
    cacData.baseid : if(isnull(crsData.BaseId_Int), 0, crsData.BaseId_Int),
    cacData.basetable : crsData.BaseTable_Txt,
    cacData.collateralID : crsData.TiedId_Int,
    cacData.customerName : crsData.FulName_Txt,
    cacData.costCenter : crsData.ReptBr_Int,
    cacData.officerNumber : crsData.Officer_Txt,
    cacData.exceptionDate : crsData.DeadlineDate_Dte,
    cacData.activityType : crsData.Type_txt,
    cacData.collateralForm : crsData.Form_Int
    cacData.companyNo : crsData.Company_Int,
    todatasubset(cac...
  • @ashleyb If I understand your question correctly, following snippet resolves your query:

    with(
    \tlocal!cacData : rule!CAC_getExceptionByIDAndNotStatus(ri!crsExceptionID, "Cleared"),
    \tlocal!crsData: rule!CAC_getCRSExceptionCollateralByActivityIdAndCollateralCode(pv!cacData.activityID, pv!cacData.typecode),
    \t
    \t/*Assuming that local!cacData has a single value*/
    \tlocal!newCacData:type!cacData(
    \ tcrsExceptionID:local!cacData.ActivityId_Int,
    \ tdescription: local!crsData.Description_txt,
    \ texceptionType: local!crsData.Type_Txt,
    \ tcrsStatus: local!crsData.Status_Txt,
    \ t... and so on
    \t),
    \t
    \t/*Assuming that local!cacData has multiple values*/
    \tlocal!newCacData:apply(
    \ ttype!cacData(
    \ tcrsExceptionID:,
    \ tdescription: _ ,
    \ texceptionType: _,
    \ tcrsStatus: _,
    \ t... and so on
    \ t),
    \ tmerge(
    \ tlocal!cacData.ActivityId_Int,
    \ tlocal!crsData.Description_txt,
    \ tlocal!crsData.Type_Txt,
    \ tlocal!crsData.Status_Txt
    \ t...and so on
    \ t)
    \t),
    \ttodatasubset(local!newCacData,topgainginfo(1,-1))
    )

    Not sure why there is local as well as process variable for cacData, but you could use the PV as long as you place the above content in the process model directly, else you may pass the PV as an rule input to the rule in which above contents are encapsulated.
  • @ashleyb Have tried the plug-in "CDT Manipulation".
    this plug-in allows you to Update, Join, expand operation on CDTs.
    Have a look on this component
    https://forum.appian.com/suite/tempo/#!/records/type/components/item/i8BCLGOdlMUpdGVqT-RV7oRg74uEGJO5yIdNklp-1ZtH3F1tosyebSo7rEoKHh1XQ/view/summary
  • HI ashleyb

    Yes it can be done.

    But by looking at your code, I would suggest you to pass the variables in to the expression rather than accessing the parent variable with out passing as a parameter. This is the best practice and it give more readability and maintainability to the code.

    Once you have the first two CDTs populated using the rules construct a new CDT using 'type' construct and map the desired value and return the newly created CDT from the expression.

    for ex:

    local!firstCDT : rule!CAC_getExceptionByIDAndNotStatus(ri!crsExceptionID, "Cleared"),
    local!secondCDT : rule!CAC_getCRSExceptionCollateralByActivityIdAndCollateralCode(ri!cacData.activityID, ri!cacData.typecode),
    
    local!returnCDT: 'type!{yourcdtnamespace}yourCDTname'(firstEle : local!firstCDT.ActivityId_Int,secondElement: local!secondCDT.LoanNbr_Int),

    Regards

    Suresh