Event Script - Get child handle from a child handle?

Probably not, but just asking.  I have a script attached to the SO_SalesOrderDetail object.  I'd like to reference a UDF attached to the Product Line of the line's item code - Ideally I would use child handles to avoid the need to give all users view writes to the product lines.  I tried the below which unsurprisingly didn't work, but just curious if anyone knew of way of making the above happen?

SET oItem = oBusObj.AsObject(oBusObj.GetChildHandle("ItemCode"))
SET oProd = oItem.AsObject(oItem.GetChildHandle("ProductLine"))

Top Replies

  •     - Just an FYI guys.  The ReadAdditional() basically does a Find() with the values in the current record so that when  using the child handle, you'll be able to just do GetValue() calls for…

  • 0

    Try this:

    retVal = oBusObj.ReadAdditional("ItemCode")
    Set oItem = oSession.AsObject(oBusObj.GetChildHandle("ItemCode"))
    retVal = oItem.ReadAdditional("ProductLine")
    Set oProd = oSession.AsObject(oItem.GetChildHandle("ProductLine"))

  • 0 in reply to Kevin M

    Hi Kevin,

    Thanks.  Unfortunately this generated the below error.  Also - just curious - what does the ReadAdditional method do?  I've seen it in the documentation but never used it previously when grabbing child handles.  Thanks again for the assistance.

    retVal = oBusObj.ReadAdditional("ItemCode")
    SET oItem = oSession.AsObject(oBusObj.GetChildHandle("ItemCode"))
    
    retVal = oItem.ReadAdditional("ProductLine")  <---Error generated here
    SET oProd = oSession.AsObject(oItem.GetChildHandle("ProductLine"))  

  • 0 in reply to Justin K

    I don't have a technical explanation, but am in the habit of using ReadAdditional before getting a child handle object because it has helped in the past.

    Make sure this does not run for comments / charge codes (which do not have a ProductLine).

    If that isn't the answer, after the Set oItem... perhaps try an oItem.Find(sItemCode) to make sure you have the correct record open.

  • 0 in reply to Kevin M

    Got it thanks.  Let me try your suggestions.

  • 0 in reply to Kevin M

        - Just an FYI guys.  The ReadAdditional() basically does a Find() with the values in the current record so that when  using the child handle, you'll be able to just do GetValue() calls for the record without having to do a Find().  If you are using the child handle for something not related to the current record then you wouldn't have to do this.

    Hope that helps

    Elliott