Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, February 21, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Add an Opportunity Sales Order automatically after closing an Opportunity
Dominic Martin
Posts: 2
 
Add an Opportunity Sales Order automatically after closing an OpportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Feb 14 8:50 AM

Hi,


LAN V8.0.0.8689


Here's what I'd like to do - when an opportunity is "Closed - Won" and after the Move Products To Assets form has done its work - I'd like the Insert Sales Order form to appear automatically.


Right now, the code is doing everything I think it needs to but the Insert Sales Order form does not appear. I don't get any errors. I just get back to the Opportunity Detail view of my now closed opportunity. I'm guessing that the form doesn't like being called outside of the grid but I'm passing all the parameters it needs? What's the proper way to acheive what I'd like to do?


Here's what I've done.



  1. I've copied and modified the CallAddEditSalesOrderView(strMode) sub from (Opportunity) Order Details into (Opportunity) Close Opportunity.

  2. I've copied the CheckPrimaryContact(AccountId, OpportunityId) function from (Opportunity) Order Details into (Opportunity) Close Opportunity.

  3. I've modified the btnOKClick(Sender) sub in (Opportunity) Close Opportunity and inserted CallAddEditSalesOrderView("Add") after AddAccountProductRecords.


This is a copy of the CallAddEditSalesOrderView sub that I've modified. You can see where I've commented out some of the original code. I've checked the contents of the new variables for Account and Opportunity ID's and they're populated as they should be.


Sub CallAddEditSalesOrderView(strMode) 'This sub is a modified copy from the Opportunity Order Details form.
    Dim objMainView, objDetail, objParent
    Dim strSalesOrderID

 


    If strStatus = Application.Translator.Localize("Closed - Won") Then 'DNL Only Closed - Won orders need a sales order


    Set objMainView = Application.MainViews.Add("System:Add Edit Sales Order", 0, False)  'DNL
    objMainView.BorderStyle = 3


    Set objDetail = objMainView.DetailsView


    If strMode = "Add" Then 'DNL
       strSalesOrderID = Application.BasicFunctions.GetIDFor("SALESORDER") 'DNL
       objMainView.SetDataMode 1, strSalesOrderID
       objDetail.CurrentID = strSalesOrderID
       'Set the default Account to that of the Opportunity
       'Set objParent = frmOrderDetails.Parent.DetailsView 'Change the object parent
       'If Not (objParent Is Nothing) Then
          objDetail.lveBillAccount.Text = GetField("ACCOUNT", "ACCOUNT", "ACCOUNTID = '" & strAcctId & "'")  'DNL objParent.lnkAccount.Text
          objDetail.lveShipAccount.Text = GetField("ACCOUNT", "ACCOUNT", "ACCOUNTID = '" & strAcctId & "'")  'DNL objParent.lnkAccount.Text
          objDetail.txtAccountID.Text = strAcctID 'objParent.lnkAccount.LinkID
          objDetail.txtOpportunityID.Text = strOppID 'objParent.CurrentID
          objDetail.txtUserID.Text = Application.BasicFunctions.CurrentUserID
          objDetail.dteOrderDate.DateTime = Date
       'End If
       'Set objParent = Nothing
       objDetail.Caption = Application.Translator.Localize("Insert Sales Order")
    'Else
       'objMainView.CurrentID = grdSalesOrders.GetCurrentField("SALESORDERID") 'DNL
       'objDetail.lveBillContact.Text = grdSalesOrders.GetCurrentField("A3_NAMELF") 'DNL
       'objDetail.lveShipContact.Text = grdSalesOrders.GetCurrentField("A4_NAMELF") 'DNL
       'objDetail.CurrentID = grdSalesOrders.GetCurrentField("SALESORDERID") 'DNL
       'objDetail.Caption = Application.Translator.Localize("Edit Sales Order #: ") & grdSalesOrders.GetCurrentField("SALESORDERNUMBER") 'DNL
       'objDetail.Caption = LocalizeFmt("Edit Sales Order #: %s", Array(grdSalesOrders.GetCurrentField("SALESORDERNUMBER")))
    End If
    'Check for account having a contact
    If CheckPrimaryContact(objDetail.txtAccountID.Text, objDetail.txtOpportunityID.Text) Then
      objDetail.Script.Init(strMode)
      'If objMainView.ShowModal = mrOK Then
         'grdSalesOrders.Refresh
      'End If
    Else
      MsgBox Localize("An account contact is required for sales orders")
    End If
    End If


    Set objDetail = Nothing
    Set objMainView = Nothing
End Sub

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Add an Opportunity Sales Order automatically after closing an OpportunityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Feb 14 9:11 PM

You've commented out the lines that actually launch\show the form!!!


 


      'If objMainView.ShowModal = mrOK Then
         'grdSalesOrders.Refresh
      'End If

the .ShowModal is the line of code that displays the mainview object....
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 2/21/2025 5:11:59 AM