Dear Team,
I’m trying to generate duplicate (auto-generate) part number. But I’m able to get the source part number only, the other part number’s are not able get it.
I’m tried in BPM method like Pre-Processing, Post-Processing the both methods are not calling in click on the Action -> Duplicate Part Menu. Then I tried the Base processing directive the BPM also call and Source Part Number also get it. But I’m not able to proceed the auto generation codes.
Kindly help me on this.
Below Code I’m tried in BPM (Base Processing):
string ItemGrp = string.Empty;
string ItemSubGrp = string.Empty;
string tmpConcateItemGrp = string.Empty;
int AutoGenNum = 0;
int incvalue=0;
var ttPartRow = ( from g in ttPart where (g.RowMod == “A”) select g ).FirstOrDefault();
if (ttPartRow != null)
{
ItemGrp = Convert.ToString(ttPartRow[“Item_Group_c”]);
ItemSubGrp = Convert.ToString(ttPartRow[“Item_SubGroup_c”]);
tmpConcateItemGrp = Convert.ToString(ItemGrp) + Convert.ToString(ItemSubGrp);
var dbPartRow = Db.Part.AsEnumerable().Where(x => x.PartNum.StartsWith(tmpConcateItemGrp)).Select(p => p[“PartNum”]);
if(dbPartRow.Count()> 0)
{
int tmp;
incvalue = dbPartRow.AsEnumerable().Select(x => int.TryParse(x.ToString(),out tmp) ? tmp : 0).Max();
AutoGenNum=Convert.ToInt32(incvalue)+1;
ttPartRow.PartNum = Convert.ToString(AutoGenNum);
ttPartRow.InActive = true;
}
else
{
ttPartRow.PartNum = Convert.ToString(tmpConcateItemGrp.ToString()) + AutoGenNum.ToString(“0001”);
ttPartRow.InActive = true;
}
}