Sage 100

 View Only
  • 1.  Updating customer record with data from UDT

    Posted 12-01-2021 18:05
    Hi All,
       I am missing something here with this script.  The purpose is to fill in an "industry" UDF in the customer file with the data pulled from the UDT.  The key in the UDT is the possible entries for the custom type.  The message box shows that it is finding the correct value but it does not update the field in the customer table.   I had originally tried doing it as a column script (that is why the Write line is there) but it did not work.  Now it is a pre-write.  Any guidance on why it's not filling in the field would be appreciated. 

    'Set Customer Industry
    ' Desc: Pulls in customer industry based on customer type
    ' Bus Object: Main: AR_Customer_bus
    ' Event: Pre-Write
    
    ' By Bob Osborn/ ACI
    
    ' ----------------------------- SCRIPT START -------------
    
    'Init VARs
    sType = "" : sIndustry = ""
    if oSession.UserCode = "ACI" then
    
    retVal = oBusObj.GetValue("CustomerType$", sType)
    
    sMsg = 	"Type: " & sType
    
    'retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
    
    Set oUDT = oSession.AsObject(oSession.GetObject("CM_UDTMaint_bus", "AR_UDT_INDUSTRY"))
    
    'Set oUDT = oSession.GetObject("CM_UDTMaint_bus", "AR_UDT_INDUSTRY")
    
    'If oUDT <> 0 Then
    '	Set oUDT = oSession.AsObject(oUDT)
    'Else
    '	sMsg = 	"Error: Could not access AR_UDT_INDUSTRY"
    '
    '	retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
    '	Exit Sub
    'End If
    
    'If Len(sType) <> 0 Then
    	retVal = oUDT.Find(sType)
    	retVal = oUDT.GetValue("UDF_INDUSTRY$", sIndustry)
    	sMsgA = "Ind: " & sIndustry
    	retMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsgA)
    	retVal = oBusObj.SetValue("UDF_INDUSTRY$", sIndustry)
    '	retVal = oBusobj.Write()
    
    'End If
    end if
    ​


    ------------------------------
    Bob Osborn
    Consultant
    ACI Consulting
    ------------------------------


  • 2.  RE: Updating customer record with data from UDT

    Posted 12-01-2021 18:20
    If sIndustry is the correct value, check the spelling of the UDF in AR_Customer.
    Also take a look at the retVal from your SetValue to make sure you're not getting an error there.  It could be something like validation / Advanced Field Settings causing the failure (with the script working just fine otherwise).

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 3.  RE: Updating customer record with data from UDT

    Posted 12-02-2021 21:14
    In addition to displaying the return value from the SetValue, you should add 'oBusObj.LastErrorMsg" to display the last message error triggered.

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------