Know when control returns to calling form

I have a customization which is calling another customization with ProcessCaller.LaunchForm(oTrans, “IMSALUS”, lfo);

I would like to execute some code automatically when this is finished. Is there a way to know when control is returned to my calling customization which I presume occurs when the ProcessCaller.LaunchForm(…) is closed.

You can use a call back passed on the lfo object

I’ll dig up the code stand by

Here’s a post where this was covered by @Chris_Conn and @josecgomez

2 Likes

I’m not sure what this is. I am looking for the instant the calling form regains control after the called customization has done its thing. I tried an EpiviewNotification but that didn’t work. I am not looking to get info back from anywhere unless it is from the called customization
saying “I’m finished doing my thing”.

That is exactly what that does.

ProcessCaller.ProcessCallBack += new ProcessCallBack(standardCallBackHandler);
LaunchFormOptions lfo = new LaunchFormOptions();
        // the CallBackToken allows us to respond to standard callback
        lfo.CallBackToken = "myCallBackToken";

 
        // Launch a Form
        ProcessCaller.LaunchForm(oTrans, "UD01", lfo);

//Get notified of transactions and events that happen on the other form.
void standardCallBackHandler(object Sender, TransactionCallBackArgs args)
    {
        ILaunch il = Sender as ILaunch;
        string msgFrom = il == null ? "" : " on " + il.WhoAmI;
        if (args.CallBackToken == "myCallBackToken")
            EpiMessageBox.Show("ShipVia form handles standard callback from transaction event" +msgFrom+ ":  " + 
            args.TransactionEvent.ToString());
    }


//Don't forget to unsubscribe from the handler when the form closes unless you enjoy memory leaks
     ProcessCaller.ProcessCallBack -= new ProcessCallBack(standardCallBackHandler);
3 Likes

This seems to be working exactly like I want. Thanks Guys.

This has worked handsomely. I now have a PerformClick() that clicks a button and in turn launches another customization. After that customization does its thing it returns to where I did the PerformClick(), which is in a Load event, I want to execute some more code. This is after the load is complete and the PerformClick is done and I would like for it to execute automatically. How can I do this? I tried another callback handler but that didn’t seem to work.

When the load is complete I’d just use the Shown_ event. That event is fired after Load generally.

Thank you. I will investigate that.

I can’t find a Shown event in the Event wizard. How can I define a Shown event?

You gotta wire it yourself

I have this in InitializeCustomCode

this.Shown += IssueMaterialForm_Shown;

and this in the DestroyCustomCode sections

this.Shown -= IssueMaterialForm_Shown;

and now this…
private void IssueMaterialForm_Shown(object sender, EventArgs e)
{
MessageBox.Show(“We have loaded the form”);
}

Is there anything I need in the Load handler? As it stands, it is not working at all.

Not this.Shown, it should be UDXXForm.Shown

Since this. is Script (and Script isn’t a form)

1 Like

Oh OK. The form I am working with is an Epicor standard form and not a UD form so I guess I can’t do it. Thank you anyway for your help.

You can just use SalesOrderForm.Shown (or whatever)

That worked. Thanks.