Typically it’s just you Query it based on Quote Key Fields, just check the DB for a QuoteNum related one.
Here is an example of me creating a NEW Quote Audit Record (Just to demo the concept of creating)
using (var txScope = IceDataContext.CreateDefaultTransactionScope())
{
Ice.Diagnostics.Log.WriteEntry(String.Format("[ {0} ] Starting Transaction...", bpmName));
// Create New
Erp.Tables.QuoteAdt QuoteAdt = new Erp.Tables.QuoteAdt();
Db.QuoteAdt.Insert(QuoteAdt);
QuoteAdt.Company = Session.CompanyID;
QuoteAdt.QuoteNum = quoteRow.tqh.QuoteNum;
QuoteAdt.ChangeDate = quoteRow.tqh.ChangeDate;
QuoteAdt.ChangeTime = System.Convert.ToInt32(DateTime.Now.TimeOfDay.TotalSeconds);
QuoteAdt.ChangedBy = Session.UserID;
QuoteAdt.ChangeDescription = "[CHANGES] \n \n" + changeList;
// Do I have to call - Validate does it
//Db.QuoteAdt.Update(QuoteAdt)
// Commit to Database
Db.Validate(QuoteAdt);
// Complete Transaction
txScope.Complete();
Ice.Diagnostics.Log.WriteEntry(String.Format("[ {0} ] Ending Transaction...", bpmName));
}
What you can do is you can use BufferCopy once you Query the original Call Record(s) and Duplicate it:
Example 1 (Jose)
BufferCopy.CopyExceptFor(curRev, newRev, "SysRowID","SysRevID","RevisionNum", "EffectiveDate", "RowMod");
Example 2 (Me Duplicating my UD06 - i do something similar with other UD Tables I use):
MOST PEOPLE MISS THIS! If you have any UD Tables, DUPLICATE will not magically bring them over.
// Main Query
var quotes =
from tqd in ttQuoteDtl
select tqd;
foreach (var quoteRow in quotes)
{
// Get Existing UD06
Ice.Tables.UD06 UD06 = (
from ud06 in Db.UD06
where ud06.Key1 == Convert.ToString(sourceQuote) && ud06.Key2 == Convert.ToString(quoteRow.QuoteLine)
select ud06
).FirstOrDefault();
if (UD06 != null)
{
using (var txScope = IceDataContext.CreateDefaultTransactionScope())
{
// Create New
Ice.Tables.UD06 NewUD06 = null;
Db.UD06.Insert(NewUD06);
BufferCopy.CopyExceptFor(UD06, NewUD06, UD06.ColumnNames.SysRevID, UD06.ColumnNames.SysRowID); // MAGIC
NewUD06.Key1 = Convert.ToString(quoteRow.QuoteNum);
NewUD06.Key2 = Convert.ToString(quoteRow.QuoteLine);
// Commit to Database
Db.Validate(NewUD06);
// Complete Transaction
txScope.Complete();
}
}
}
I assume you would do something similar, Query existing Call Record, then start creating your own, but using a foreach() loop and doing BufferCopy’s just, excluding SysRevID, SysRowID, QuoteNum etc… what u don’t want to duplicate. Then before you call Db.Validate() you just change what you want changed:
// After BufferCopy
YourNewCallRecord.Key1 = Convert.ToString(quoteRow.QuoteNum); // populate the new QuoteNum
// Db.Validate
There’s a little section on BufferCopy in this Guide: Sign In
You just have to figure out the RelatedToFile and Keys.
Example of someone Creating a CRMCall
CRMCall = new Erp.Tables.CRMCall();
Db.CRMCall.Insert(CRMCall);
CRMCall.Company = Session.CompanyID;
CRMCall.OrigDate = DateTime.Now.Date;
CRMCall.OrigTime = SecondsSinceMidnight(DateTime.Now.Date);
CRMCall.OrigDcdUserID = Session.UserID;
CRMCall.CallSeqNum = keyBlockNextCallSeqNum;
CRMCall.RelatedToFile = "Customer"; // You will prob need Quote or QuoteHed not sure check BAQ
CRMCall.Key1 = Convert.ToString(MktgLstDtl.CustNum); // QuoteNum (string)
CRMCall.Key2 = "";
CRMCall.Key3 = "";
CRMCall.CallCustNum = MktgLstDtl.CustNum;
CRMCall.CallShipToNum = MktgLstDtl.ShipToNum;
CRMCall.CallConNum = MktgLstDtl.ConNum;
CRMCall.CallContactType = "Customer";
CRMCall.CallTypeCode = ttMktgLstExpParam.CallType;
CRMCall.CallDesc = CallDescription;
CRMCall.CallText = Session.UserID + " / " + Convert.ToString(DateTime.Now.Date) + " / " + Convert.ToString(DateTime.Now.Hour) + ":" + Convert.ToString(DateTime.Now.Minute) + " / " + bMktgListResult.MktgListID + " / " + bMktgListResult.ListDescription;
Db.Validate(CRMCall);
Again - you will not create each one from Scratch if you use BufferCopy =) this is just to demo an example.
Make Adjustments to my examples to fit QuoteHed and Db.CRMCall