Getting User Code

SOLVED

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.

Parents
  • 0

    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)

  • 0 in reply to BigLouie

    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

  • 0 in reply to jland47

    , 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.

  • 0 in reply to jepritch

    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?

  • +1 in reply to jland47
    verified answer

    There is no User Code field in the stock Sage 100 so, I'm assuming the lookup above either retrieves the code from the UserCreatedKey, or User Code is a UDF.

    I'm not sure the intention, but possibly it would be better to implement a UDF for this purpose?   Or if you are always basing the user code on the customer, possibly associate a UDF on the customer table with the appropriate user code and then use that in this lookup or wherever it is needed?

    E

  • +1 in reply to jland47
    verified answer

    If you have a "who did the data entry" value in the source system, ask ROI to push that into a UDF.

    The Sage fields for user created / user updated are system controls tracking who does what (audit trail of data entry activities) which is completely unrelated to who is "used per customer".  Don't try and repurpose Sage fields.  Custom data logic is what UDF's are meant for.

Reply
  • +1 in reply to jland47
    verified answer

    If you have a "who did the data entry" value in the source system, ask ROI to push that into a UDF.

    The Sage fields for user created / user updated are system controls tracking who does what (audit trail of data entry activities) which is completely unrelated to who is "used per customer".  Don't try and repurpose Sage fields.  Custom data logic is what UDF's are meant for.

Children
No Data