Copying a Sales Order (Sales Order Line - Custom Fields)  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Copying a Sales Order (Sales Order Line - Custom Fields)

Postby marcosomizu » Wed Oct 28, 2015 3:28 pm

Hi,

I need help with the Sales Order Lines Custom Fields.

The problem is that when I copy a Sales Order that has all the informations (including the Custom Fields from the Sales Order Line), the new Sales Order looks just fine, but when I save it, it loses all the Custom Fields from the Sales Order Line.

Example:

1) Search for a Sales Order that has all the Custom Fields from the Sales Order Line(s) filled.
2) Copy this Sales Order
3) A new Sales Order will appear with all the information filled (so far it is working fine)
4) Save the Sales Order - automatically loses the Custom Fields from the Sales Order Line(s)

Can someone help me on this? I tried to force setting all the Custom Fields values when saving, but it still does not work.

What I tried:

Code: Select all
Public Sub SalesOrder_SaveStart(sender As Object, e As System.EventArgs)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = DirectCast(salesOrder.GenericObjectCollection("SalesOrderForm").Object, JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
      
      Dim gridSheet As JiwaFinancials.Jiwa.JiwaApplication.Controls.Sheet = DirectCast(salesOrderForm.grdLines.ActiveSheet, JiwaFinancials.Jiwa.JiwaApplication.Controls.Sheet)
      
      For row As Integer = 0 To gridSheet.Rows.Count - 1
         
         If Not IsNothing(gridSheet.GetValue(row, 0)) Then
            
            For Each line As JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine In salesOrder.SalesOrderLines
               
               If gridSheet.GetValue(row, 0).ToString() = line.RecID Then
                  
                  For Each customFieldValue As JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue In line.CustomFieldValues
                     
                     Select Case customFieldValue.CustomField.PluginCustomField.Name
                        
                     Case "PickPack"
                        line.CustomFieldValues.ItemFromSettingName("PickPack", "Plugin Name").Contents = gridSheet.Cells(row, gridSheet.Columns("Plugin Name.PickPack").Index).Text

marcosomizu
Occasional Contributor
Occasional Contributor
 
Posts: 23
Joined: Mon Sep 07, 2015 12:01 pm
Topics Solved: 1

Re: Copying a Sales Order (Sales Order Line - Custom Fields)

Postby Scott.Pearce » Fri Oct 30, 2015 9:24 am

The native copy only copies basic properties. The problem we often find is that some sites want some properties copied, and other sites do *not* want those same properties copied. A classic example of this is notes - should notes be copied across? Some say yes, others say no - it all depends on how a site uses the notes (for example, courier information for a specific sales order may be entered as a note which would not be relevant for the copy). To this end, we tend to use plugins to "fill in the gaps", so to speak, and I see that you are now attempting to do exactly that now for your site.

I'll dig up a plugin you can use and post it here shortly.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Copying a Sales Order (Sales Order Line - Custom Fields)  Topic is solved

Postby Scott.Pearce » Fri Oct 30, 2015 9:43 am

I've posted up a sample plugin which should suit your needs here:

viewtopic.php?f=27&t=445
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Copying a Sales Order (Sales Order Line - Custom Fields)

Postby marcosomizu » Mon Nov 02, 2015 2:04 pm

Thank you Scott.

Just a suggestion: since it is debatable whether custom fields should be copied along or not, wouldn't it be better if it was a property/method to set in a Sales Order object, instead of creating new plugins in order to do this?

Something simple, for example: SalesOrder.CopyCustomFields = true

Anyway, is just an idea. Thank you for the plugin.
marcosomizu
Occasional Contributor
Occasional Contributor
 
Posts: 23
Joined: Mon Sep 07, 2015 12:01 pm
Topics Solved: 1


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests