Button Click event happens on click only on first press #e10

I have added a button to the UD10 screen to go get the inventory amount for the part and lot selected and put it in UD10.Number05. The button works the first time I press it. If I change the lot number and press it again I get the popup box that the contextbpmdata has been changed to Inventory but the data in the field doesn’t change.

Button Code: I had to comment out the RowMod to get it to fire at all. Can I set it to look for Updated OR added rows?

private void epiButtonInventory_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
	//edvUD10.dataView[edvUD10.Row]["RowMod"]="U";
	edvCallContextBpmData.dataView[edvCallContextBpmData.Row]["Character01"] = "Inventory";
	oTrans.Update();

	}

BPM code that fires if CallContextBpmData.Character01 = Inventory

// get temp table for updated UD10 record
var NewRecord = ttUD10.FirstOrDefault();

//get quantities from partbin table               
                                      
 decimal thisOnHandQty =
  Db.PartBin.Where(x=>
      x.Company == Session.CompanyID &&
      x.PartNum == NewRecord.Character01 &&
      x.LotNum == NewRecord.Character02).Sum(x => x.OnhandQty);  
                      
 NewRecord.Number05 = thisOnHandQty;
 
 callContextBpmData.Character01 = "";

Just because I’ve seen stuff like this before, you might need a Db.Validate(); at the end of the BPM. I’ve not had it confirmed, but it seems like that writes the data (or goes through the steps to get it ready for update). I know the consultants always put this in when we had them writing BPM code for us.

Do a trace, I doubt the Update is even fired from the screen without the RowMod changing.

Thanks for the suggestion. That didn’t fix it :frowning:

It does fire the update both times. I have a pop up to show me the part and lot number it’s sending through to the code and that box pops up with the correct information every time I push the button.

In your BPM, does it only have one row, or a before row, and a modified row?

Do a count, you may need to check for one with the proper rowmod in the bpm.

2 Likes

I don’t know how to do that but I went through the options for ttUD10. and found LastorDefault makes it work correctly.