Adding Quote to Project C#

I’m trying to add a quote to the Project Entry Form. I’ve tried this through the project adapter/BO and also the quote adapter/

  string pcWarningMsg;
  string opMethMsg;
  ProjectAdapter projectAdapter = new ProjectAdapter(oTrans);
  projectAdapter.BOConnect();
  projectAdapter.GetByID("TEST");	
  projectAdapter.AddProjectQuote(11534, 1, out pcWarningMsg, out opMethMsg);
  projectAdapter.Update();

When I run this (the project and quote/line exist) I receive the error that “Project has not changed.” Does anyone have any insight on this?

Thanks

I’ve seen this with other business objects. I’d use the BL tester in combo with detailed trace logs to view what fields in the dataset changed in addition to the parameters being passed into it. Often, you’ll need to set certain fields and THEN call the method for it to accept the change.

Hi Dan,

The ProjectID is stored on QuoteDtl since a Project can have multiple quotes and a Quote can point to multiple projects. To associate a Quote line to a Project, I would use the QuoteAdapter, that is if I understand what you’re trying to do.

Mark W.

So I’m getting closer. It has something to do with preventing quotes from being changed. I can’t actually add a quote to a project manually through quote entry, but I can add it from project entry. So somehow the project entry’s function bypasses the prevent changes.

So it wasn’t a simple BO or Adapter call. I literally had to set every field in the DataSet.

  ProjectAdapter projectAdapter = new ProjectAdapter(oTrans);
  projectAdapter.BOConnect();
  projectAdapter.GetByID("TEST");
  projectAdapter.GetNewProjectQuot("TEST");
  projectAdapter.ProjectData.Project[0].RowMod = "U";
  int qLines = projectAdapter.ProjectData.ProjectQuot.Rows.Count;
  projectAdapter.ProjectData.ProjectQuot[qLines].Company = session.CompanyID;
  projectAdapter.ProjectData.ProjectQuot[qLines].CustomerName = "Test Customer";
  projectAdapter.ProjectData.ProjectQuot[qLines].QuoteNum = 11534;
  projectAdapter.ProjectData.ProjectQuot[qLines].QuoteLine = 1;
  projectAdapter.ProjectData.ProjectQuot[qLines].ExpectedQty = 1;
  projectAdapter.ProjectData.ProjectQuot[qLines].DocUnitPrice = 1;
  projectAdapter.ProjectData.ProjectQuot[qLines].CurrencyCode = "USD";
  projectAdapter.ProjectData.ProjectQuot[qLines].OkToReassociate = false;
  projectAdapter.ProjectData.ProjectQuot[qLines].PartNum = "TESTPART";
  projectAdapter.ProjectData.ProjectQuot[qLines].Rev = "";
  projectAdapter.ProjectData.ProjectQuot[qLines].UM = "EA";
  projectAdapter.ProjectData.ProjectQuot[qLines].UnitPrice = 1;
  projectAdapter.ProjectData.ProjectQuot[qLines].CurrencyCode = "USD";
  projectAdapter.ProjectData.ProjectQuot[qLines].ProjectID = "Test";
  projectAdapter.ProjectData.ProjectQuot[qLines].SysRowID = Guid.NewGuid();
  projectAdapter.ProjectData.ProjectQuot[qLines].BitFlag = 0;
  projectAdapter.ProjectData.ProjectQuot[qLines].RowMod = "A";
  
  projectAdapter.Update();
  projectAdapter.Dispose();
1 Like

Most likely, you just needed to call Update after setting that RowMod = “U”. My assumption (and you know how that goes) is that after you updated the adapter, it would have populated a 'blank" row - which had the defaults.

From there you would still do pretty much what you’ve done below, with exception of setting some of the fields (like Company, and RowMod)

Thanks Chris.

I wonder if calling AddProjectQuote would have done the trick after that.

I dont have that DLL loaded up in decomp at the moment, whats the signature of the AddProjectQuote method?

Dan,

I don’t think this is persisting like you think it will. Aren’t the “Related” items on the Project just look-ups to the original documents (Quotes, Orders, etc.)? I think when you call up a project, it fills the temporary ProjectQuot table but that’s not persisted in the database - at least I can’t find a table for it.

If I’m not mistaken (always possible), Add a Project Quote actually opens Opportunity/Quote Entry and it populates the project field on the detail records. From Help:

Add Quote To Project

Select the Add Quote To Project command to launch the Quote Line Search window. In the Quote Line Search window, search for and select a quote line that you want to link to a project.

I could be fill of Chris, er, I mean :poop: but I think all of the "Add a XXX to a Project functions are actually updating records outside the project itself.

Mark W.

1 Like

My original solution was to go through Quote BO or Adapter. I wrote the solution, it worked, but only if I had Prevent Changes NOT set on quote. It seems that ProjectQuot dataset can bypass that setting.

1 Like

Do you know which table this is getting stored? When you pull the project back up, does it bring in the quote? You can right-mouse click it and open the quote?

Mark W.

Wait a minute. It’s actually doing the “Search update quotedtl” in the background? That’s pretty cool @duckor

I tied a BAQ to a grid with filtering fields to narrow it down so that I can iterate through any selected rows and add them to the project instead of clicking action>add quote to project>search>find the line>click ok>repeat per line.

Since we have 5-15 quoted lines this becomes a nightmare, now its just click the ones you want and click add. (Which reminds me I should limit the number of selected in case they hit CTRL+A and click add)

If I have to pull the grid data into a dataset into a foreach I’m fine with that. What I have now does everything you asked.

1 Like

deadtome

2 Likes

Hey man, I owe you a beer. In the meantime, I’ll have to eat some :poop: of my own…

2 Likes

Dan,

I use web services more than adapters so I tested this in the BL tester but try this using the adapter.

projectAdapter.GetByID(“TEST”);

projectAdapter.ProjectData.Project[0].RowMod = “U”; <- This is allowing the update to occur from your original issue.

projectAdapter.AddProjectQuote(11534, 1, out pcWarningMsg, out opMethMsg); <- and then when this is invoked it is adding the new row with the Quote data

projectAdapter.Update();

Scott

3 Likes

I had that in there originally, but it seems you need the RowMod before the change… I had it after the AddProjectQuote. I always thought that the RowMod was just tagging the record to be updated at Update().

Thanks for clearing that up @litzer67 & @Chris_Conn!

1 Like