Duplicate Quote Method Directive

I’m trying to create a method directive for when a user goes to Actions>Duplicate Quote. When this occurs, a new quote is created with the same information as the Source Quote. I’m wondering how I can use a method directive to have changes occur to the Source Quote. For example, when a Quote is duplicated, I want to have a certain checkbox on the original quote (source quote) be set to false.

I’ve been experimenting within the Quote.DuplicateQuote method and can’t seem to solve the issue. Is this possible? If so, would this be created as a Pre-Processing, Base Processing, or Post-Processing Directive? Thanks in advance!

I am thinking POST (assuming that it eventually also calls UPDATE). After all of the duplication is done, you’d modify your values (and then presumably it would call update). Does the trace show duplicate then update?

Hey Chris,

I’ll list the methods below in the order the trace shows. Sorry, I’m just having a hard time making sense of the trace so maybe you’ll be able to follow it better.

Erp.Proxy.BO.QuoteImpl GetRows
Erp.Proxy.BO.QuoteImpl DuplicateQuote
Erp.Proxy.BO.QuoteImpl GetByID
Erp.Proxy.BO.TaskSetImpl GetCRMTaskSetList
Erp.Proxy.BO.QuoteAsmImpl GetDatasetForTree
Erp.Proxy.BO.QuoteImpl ExistsProductGroupPriceList
Erp.Proxy.BO.QuoteImpl ExistsProductGroupDiscPriceList

I believe that’s all that pertains to this scenario within the trace?

I think you can do this either way - pre or post but there are some caveats.

Do you know if the fields you want to change are available in the temptable (tt) of that directive? If they are, you can probably use PRE directive and just modify them.

If the fields are not there in the tt, you’d use a POST directive, then lookup the records from the actual table, modify the data and save explicitly

Another option that completely avoids directives is to just put an event on the Actions>Duplicate menu item and then run your code. It will run after the default handling (which would be the duplication) - from there, just change the field

The fields show up in the temptable, but I’m starting to think that no data is actually changed in the DuplicateQuote method. I tried doing a ShowMessage in both the pre-processing and post-processing and when I tell it to return QuoteNum from the temptable for Added, Updated, Unchanged, or Deleted records it returns a blank message when I duplicate a quote. Makes me think the temptable in this method is empty or something?

I’ve also experimented with using the Invoke BO Method and have it trigger a Quote.Update method but the only parameter to specify is “ds” which I’m not sure how to use. The only thing I’m able to get to show in a ShowMessage on the DuplicateQuote Method is a parameter the system creates called “sourceQuote” which shows the original quote number.

I’ve also tried using that parameter in an UpdateTableByQuery but that didn’t work either. For the specified query, I set a criteria that QuoteNum=the parameter sourceQuote. Then set the relation to be QuoteNum from the query = ttQuoteHed_QuoteNum. My thought was I could set the binding for the checkbox I want to change to the specified expression False.

I’ve tried all of this as both Pre and Post processing.

I see - one of THOSE kind of directives lol. Well I don’t have much experience using the built in objects in BPM to modify data - I generally use code. Maybe something like this will work in a POST directive:

using (var txScope = IceContext.CreateDefaultTransactionScope())
{
 foreach(var QH in (from row in Db.QuoteHed.With(LockHint.UpdLock) where
 row.Company == Session.CompanyID && row.QuoteNum == sourceQuote
 select row))
 {
  QH.Checkbox1 = true; //or whatever
 }
 Db.Validate();
 txScope.Complete();
}
1 Like

How do I implement code within a BPM Method Directive? I know I’ve seen “Invoke Custom Code” or something like that as an optional node before when creating a directive, but maybe it’s only for Data Directives? It’s not currently an option to add for the DuplicateQuote method, neither Pre-Processing or Post-Processing…

ExecuteCustomCode

image

It must not be an option for this method?

Interesting, what version. I have it on 10.1.600

image

Check this in your user settings -
image

I knew I had seen it before. I was in our test environment and the permissions were not set up correctly. This worked out perfectly tho! Thanks for all the help!

1 Like

If everything worked out, can I get you to mark the solution please. Glad to help!