- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Script to pull Customer Data into a UDF in SO Invoice Data Entry
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2012 09:34 AM
In Sales Order Invoice Data Entry a script was created to pull in the customer information into a UDF field in Sales Order Invoice Data Entry header. The script works however I am trying to add the customer name to script and when I add the name to the script the script no longer works. Would anyone happen to have any ideas on why? Please let me know if you require further information.
The client is running MAS200 4.4.PU4
Here is the script: When I remove the references to the name (shown in red) from the script then the address will write to the UDF. When I add the references to the name the name nor address will not write to the UDF.
Dim retVal, bl_freightchg, oCust
Dim strName, strAddr1, strAddr2, strAddr3, strCity, strState, strZip, strCountry
Dim strFullAddress
'initialize variables
retVal = 0
bl_freightchg = ""
strName = ""
strAddr1 = ""
strAddr2 = ""
strAddr3 = ""
strCity = ""
strState = ""
strZip = ""
strCountry = ""
strFullAddress = ""
'get the freight charge value
retVal = oBusObj.GetValue("UDF_BLFRGTCHG$", bl_freightchg)
'if this = Third Party...we need to write the billing adddress to another field
if bl_freightchg = "Third Party" then
'connect to customer record
Set oCust = oBusObj.AsObject(oBusObj.GetChildHandle("CustomerN
'get all of the address info
retVal = oCust.GetValue("CustomerName$", strName)
retVal = oCust.GetValue("AddressLine1$", strAddr1)
retVal = oCust.GetValue("AddressLine2$", strAddr2)
retVal = oCust.GetValue("AddressLine3$", strAddr3)
retVal = oCust.GetValue("City$", strCity)
retVal = oCust.GetValue("State$", strState)
retVal = oCust.GetValue("ZipCode$", strZip)
retVal = oCust.GetValue("CountryCode$", strCountry)
'build full address
if Len(Trim(strAddr1)) > 0 then strFullAddress = strFullAddress & strAddr1 & chr(13) & chr(10)
if Len(Trim(strAddr2)) > 0 then strFullAddress = strFullAddress & strAddr2 & chr(13) & chr(10)
if Len(Trim(strAddr3)) > 0 then strFullAddress = strFullAddress & strAddr3 & chr(13) & chr(10)
strFullAddress = strName & strFullAddress & strCity & ", " & strState & " " & strZip & chr(13) & chr(10)
strFullAddress = strFullAddress & strCountry
'write the full address to the BLNote field
retVal = oBusObj.SetValue("UDF_BLNOTE$", strFullAddress)
end if
Re: Script to pull Customer Data into a UDF in SO Invoice Data Entry
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2012 09:55 AM
mmneal,
I would check the return value on the oBusObj.SetValue("UDF_BLNOTE$", strFullAddress), my best guess is adding the potential 30 characters of the customer name, maybe exceeding the field length for the UDF. Check the length of the variable in UDF Maintenance.
Hope this helps
Elliott
Re: Script to pull Customer Data into a UDF in SO Invoice Data Entry
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2012 11:19 AM
I didn't think about that. I will check and let you know. Thank you!
Re: Script to pull Customer Data into a UDF in SO Invoice Data Entry
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2012 11:25 AM
I just checked adn the lenght of the field is 400 characters.
Re: Script to pull Customer Data into a UDF in SO Invoice Data Entry
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2012 12:12 PM
I have tried this script on my system, and it seemed to work okay for me. You may want to check to see what the value of retVal is after doing the SetValue of the UDF.
retVal = oBusObj.SetValue("UDF_BLNOTE$", strFullAddress)
If retVal=0 Then
' you can either do a DebugPrint() or a Msgbox depending on where you're doing your testing
rVal = oScript.DebugPrint("FAILED! - " & oBusObj.LastErrorMsg)
' -- or --
rVal = oSession.AsObject(oSession.UI).MessageBox("", "FAILED! - " & oBusObj.LastErrorMsg)
End if
How are you checking to see if this worked or not? You will not be able to see this value in the DFDM until you do a Write() or accept the record on the screen.
Elliott


