SetStorageVar & GetStorageVar in different business objects...

SOLVED

I have a script in SO Header where I open Customer Maintenance, and I want to pass a Storage Var to that Customer Maintenance object (to change what happens in an AR_Customer post read script), but the values are not transmitted.

To test, I created a button script in SO Entry to SetStorageVar, using Elliott's oSessionScript strategy (posted elsewhere)... before invoking the customer maintenance screen.

Yet the Set value is not being passed through to the Get in the AR Customer script.

Am I missing something?

  • 0
    SUGGESTED

    I suspect it is because you are using InvokeProgram to start customer maintenance and this is probably causing the invoked program to have its own "session".

    Perhaps you can instead use GetObject or NewObject on the AR_Customer_UI class and then use its Process method and pass in the ARDivisionNo + CustomerNo. This should start off the current session but your script will pause at the line with Process until the processed task is closed by the user. This also suspends sales order entry in the background.

    You could also use oScript.InvokeButton "BT_CustomerNo". This will invoke this button.

  • 0 in reply to David Speck

    Thanks David... the BT_CustomerNo strategy is what I tried first, but the script where this is executed is PostValidate on CustomerNo and the button doesn't work at that stage.  Reference this thread.

    I'll see if I can figure out the GetObject / NewObject / Process idea but I have never opened another UI in a script that way before and don't know the syntax.  (Tips are welcome :-) ).

  • +1 in reply to Kevin M
    verified answer

    It seems the InvokeProgram was indeed the issue.  I've only tested with the button script, not the customer BOI script, but this worked... and the GetStorageVar in the AR_Customer script had the correct value.

    oUICust = oSession.GetObject("AR_Customer_UI")
    if oUICust <> 0 then
    	Set oUICust = oSession.AsObject(oUICust)
    else	
    	retVal = oSession.AsObject(oSession.UI).MessageBox("", "Access to AR_Customer_UI is required for the ... script to work.")
    	exit sub
    end if
    retVal = oUICust.Process(sDiv  & sCustNo)