Form Plugin Setup

Posted:
Mon May 07, 2018 11:23 am
by SBarnes
Hi Mike,
Is these a way to make the Form Plugin Setup be called for every form that is created, without every form that is in SY_Forms being added as a form reference?
Re: Form Plugin Setup 

Posted:
Mon May 07, 2018 8:46 pm
by Mike.Sheen
Hi Stuart,
You can add a handler within the Setup method of the ApplicationManagerPlugin for the FormFactory AfterFormStart event.
In 07.00.175.00 this would be:
- Code: Select all
public class ApplicationManagerPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaApplicationManagerPlugin
{
public override object InitializeLifetimeService()
{
// returning null here will prevent the lease manager
// from deleting the Object.
return null;
}
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.FormFactory.AfterFormStart += AfterFormStart;
}
public void AfterFormStart(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm)
{
// code goes in here to handle after the form has started (equivalent to Setup method)
}
}
In 07.01.xx:
- Code: Select all
public class ApplicationManagerPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaApplicationManagerPlugin
{
public override object InitializeLifetimeService()
{
// returning null here will prevent the lease manager
// from deleting the Object.
return null;
}
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
Plugin.Manager.FormFactory.AfterFormStart += AfterFormStart;
}
public void AfterFormStart(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm)
{
// code goes in here to handle after the form has started (equivalent to Setup method)
}
}
Mike
Re: Form Plugin Setup

Posted:
Fri May 11, 2018 5:59 pm
by SBarnes
Hi Mike,
Thanks for the reply.
A minor little issue that I have just discovered in 7.1, is that if you have a custom form in a plugin, and you add that form to the form references references for the same plugin so you can put code into the Form Plugin Setup, this all works fine but when you export the plugin and try and import it you of course get a plugin error about the form not found and the import fails, you have to remove the reference, export, import and add the reference back to get around it. I only mention it in case someone else comes across the same issue.
Re: Form Plugin Setup

Posted:
Sat May 12, 2018 2:55 pm
by Mike.Sheen
Hi Stuart,
Thanks - logged as
DEV-6613. An edge case we hadn't considered - not sure if we can fix it, but we'll see.
A workaround might be to split the plugin in two - one which creates the form, and a second which has a plugin reference to the plugin defining the form and with an execution order higher than the plugin defining the form. This would mean you'd have to make sure you import the plugins in order - not sure if that's less of a burden than how you're currently working around it or not.
Mike