Page 1 of 1

How do copy the custom fields from Quote to Sales Order

PostPosted: Mon Aug 03, 2009 5:03 pm
by acute
Hi Mike,

Are you able to provide us with sample code on how to use breakout to copy the custom fields from Quote to Sales Order, when you convert the Quote into the sales order using Recurring Quote Activation form.

Assuming I can make sure that the custom fields setting id exactly the same between SO_CustomSetting and QO_CustomSetting.

I need this for both 6.4.14 sp5 and 6.5.12

Re: How do copy the custom fields from Quote to Sales Order

PostPosted: Mon Aug 10, 2009 3:59 pm
by pricerc
Hi,

Don't know if it'll work for 6.4.14, but I have this working for one client in 6.5.12 - in Sales Order Breakouts/SalesOrderCreateNewCompleted:

Code: Select all
If Not SourceQuoteObject Is nothing Then
      'Sales Order generated from a quote
      Dim qcs, ocs
     
       For Each qcs In SourceQuoteObject.SalesQuoteCustomSettings
            For Each ocs In SalesOrderObject.SalesOrderCustomSettings
                  If ocs.SettingName = qcs.SettingName Then
                        'msgbox qcs.SettingName & " = " & qcs.SettingContents
                        ocs.SettingContents = qcs.SettingContents
                  End If
            Next
       Next
End If


/Ryan

Re: How do copy the custom fields from Quote to Sales Order

PostPosted: Tue Aug 11, 2009 8:21 pm
by Mike.Sheen
Ryan,

That code looks solid - should work in any version which has custom fields.

Well done.

Edit : ok I'm being picky here, but we can optimise that a little - once you've matched the sales order custom field against the quote one by name, and set the value, you can exit the loop - might save a few milliseconds, depending on how many custom fields you have :)
Code: Select all
If Not SourceQuoteObject Is nothing Then
      'Sales Order generated from a quote
      Dim qcs, ocs
     
       For Each qcs In SourceQuoteObject.SalesQuoteCustomSettings
            For Each ocs In SalesOrderObject.SalesOrderCustomSettings
                  If ocs.SettingName = qcs.SettingName Then
                        'msgbox qcs.SettingName & " = " & qcs.SettingContents
                        ocs.SettingContents = qcs.SettingContents
                        Exit For
                  End If
            Next
       Next
End If