Executing custom code in Create-sales-order form after using an alternate address

Hello,

Even though this question is specific to the SalesCreateOrder form, it holds for all forms that have this pattern.

From the Sales order Details form, when you click the New button, the SalesCreateOrder form opens. Here, you can click on the “Alt Address” button and pick a different delivery address for the customer and click the “Copy address to order” button to copy the selected address. The address gets copied and all of this is fine.

I would like to take some action after control comes back to the SalesCreateOrder form. I tried the following:

  1. I put code after the super call in the clicked event of the “Alt Addresss” button. The code gets executed even before Select Address form opens up. No use there.

  2. The AddressSelect form’s CopyAddressToCaller method copies the new address to the calling datasource’s buffer and refreshes the salesCreateOrder form. I can find out the caller by checking callerDataSource.name(), but I cannot invoke a custom method using callerDataSource.myCustomMethod()

So, how do I execute some custom code after returning from selecting an alternate address?

Thank you,

Raman

Well, I found a way to do it.

  1. Create a method (someMethod) on the SalesTable datasource and put your code in it

  2. In the AddressSelect form’s CopyAddressToCaller method, I checked whether the caller datasource has the method and if present, executed it

if Global::formDataSourceHasMethod(callerDataSource, identifierStr(someMethod)))

{

callerDataSource.someMethod();

}

If there is a better way, please let me know.

Thanks.