Quote Adapter-Creating Quote Dtl?

Having a bit of trouble understanding what I’m doing wrong with my quote adapter. I’m creating a quote detail record from a quote adapter.
I call the methods in the order I find them in the trace log.

bool dtl = adapterQuote.GetNewQuoteDtl(adapterQuote.QuoteData.QuoteHed[0].QuoteNum);
if(dtl){
	//ChangePartNumMaster
	bool lIsPhantom = false;
	bool lIsSalesKit = false;
	string uomCode = String.Empty;
	string rowType = String.Empty;
	Guid sysRowID = Guid.Empty;
	bool salesKitView = false;
	bool removeKitComponents = false;
	bool suppressUserPrompts = false;
	bool runChkPrePartInfo = true;
	string vMessage = String.Empty;
	string vPMessage = String.Empty;
	string vBMessage = String.Empty;
	bool vSubAvail = false;
	string vMsgType = String.Empty;
	bool getPartXRefInfo = true;
	bool checkChangeKitParent = true;
	string cDeleteComponentsMessage = String.Empty;
	bool multipleMatch = false;
	bool promptToExplodeBOM= false;
	string explodeBOMerrMessage = String.Empty;
	adapterQuote.ChangePartNumMaster(ref partNum,ref lIsPhantom, ref lIsSalesKit, ref uomCode, rowType, sysRowID, salesKitView, removeKitComponents, suppressUserPrompts, runChkPrePartInfo, out vMessage, out vPMessage, out vBMessage, out vSubAvail, out vMsgType, getPartXRefInfo, checkChangeKitParent, out cDeleteComponentsMessage, out multipleMatch, out promptToExplodeBOM, out explodeBOMerrMessage);
	errorLocation  = "366";
	//ChangePartNum
	adapterQuote.ChangePartNum(false, String.Empty);
	//add drawNum
	drawNum = RandomString(7);	
	adapterQuote.QuoteData.QuoteDtl[0].DrawNum = drawNum;	
	errorLocation = "373";
	adapterQuote.Update();
}

I catch the exception message of “Part is Required” when this code is run and it occurs right before the last adapter update. Seems that I am providing the correct information for it to create a Quote Dtl record, but can anyone see what I’m missing?

I’ve also attempted setting the field values before and after the ChangePartNum method fires, but any time I call the update, I get the Part Num Is Required message.
I definitely think I’m missing something on this one, any help would be appreciated.

if(dtl){
//ChangePartNumMaster
bool lIsPhantom = false;
bool lIsSalesKit = false;
string uomCode = String.Empty;
string rowType = String.Empty;
Guid sysRowID = Guid.Empty;
bool salesKitView = false;
bool removeKitComponents = false;
bool suppressUserPrompts = false;
bool runChkPrePartInfo = true;
string vMessage = String.Empty;
string vPMessage = String.Empty;
string vBMessage = String.Empty;
bool vSubAvail = false;
string vMsgType = String.Empty;
bool getPartXRefInfo = true;
bool checkChangeKitParent = true;
string cDeleteComponentsMessage = String.Empty;
bool multipleMatch = false;
bool promptToExplodeBOM= false;
string explodeBOMerrMessage = String.Empty;
adapterQuote.ChangePartNumMaster(ref partNum,ref lIsPhantom, ref lIsSalesKit, ref uomCode, rowType, sysRowID, salesKitView, removeKitComponents, suppressUserPrompts, runChkPrePartInfo, out vMessage, out vPMessage, out vBMessage, out vSubAvail, out vMsgType, getPartXRefInfo, checkChangeKitParent, out cDeleteComponentsMessage, out multipleMatch, out promptToExplodeBOM, out explodeBOMerrMessage);

//ChangePartNum
errorLocation = “359”;
adapterQuote.ChangePartNum(false, String.Empty);
adapterQuote.QuoteData.QuoteDtl[0].Company = adapterQuote.QuoteData.QuoteHed[0].Company;
adapterQuote.QuoteData.QuoteDtl[0].QuoteNum = adapterQuote.QuoteData.QuoteHed[0].QuoteNum;
adapterQuote.QuoteData.QuoteDtl[0].QuoteLine = 0;
adapterQuote.QuoteData.QuoteDtl[0].CustNum = adapterQuote.QuoteData.QuoteHed[0].CustNum;
adapterQuote.QuoteData.QuoteDtl[0].PartNum = partNum;
adapterQuote.QuoteData.QuoteDtl[0].RowMod = “A”;

errorLocation = “373”;
//update
adapterQuote.Update();
}

Where are you setting the variable partNum?

I set it outside the method, but I’ve also tried hard coding it into the method. Neither seems to work for me.

try

adapterQuote.QuoteData.QuoteDtl[0].PartNum = partNum; // set this before calling:
adapterQuote.QuoteData.QuoteDtl[0].PartDescription = partNum; // leave for testing
adapterQuote.ChangePartNum(false, String.Empty);

That worked

adapterQuote.QuoteData.QuoteDtl[0].PartNum = “10017000”;
adapterQuote.QuoteData.QuoteDtl[0].LineDesc = “10017000”;
adapterQuote.ChangePartNum(false, String.Empty);

errorLocation = “373”;
//update
adapterQuote.Update();

Thank you for your help!

Awesome! I just happened to have a snippet from @Edge as reference =) which is similar but BO version for Part.

if(!partBO.PartExists(testPart))
{       
    partBO.GetNewPart(ds);
    ds.Part[0].PartNum = testPart;
    ds.Part[0].PartDescription = testPart;
    ds.Part[0].TrackLots = true;
    partBO.ChangePartNum(testPart,ds);
    partBO.Update(ds);
}

I think it can be pretty confusing what needs to be set before a certain method will perform correctly. In the code example above it looks like he’s calling the BO directly, which accepts a dataset as part of the method parameters. In the adapters though, I’ve noticed that they often have a different set of parameters to call the same method than the BO does.
Thanks again, been pulling my hair out on this one!

Actually if you look at the trace with the Changes Only Option it will show you the dataset which fields changed. So that means those fields need to be set before the method call is made.

1 Like

That’s a good tip, I’ll definitely be using it in the future! Thanks