Page 1 of 1

Plugin to fire the Send To Freight System button

PostPosted: Wed Dec 15, 2021 10:55 am
by DannyC
I've got a plugin which populates the freight grid (the one in the Freight tab, not grdCartage) based on the items, weights, cubic etc.
As part of the plugin, I want it to automatically send the details to the freight system.

I've worked out how to change the status to Ready To Send but I can't work out if I can programmatically Send To Freight System.

How would I do this?

Re: Plugin to fire the Send To Freight System button

PostPosted: Wed Dec 15, 2021 2:41 pm
by Mike.Sheen
That button on the sales order form does nothing without a plugin handling the button click and then doing something with it.

We ship with a sample plugin, "IFS Smartfreight" which does that - it adds a handler for the SendToFreightSystemUltraButton.Click and in there it sends some information to the configured IFS SmartFreight web service.

Are you wanting to invoke the same code that this plugin executes when that button is clicked?

Re: Plugin to fire the Send To Freight System button

PostPosted: Wed Dec 15, 2021 2:47 pm
by DannyC
Are you wanting to invoke the same code that this plugin executes when that button is clicked?

Yep.

Pretty sure the IFS Smartfreight plugin is already enabled. So I'd need to somehow invoke the code in that plugin.

Re: Plugin to fire the Send To Freight System button

PostPosted: Wed Dec 15, 2021 2:58 pm
by Mike.Sheen
The easiest way is to automate the clicking of the button - that's assuming you have a form and are not trying to do this with only the business logic available.

You can do that using the PerformClick method.

Code: Select all
salesOrderForm.SendToFreightSystemUltraButton.PerformClick();

Re: Plugin to fire the Send To Freight System button

PostPosted: Thu Dec 16, 2021 9:03 am
by DannyC
that's assuming you have a form and are not trying to do this with only the business logic available
.

Bugger. Not via another Jiwa form. But would the same technique be possible using
Code: Select all
salesOrder.Client.SendToFreightSystemUltraButton.PerformClick();

or would that only work if the Client isn't null? i.e. that there's a sales order form?

Re: Plugin to fire the Send To Freight System button  Topic is solved

PostPosted: Thu Dec 16, 2021 11:21 am
by Mike.Sheen
DannyC wrote:Bugger. Not via another Jiwa form. But would the same technique be possible using
Code: Select all
salesOrder.Client.SendToFreightSystemUltraButton.PerformClick();

or would that only work if the Client isn't null? i.e. that there's a sales order form?


Yes, only if the Client is not null is there a form - and if you look at the code in the IFS plugin, you'll see it only adds a button click handler on the sales order form setup method.

It's beginning to sound like you need to copy the code in that IFS plugin into your plugin.