How do copy the custom fields from Quote to Sales Order

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

How do copy the custom fields from Quote to Sales Order

Postby acute » Mon Aug 03, 2009 5:03 pm

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
acute
I'm new here
I'm new here
 
Posts: 3
Joined: Sat Feb 23, 2008 1:52 am

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

Postby pricerc » Mon Aug 10, 2009 3:59 pm

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
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

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

Postby Mike.Sheen » Tue Aug 11, 2009 8:21 pm

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
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 8 guests