Load or replace currentdatarow

I am working on a screen customization for Opportunity/Quote Entry. I have placed an action menu item on the screen that sets some BPM variables and then calls UD01 to perform some actions using code below.

EpiDataView myccedv = oTrans.Factory("CallContextBpmData");
DataRow xrow = myccedv.CurrentDataRow;
if (xrow == null) { return; }
//first set the code so BPM engine knows what to run
xrow.BeginEdit();
xrow["Number01"] = myQuote;
xrow["Character20"] = "MagicLogic";
xrow.EndEdit();

//then call BPM engine to run logic
using (var u = new Ice.Adapters.UD01Adapter(this.oTrans)) {
 bool morePages;
 SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
 u.BOConnect();
 DataSet ds = u.GetList(opts, out morePages);
 u.Dispose();
}

The BPM on UD01.GetList performs a number of actions which may return an Epicor quote number in a BPM variable (Number03). If there is a value, I want to retrieve that quote to replace the screen.

var findq = Int32.Parse(xrow["Number03"].ToString());
xrow.BeginEdit();
xrow["Number01"] = 0;
xrow["Number03"] = 0;
xrow["Character20"] = "";
xrow.EndEdit();

EpiDataView edvQuoteHed = ((EpiDataView)(this.oTrans.EpiDataViews["QuoteHed"]));
System.Data.DataRow edvQuoteHedRow = edvQuoteHed.CurrentDataRow;

if (findq != 0)
{
	if(edvQuoteHed.CurrentDataRow!=null){
		var qhrow = edvQuoteHed.CurrentDataRow;
		qhrow.BeginEdit();
		qhrow["QuoteNum"] = findq;
		qhrow.EndEdit();
	}
	else {
		 //What if there was nothing in the view?  Must be something simple for an EpiGuru
	}
	oTrans.RefreshEverything();
}

This code works as long as the user already has a quote loaded on the screen. However, if they have not already retrieved a record, it cannot refresh the view. Is there a simple solution to this that someone would be able to help with? I apologize if this has been asked before or is obvious, but any help is appreciated!

Thanks,
Tanner

Not sure what you want to happen, but you could always select the first row (if it exists)

edvQuoteHed.Row = 0;

Thanks, I’ll try this. To clarify, if the form is opened from the menu without any QuoteHed data, will there be a row 0 in the dataview or do I need to add one? I basically want to simulate what happens when you enter a quote number into the quote number field.

Thanks
Tanner

Thanks
Tanner Post

No, if there is no data, you shouldnt do anything. And in that case, the row is -1

Thanks for the help again. I know this might be a very simple question so I apologize if I am missing something obvious. If there is no data in the primary dataview, but I have the quotenumber I want to auto load into the open form in a bpm variable, what is the best way to do this?

@Chris_Conn Looks like I just needed to follow this thread to do what I want. Thanks again for your help!