Plugin Create Work Order from Sales Order  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Plugin Create Work Order from Sales Order

Postby DannyC » Tue Jun 18, 2019 6:16 pm

There's a Jiwa-written plugin floating around which creates a works order when a sales order needs qty from a BOM item, replicating the old breakout from Jiwa 6 days.

It was written, I believe, prior to 7.2 as there's a few lines with Manager.Instance (and it's in VB!) so I've tweaked the plugin for version 7.2.
Unfortunately it's erroring "Object reference not set to an instance of an object" when saving the sales order, line 65.
Code: Select all
item.SalesOrderLines.SalesOrder.Save(False,False)


Even if I rem out that line & manually save the sales order, it throws the same error. I've also removed the bool SavingForPrint, bool SavingForSplit values (i.e the False, False) which doesn't help either.

I've attached the plugin here. Can you assist in resolving the error?
Attachments
Plugin Create Work Order from Sales Order 7.2.xml
(38.57 KiB) Downloaded 65 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Plugin Create Work Order from Sales Order

Postby nsbandara » Tue Jun 18, 2019 6:53 pm

Hi Danny,

I noticed 2 issues with plugin.

Please check line 47 and 61 in plugin. You need to define sales order line custom field "Work Order No."

Capture.JPG


Line 59, You need to initialize custom field using collection item factory

Code: Select all
customFieldValue = Item.Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaApplication.CustomFields.CustomFieldValue)


Hope this helps.

Thanks.
Attachments
Plugin Create Work Order from Sales Order 7.2.xml
(39.11 KiB) Downloaded 63 times
User avatar
nsbandara
Occasional Contributor
Occasional Contributor
 
Posts: 43
Joined: Tue Jul 16, 2013 5:02 pm
Location: Sri Lanka
Topics Solved: 11

Re: Plugin Create Work Order from Sales Order  Topic is solved

Postby Mike.Sheen » Tue Jun 18, 2019 7:00 pm

We actually rewrote that plugin to behave differently.

It now doesn't use a custom field at all - we introduced a built-in optional relationship between work orders and sales order lines, so the plugin dispensed with the custom field and used that instead. We also no longer ask the user if they want to create the work order - we add a button to the ribbon instead.

The plugin description now (7.2):
Adds a tool to the sales form ribbon "Create Work Orders". When pressed, any items on backorder which are the primary output of bill of materials will have a work order created. The work order is linked to the sales order line by the built-in field BM_WorkOrder.SO_Lines_InvoiceLineID on the work order linking to the sales order line, and the sales order line has a new column displaying the work order (drillable).

When a work order is closed that is linked to a sales order, the sales order will receive the stock instead of it going straight into stock.


Plugin attached:
Plugin Create Work Order from Sales Order.xml
(46.2 KiB) Downloaded 72 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Plugin Create Work Order from Sales Order

Postby Mike.Sheen » Tue Jun 18, 2019 7:19 pm

If you REALLY want the original behaviour, then you need to follow Nishantha's guidance and add the custom field to sales orders - but there are other issues as well.

The error is actually caused by the Save of the sales order occurring inside the Sales Order Line Changed event handler - There's no real way around that and it's a mystery how it wasn't a problem before 7.2 anyway (was it ever working?).

I've made that change - to not save the sales order - and it works fine now.

I also took the liberty of updating the reading and setting of the custom field value - there's a simple, neat way of doing that now which doesn't offend.

Plugin attached (however I think the previous one I posted is superior).
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Plugin Create Work Order from Sales Order

Postby DannyC » Wed Jun 19, 2019 11:18 am

Gotta thank you both Nisha and Mike for that fast response.
I reckon we'll deploy the preferred plugin (with the ribbon button) as I think it makes more sense. The tweaked plugin is definitely worthwhile as that may actually be the preferred workflow.

Cheers

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests