Automatic Quote Recalc

Hello,

We have a tab on our Quote/Opportunity form that allows users to recalc quotes. They are warned to recalc the quote and have to click a button called (Re)calculate to get accurate pricing:

The issue I am being told is that end users have to go to this tab to recalc all quotes once they are created and there are time where users will not do so and the necessary pricing fields will stay at 0.00 and cause issues. The fields in the above picture are tied to the QuoteHed table using Number01, Number03, etc.

Is there a way to run this recalc once the quote is created and the user goes into it for the first time? The recalc would only need to be run upon the initial creation and any other time it needs to be recalculated it will need to be triggered manually using the button. I will attach the button click code that the system is currently using:


private void btnRecalculate_Click(object sender, System.EventArgs args)
{
	//Fire Update in case any change to Pricing fields have been done
	oTrans.Update();

	try
	{
		oTrans.PushStatusText("Calculating Prices...", true);
		Ice.Adapters.UD01Adapter ud01Adapter;

		ud01Adapter = new UD01Adapter (oTrans);
		ud01Adapter.BOConnect();

		edvCallContextBpmData.dataView[edvCallContextBpmData.Row]["Number01"] = edvQuoteHed.dataView[edvQuoteHed.Row]["QuoteNum"];
		
		SearchOptions opts  = new SearchOptions(SearchMode.AutoSearch);
		opts.DataSetMode = DataSetMode.RowsDataSet;
		opts.PreLoadSearchFilter  = "Key1 = 'QuoteRecalc'";  
		ud01Adapter.InvokeSearch(opts);	
		
		oTrans.Refresh();
	}
	catch (Exception e)
	{
		// EpiMessageBox.Show(e.ToString());
		edvCallContextBpmData.dataView[edvCallContextBpmData.Row]["Number01"] = 0;
		
	}finally{
		oTrans.PopStatus();
	}	

}

Unfortunately I am not as knowledgeable in regards to Epicor BO’s as I’d like to so I am sure there is an easier way to achieve what I want without brute forcing c# code that is not efficient.

You can hang the same code on a different event (like and EpiView Notification, pick detail or header depending on what you use to calculate) , then check a condition before actually running the code. I’m not going to be much help in making the code for you, but you should be able to take the code that you have there, and make it a function that you can call in the different places you want to use it so you can maintain only one area. Then on the view notification one, throw a check in there to see if a certain condition is met before it actually runs the calc. Sorry about being kind of general, I’m still learning C#.

Thanks.

I can try dumping the code into the existing EpiViewNotification that we are already using which highlights whether or not the user needs to recalc or not. This is what it is currently doing:

So I tried adding cases to trigger the update but can’t seem to get it to work.

The CheckBox02 gets checked once the quote is created after the import finishes:

I would assume this would work ad the other cases work but I may be missing something.

Update: I tried adding the code to a function we have called afterfieldchange and it still does not fire off

private void QuoteHed_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		switch (args.Column.ColumnName)
		{
			case "CheckBox02":

				
				if (Convert.ToBoolean(args.ProposedValue))
				{
					checkbox02 = true;
					edvQuoteHed.dataView[edvQuoteHed.Row]["RowMod"] = "U";
					
//Added code here as this is the box that I want to be checked
				}
			

			break;

			case "ShortChar02":

				oTrans.Update();	
			break;

			case "ShipViaCode":

				
				if (!args.ProposedValue.ToString().Equals("IF"))
				{
					edvQuoteHed.dataView[edvQuoteHed.Row]["Number01"] = 0;
				}
				

			break;

			case "ShipToNum":

				var adapterShipTo = new ShipToAdapter(this.oTrans);
				adapterShipTo.BOConnect();
				var bo = (Erp.Proxy.BO.ShipToImpl)adapterShipTo.BusinessObject;
				var cn = Convert.ToInt32(edvQuoteHed.dataView[edvQuoteHed.Row]["CustNum"]);
				var dsShipTo = bo.GetByID(cn, args.ProposedValue.ToString());
				adapterShipTo.Dispose();
	
				// MessageBox.Show(GetTablesRowsAndFieldsInDataSet(dsShipTo));

				var shipToTable = dsShipTo.Tables["ShipTo"];
				var shipToRow = shipToTable.Rows[0];
				var shipToMasterQuote = Convert.ToInt32(shipToRow["ShipMstrQuote_c"]);
	
				
				edvQuoteHed.dataView[edvQuoteHed.Row]["Number10"] = shipToMasterQuote;
				edvQuoteHed.dataView[edvQuoteHed.Row]["MstrQuote_c"] = shipToMasterQuote;
			
			break;
		}
	}

Still require me to click the button. There were some other instances we had of checking for rows and the code didn’t work their either.

Kind of confused as to what exactly I am needing to do in regards to the oTrans.Update/oTrans.Refresh.

I ended up creating a separate event that triggered off that checkbox being changed. I altered the code to not run through a try/catch statement and got it working. I would have preferred to get it to work in our original events but this does what I need it to.

This thread can be closed.

Thanks

1 Like