How to Concatenate in BPM Custom Code

I have 1 PO Detail Line with a multiple PO Release Number due to different Project ID.

Now, my target is to concatenate multiple Project ID in PORel to Project ID in PODtl.

I have successfully passed a single project ID from PORel to PODtl. But now I’m stuck in concatenate if multiple project ID found in PORel.

This is what I’ve done to pass the single project ID:

   foreach(var ttPR_itor in (from r in Db.PORel select r)){
string relCompany = ttPR_itor.Company;
int relPONum = ttPR_itor.PONum;
int relPOLine = ttPR_itor.POLine;
string relttg_ProjectID_c = ttPR_itor.ttg_ProjectID_c;
string PD_PODtl_ttg_ProjectID_c = " ";

foreach(var ttPD_itor in (from r1 in Db.PODetail where r1.Company == relCompany && r1.PONUM == relPONum && r1.POLine == relPOLine select r1))   {
  var tsPODtl = new Erp.Tablesets.PODetailRow();
  //tsPODtl.SetUDField<System.String>("PODtl_ttg_ProjectID_c", relttg_ProjectID_c);
  ttPD_itor.PODtl_ttg_ProjectID_c = relttg_ProjectID_c;
//  PD_PODtl_ttg_ProjectID_c = ttPD_itor.PODtl_ttg_ProjectID_c;
  tsPODtl.RowMod = "U"; 
  }

}

2 release in PO Rel
image

Only can return 1 project ID due to 1 PO Line
image
Thanks in advance. Any help or suggestions would be appreciated.

ok… BEFORE you do this, I want you to know that your block of code looks at EVERY RELEASE and processes it. there is no filter.

I did the same thing here… This appears to be some form of data fix. This block of code that I am showing will do the same thing!!!

OK… Warning done… I think your problem is that you are looking at the RELEASE first and then populating the DETAILS and it overwrites the previous version.

Instead, the concept I chose was to look at the DETAIL first, and then gather all the data from the related release. Since you only wanted the project ID, I selected that to a list, and then did a string join to assemble them with commas.

WARNING: This is NOT TESTED… it WILL go through ALL your PO Details and update EVERY ONE. if that is what you wanted to do, then here it is:


foreach (var dbPODtl in Db.PORel) {

    var projectList = Db.PORel.Where(x =>
        x.Company &&
        x.PONum == dbPODtl.Company &&
        x.PONum == dbPODtl.PONum &&
        x.POLine == dbPODtl.POLine && ).Select(x.relttg_ProjectID_c).ToList();

    dbPODtl.PODtl_ttg_ProjectID_c = string.Join.Join(",", projectList);  //convert list to comma delimited string

}