Getting User Code

I am trying to change the user code on orders importing through ROI's Insynch based on the customer no.  To get the user code do you use "oSession" I wouldn't think so because the actual user is not actually in the session right?  And I shouldn't use "oBusObj" either because it is in another table, not the header correct?  I do not see any examples of going into the SY_User table from the header to pull the value.

  • Here is a code I use to get the User first and last name. Maybe this will give you some idea

    sFirst = "" : sLast = "" : sKey= "" : sCKey = ""

    retVal = oBusObj.GetValue("UserCreatedKey", sCKey)

    Set oUser = oBusObj.AsObject(oBusObj.GetChildHandle("UserCreatedKey"))

    retVal = oUser.getvalue("UserKey$",sKey)
    retVal = oUser.getvalue("FirstName$",sFirst)
    retVal = oUser.getvalue("LastName$",sLast)

    If sKey = sCKey then
    retVal = oBusObj.SetValue("UDF_FIRST$", sFirst)
    retVal = oBusObj.SetValue("UDF_LAST$", sLast)

  • Thanks, actually just found that post with this code, trying out an option now.

  • Script fired on column post validate (CustomerNo), it hangs on the "oUser.SetValue", also tried "Set oUser = ", code I posted I tried using oBusObj.SetValue on the UserCreatedKey field.  UserCode is not a field on the header so how do you update it?

    'Script to change user code for web orders
    
    If oSession.UserCode = "JML" then
    rVal = oSession.AsObject(oSession.UI).MessageBox("user = " & oSession.UserCode)
    	If oBusObj.EditState = 2 then
    rVal = oSession.AsObject(oSession.UI).MessageBox("edit state = " & oBusObj.EditState)
    
    	rVal= 0
    	sCustomerNo= ""
    
    	rVal= oBusObj.GetValue("CustomerNo$",sCustomerNo)
    rVal = oSession.AsObject(oSession.UI).MessageBox("custno = " & sCustomerNo)
    
    
    		If sCustomerNo = "2668000" then
    
    		rVal = oBusObj.SetValue("UserCreatedKey$", 0000000071)
    
    		end if
    	end if
    end if

  • , you will not be able to update the UserCreatedKey, or Date/Time Created.  These are deemed read-only columns and are to be only set by the business object.  The ROI software when they create these through BOI will have an associated user they use to create these, and that is the user that should be assigned when the orders are created.

  • So "UserCode" can not be updated through scripting? I would need ROI to hard code in the logic of the import which user code is used per customer?