Sage 100

 View Only
Expand all | Collapse all

I have a script running on SO entry that works fin

  • 1.  I have a script running on SO entry that works fin

    Posted 08-05-2013 11:57
    I have a script running on SO entry that works fine through Sales Order. However, when a customer is pulled up through Customer Maintenance and then to the sales order tab, the script runs fine the first time a sales order is selected but throws an error 88 if the user chooses another sales order without closing all the way out of Customer Maintenance first. Is there something with the UI that opens the first time a SO is selected and then is confused when another SO is clicked on? Since the script works the first time, I'm not sure how to troubleshoot. Any help would be really appreciated! Here is the script: retVal = oSession.StartProgram 'retMsg = oSession.AsObject(oSession.UI).MessageBox("""",""Program = "" & retVal) if oSession.StartProgram <> ""AR_CUSTOMERINQUIRY_UI"" then retVal = oBusObj.EditState if retVal = ""1"" then if oSession.AsObject(oSession.Security).IsMember(""SO APPROVAL"") > 0 then retVal = oScript.InvokeButton(""fldr.pTotals"") retVal = oScript.SetUIControl(""ORDERDATE"",""DISABLE"") retVal = oScript.SetUIControl(""ORDERTYPE"",""DISABLE"") retVal = oScript.SetUIControl(""ML_CUSTOMER"",""DISABLE"") ELSE retVal = oScript.SetUIControl(""ML_BILLTOCUSTOMERNO"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTONAME"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS1"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS2"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS3"",""DISABLE"")


  • 2.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 12:24
    @AlnoorCassim - Kent Mackall discussed how to get the script to fire only once... I believe it has to do with how you link the script to the business object (so that the script modifies its behavior) in user defined fields and table maintenance. This seems like it could be the issue. Do you remember how that works?


  • 3.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 12:39
    @KateKrueger - Is the script attached to SO_SalesOrder_bus? This business object is used in other places besides SO entry. Since the script is attached it may be getting executed when it is not intended to be. You may need to put some Deactivation or conditionals in the script to make sure it only gets executed when you want it to.


  • 4.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 12:41
    Hi! The script is attached to Table - Post Read to Sales Order Entry. I need it to execute, but I need it to execute each time, not throw the error the second time. I feel like running the script the first time is opening some UI and then the second time is confused. Maybe there is a way to refresh customer maintenance without making the user close the task?


  • 5.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 13:28
    Comment out the IsMember line, recompile and try again. Just as an experiment


  • 6.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 13:52
    @AlnoorCassim - the script does not error out with the IsMember line commented out. Hopefully this is good news?


  • 7.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 13:56
    I ran into this before. I thought it was just an anomaly on my customer's system but I see now it's not. You should report it as a bug. Gotta run right now but will give you a workaround later today.


  • 8.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 14:38
    Hi Dan! The whole script is kind of a beast - i'm looking for two different member roles and enabling/disabling different fields based on if they have that role or not. I can send you the whole thing but i'm not sure if this text box will hold it. ...


  • 9.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 14:43
    Your script uses retVal inconsistently. First you set it to a string (oSession.StartProgram) then later you assign retVal to oBusObj.EditState (a numeric) and test it against a string. This might all work out, but it is confusing to read. Also, What's the rest of the script. What you show appears incomplete.


  • 10.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 14:57
    Here is the entire script, for some light reading... retVal = oSession.StartProgram 'retMsg = oSession.AsObject(oSession.UI).MessageBox("""",""Program = "" & retVal) if oSession.StartProgram <> ""AR_CUSTOMERINQUIRY_UI"" then retVal = oBusObj.EditState if retVal = ""1"" then if oSession.AsObject(oSession.Security).IsMember(""SO APPROVAL"") > 0 then retVal = oScript.InvokeButton(""fldr.pTotals"") retVal = oScript.SetUIControl(""ORDERDATE"",""DISABLE"") retVal = oScript.SetUIControl(""ORDERTYPE"",""DISABLE"") retVal = oScript.SetUIControl(""ML_CUSTOMER"",""DISABLE"") retVal = oScript.SetUIControl(""CUSTOMERPONO"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPEXPIREDATE"",""DISABLE"") retVal = oScript.SetUIControl(""ORDERSTATUS"",""DISABLE"") retVal = oScript.SetUIControl(""ML_WAREHOUSECODE"",""DISABLE"") retVal = oScript.SetUIControl(""TAXSCHEDULE"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_SHIPTO"",""DISABLE"") retVal = oScript.SetUIControl(""TERMSCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_TERMSCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_SHIPVIA"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPVIA"",""DISABLE"") retVal = oScript.SetUIControl(""CONFIRMTO"",""DISABLE"") retVal = oScript.SetUIControl(""EMAILADDRESS"",""DISABLE"") retVal = oScript.SetUIControl(""FAXNO"",""DISABLE"") retVal = oScript.SetUIControl(""COMMENT"",""DISABLE"") retVal = oScript.SetUIControl(""BT_SALESPERSON"",""DISABLE"") retVal = oScript.SetUIControl(""SALESPERSONNO"",""DISABLE"") retVal = oScript.SetUIControl(""SPLITCOMMISSIONS"",""DISABLE"") retVal = oScript.SetUIControl(""ML_BILLTOCUSTOMERNO"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTONAME"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS1"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS2"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS3"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOZIPCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCITY"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOSTATE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCOUNTRYCODE"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_SHIPTO"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTONAME"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOADDRESS1"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOADDRESS2"",""ENABLE"") retVal = oScript.SetUIControl(""SHIPTOADDRESS3"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOZIPCODE"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOCITY"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOCOUNTRYCODE"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPTOSTATE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_COPYSHIP"",""DISABLE"") retVal = oScript.SetUIControl(""DISCOUNTRATE"",""DISABLE"") retVal = oScript.SetUIControl(""DISCOUNTAMT"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPZONE"",""DISABLE"") retVal = oScript.SetUIControl(""SHIPWEIGHT"",""DISABLE"") retVal = oScript.SetUIControl(""FREIGHTAMT"",""DISABLE"") retVal = oScript.SetUIControl(""UDF_WARRANTY"",""DISABLE"") retVal = oScript.SetUIControl(""COMMISSIONRATE"",""DISABLE"") retVal = oScript.SetUIControl(""GD_LINES"",""DISABLE"") retVal = oScript.SetUIControl(""DB_PAYMENTTYPE"",""DISABLE"") retVal = oScript.SetUIControl(""FOB"",""DISABLE"") retVal = oScript.SetUIControl(""CHECKNOFORDEPOSIT"",""DISABLE"") END IF if oSession.AsObject(oSession.Security).IsMember(""AR ACCOUNTING"") > 0 then retVal = oScript.SetUIControl(""ML_BILLTOCUSTOMERNO"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTONAME"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS1"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS2"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS3"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOZIPCODE"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOCITY"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOSTATE"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOCOUNTRYCODE"",""ENABLE"") retVal = oScript.SetUIControl(""TERMSCODE"",""ENABLE"") retVal = oScript.SetUIControl(""BT_TERMSCODE"",""ENABLE"") retVal = oScript.SetUIControl(""BT_COPYSHIP"",""ENABLE"") ELSE retVal = oScript.SetUIControl(""ML_BILLTOCUSTOMERNO"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTONAME"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS1"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS2"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS3"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOZIPCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCITY"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOSTATE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCOUNTRYCODE"",""DISABLE"") retVal = oScript.SetUIControl(""TERMSCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_TERMSCODE"",""DISABLE"") END IF ELSE retVal = oScript.SetUIControl(""ML_BILLTOCUSTOMERNO"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTONAME"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS1"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS2"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS3"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOZIPCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCITY"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOSTATE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCOUNTRYCODE"",""DISABLE"") retVal = oScript.SetUIControl(""TERMSCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_TERMSCODE"",""DISABLE"") end if ELSE retVal = oScript.SetUIControl(""ML_BILLTOCUSTOMERNO"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTONAME"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS1"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS2"",""ENABLE"") retVal = oScript.SetUIControl(""BILLTOADDRESS3"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOZIPCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCITY"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOSTATE"",""DISABLE"") retVal = oScript.SetUIControl(""BILLTOCOUNTRYCODE"",""DISABLE"") retVal = oScript.SetUIControl(""TERMSCODE"",""DISABLE"") retVal = oScript.SetUIControl(""BT_TERMSCODE"",""DISABLE"") end if


  • 11.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 18:33
      |   view attached
    Here you go Kate. I was able to duplicate your error. The attached is the workaround for when the IsMember() function causes SetUIControl to fail with an error 88 when the starting UI is different than the one you are manipulating the controls on (like disabling fields, hiding fields, etc) I'm connecting to Sy_UserSecurity object as the workaround. Look at the comments in the attached to see the logic. And since Sy_UserSecurity doesn't have an associated UI object it means we don't need to grant the user View Only access to Role Maintenance or User Maintenance. Hope this helps. It works for me.

    Attachment(s)

    txt
    Tst_So_Entry_Ismember.txt   977 B 1 version


  • 12.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 18:55
    Thanks so much Alnoor! I'll give this a try and let you know how it goes (I'm sure it will work perfectly since you wrote it (shameless flattery))


  • 13.  RE: I have a script running on SO entry that works fin

    Posted 08-05-2013 19:02
    Forgot to remove the line referencing SC2 company code. You should remove that.


  • 14.  RE: I have a script running on SO entry that works fin

    Posted 08-07-2013 11:02
    I loaded up your changes and it worked perfectly. Thanks Alnoor!!