Customization Trigger on new QuoteHed

This is an issue I have always had, but never really found a need to ‘resolve’ until now. It boils down to catching the end of the event when a new record is created (Order, Quote, QuoteDtl, etc.).

In this instance, I am trying to catch when a user clicks on the “New Quote” button on the Opportunity/Quote entry screen and the process to create the quote finishes. IE: the Quote Number is set to 0 and everything is initialized waiting for user input.

Once that is done, I need to set the value of a field in the QuoteHed EpiDataView. I have a textbox with that value so I can see what it is at any given time.

I tried checking when the EpiDataViewNotification was triggered and the NotifyType is Initialize and Row > -1, which triggers multiple times…It seems that when that triggers the 1st time, it sets the value, but it immediately triggers again and blanks the value out…each subsequent time it triggers (which I think is 4 or 5 times when the New button is clicked) it never sets it back to what it want it to be set as (at least the textbox I have on screen doesn’t reflect it).

The code block is very simple, as shown here:

If (args.NotifyType = EpiTransaction.NotifyType.Initialize) AND (args.Row >-1)  Then
	Dim edvQuoteHed As EpiDataView = CType(Script.oTrans.EpiDataViews(QuoteHed),EpiDataView)|
	Dim edvQuoteHedRow As System.Data.DataRow = edvQuoteHed.CurrentDataRow|
	UserName = QuoteForm.Session.UserName
	edvQuoteHedRow("Owner_c") = UserName
End If

My texbox is bound to QuoteHed.Owner_c

I have tried similar approaches with AfterAdapter methods and such, but the results are always the same: The texttbox is empty when all is said and done.

Is this something that would be better off being handled in a BPM for when a new quotehed record is added? Or am I missing a step on the customization? (IE: I am checking the wrong thing to see if the new record has been created? If I go the BPM route, will that trigger before anything is actually saved to the DB? (IE: the user hasn’t actually saved the quote yet…so the QuoteNum textbox/field is still showing 0)?

Yes, if you want to do that, just do something like this:

Post-Processing BPM on Erp → Quote → GetNewQuoteHed

Use a widget or some code to set your field

//May not be correct syntax to set UD field depending on your version of 10?
ds.QuoteHed.First().Owner_c = Session.UserID;
  • ?? That ds is a ref object, so input-output. I’m assuming the new one would be the first here. Possibly not.
  • If not then ds.QuoteHed.Where(x => x.QuoteNum == 0).First().Owner_c = Session.UserID;

When it comes back from the server it will have your data in the field, but not saved yet.

1 Like

That was exactly what I was looking for! Thank you for the clarification, Kevin. I have tested and proved this out this morning and put it into our Production environment.

Thank you, again.