I’m trying to generate part number is auto-generation based on Item Group and Item-Subgroup. I used the below code. I’m trying the below code in BPM Method directive - (Pre-Processing.)
BPM Code:
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)
{
incvalue = dbPartRow.AsEnumerable().Select(x => Convert.ToInt32(x.ToString())).Max(); // this line am getting the error message like Input String was Not correct Format. But i’m using same code in another enhancement working fine.
AutoGenNum=Convert.ToInt32(incvalue)+1;
ttPartRow.PartNum = Convert.ToString(AutoGenNum);
ttPartRow.InActive = true;
}
Thanks for your help. I fixed the above issue. The below is working code
BPM Code:
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”]);