Hi guys, I need a bit of help / advice on a small BPM which I am trying to write. I have a custom field (character03) on the QuoteDtl which holds a comma delimited character string. This string contains location references to be printed on labels. There is a check at the beginning to replace unwanted carriage returns double commas etc to hopefully end up with a string like this;
ref1,ref2,ref3,ref4,ref5…etc etc
So far so good. However, because we are in the construction industry and these references are usually floors of buildings which could have many products my users want to be able to enter the references like this
ref1[25],ref2,ref3[50],ref4,ref5[3]…etc etc.
I am a bit stuck on how to check this. Anybody done anything similar?
Here is where I am at the moment. All help and advice much appreciated.
Adrian.
var ttQuoteDtl_iterator = (from ttQuoteDtl_Row in ttQuoteDtl
where (ttQuoteDtl_Row.RowMod == "U")
select ttQuoteDtl_Row).FirstOrDefault();
// Check if a row exists.
// If it does make sure there are no extra commas or line feeds
if (ttQuoteDtl_iterator != null)
{
bool stringCorrect = false;
string refs = ttQuoteDtl_iterator["Character03"].ToString();
refs = refs.Replace("\r",",");
refs = refs.Replace("\n",",");
refs = refs.Replace(", ,",",");
refs = refs.Replace(",,",",");
ttQuoteDtl_iterator["Character03"] = refs;
// Get quantity required
int qty = Convert.ToInt32(ttQuoteDtl_iterator.OrderQty);
// Get number of refs in string;
int qtyRefs = refs.Split(',').Count();
if ((qty >= 1 && qtyRefs == 1) || qty == qtyRefs)
{
stringCorrect = true;
}
//Diagnostic message
string msg = "Ref string is " + refs + "\r\n"
+ "Order Qty is " + qty + "\r\n"
+ "Qty of refs is " + qtyRefs + "\r\n"
+ "Refs correct is " + stringCorrect;
throw new Ice.Common.BusinessObjectException(
new Ice.Common.BusinessObjectMessage(msg)
{
Type = Ice.Common.BusinessObjectMessageType.Information,
});
this.PublishInfoMessage(msg, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}