- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 10:25 AM
I need to fire off a script when a sales order is saved, grab some data and update a remote database. I have created a secondary accept button, tied a script to my button, and hidden the original accept button.
My script successfully runs and I can get the order number and order date, but I need to grab salespersonNo, expiration date and total and can't seem to figure how to do that.
salesOrderNo = ""
salesPersonNO = ""
retVal = oScript.InvokeButton("BT_ACCEPT")
rtnVal = oBusObj.GetValue("SalesOrderNo$", salesOrderNo)
customerNo = [SO_SalesOrder_bus_CustomerNo]
orderDate = [SO_SalesOrder_bus_OrderDate]
'Parse Order Date
Dim theYear, theMonth, theDay, result
parsedOrderDate = ""
If Len(orderDate) = 8 And IsNumeric(orderDate) Then
theYear = Mid(orderDate,1, 4)
theMonth = Mid(orderDate,5, 2)
theDay = Mid(orderDate, 7, 2)
result = theMonth & "/" & theDay & "/" & theYear
If IsDate(result) Then
parsedOrderDate = CDate(result)
End If
End If
Solved! Go to Solution.
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 11:51 AM
Hi dosborn,
You should be able to get the salesperson number and expiry date in the same fashion as the sales order number. Also, I would recommend retreiving these values BEFORE you invoke the real Accept button, as some of these values may be cleared after. Also, you could actually do this entire script on a Post or Pre Write event as a user-defined script. Your choice.
slsperson = ""
expireDate = ""
retVal = oBusObj.GetValue("SalespersonNo$", slsperson) ' keep in mind there are several salesperson fields if using split commissions and each has their own division number if you are using divisions.
retVal = oBusobj.GetValue("ShipExpireDate$", expireDate) ' this will be in YYYYMMDD
The order total however, is a calculation of several fields:
taxAmt = 0
nontaxAmt = 0
salestax = 0
freight = 0
discount = 0
retVal = oBusObj.GetValue("TaxableAmt", taxAmt)
retVal = oBusObj.GetValue("NonTaxableAmt", nontaxAmt)
retVal = oBusObj.GetValue("SalesTaxAmt", salestax)
retVal = oBusObj.GetValue("FreightAmt", freight)
retVal = oBusObj.GetValue("DiscountAmt", discount)
orderTotal = 0
orderTotal = taxAmt+nonTaxAmt+salestax+freight-discount
Hope this helps.
Elliott
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 11:55 AM
Also, if this is being run from a button script, then all the values you need can just be passed into the script. No need to do any business object queries.
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 12:00 PM
Why do you need to add a new button? You can just write a script that runs in the SO_SalesOrderHeader - Post_Write event.
You can just use GetValue to get the fields you need.
retVal = oBusObj.GetValue("SalespersonNo$", salespersonno)
retVal = oBusObj.GetValue("ShipExpireDate$", expiredate)
Order total is not stored. It can be calculated as TaxableAmt + NonTaxableAmt + SalesTaxAmt + FreightAmt - DiscountAmt.
Sr. Software Engineer
Sage 100 ERP
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 12:06 PM
You could do it with either of the techniques you are already using:
rtnVal = oBusObj.GetValue("SalesPersonNo$", SalesPersonNo)
rtnVal = oBusObj.GetValue("ShipExpireDate$", ShipExpireDate) or if you add the following fields with the MS Script Variable Selection button...
SalesPersonNo = [SO_SalesOrder_bus_SalespersonNo] ShipExpireDate = [SO_SalesOrder_bus_ShipExpireDate]
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 12:29 PM
Thanks, I am a bit baffled because I tried grabbing SalesPersonNo that way and it didn't work, but now it seems to be. I tried putting it in the post write initially, but was having some issues. Once I get it working I will try moving it back to the post write and see if I have success.
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 12:49 PM
...talk about an avalanche of support. Impressive!![]()
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 01:29 PM
Thanks for on the feedback. I moved the script to post write on SO Sales Order Detail, but it doesn't seem to fire any suggestions?
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 01:32 PM
I usually put a oScript.DebugPrint at the beginning of my scripts to make sure they are getting hit when I want them to (using the Program Trace with the Debug option in the INI file on).
Also make sure you have "Allow External Access" checked in the company you are working on in Company Maintenance.
Re: Get Updated Sales Order Person No, Expiration Date & Total on Accept
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-15-2011 01:53 PM
Hi dosborn,
In addition to Gator's suggestion, make sure it does get compiled into the script for the object as well. (It probably has). Also, I just noticed in your earlier post, that you added this to the SO_SalesOrderDetail : Post-Write event? I think you should put it on the SO_SalesOrderHeader : Post-Write event.
I agree wholeheartedly with Gator, as that DebugPrint can certainly be your friend when debugging ![]()
Elliott


