Scripting

Expand all | Collapse all

I have a question regarding setting of values when

  • 1.  I have a question regarding setting of values when

    Posted 03-08-2017 18:07
    I have a question regarding setting of values when creating new sales orders using RMA Generate Transactions. I have a simple Table Post Read script that works to recalculate the Ship Date for new orders created via RMA Xpress Sales Order and using this line = ""If oSession.StartProgram = ""RA_RETURN_UI"" and oBusObj.EditState = 1"". Now I need to do the same thing with orders created with Generate Transactions but have tried various Event and Start Program combinations and have been unsuccessful. Anyone have any tips for me? Thanks in advance!


  • 2.  RE: I have a question regarding setting of values when

    Posted 03-08-2017 18:51
    Generate is in the Receipts Entry screen right? So check for RA_Receipts_ui I think. To be sure you can create a lil button script in Receipts Entry that gives you in a MessageBox or DebugPrint on oSession.StartProgram Not sure if you need to check the EditState. (Another way is from Debugging Environment"", you can drop down to ""command mode window"", click on Halt and at prompt type ? coSession.StartProgram$ then click on Run to restore focus to your screen) .


  • 3.  RE: I have a question regarding setting of values when

    Posted 03-08-2017 19:42
    Thank you! I was reading through the guides you provided in class to figure out how to display information like StartProgram but could not get it to work for some reason. I really need to get better at this debugging or I won't improve in scripting. Thanks for the tip - I'll go try it now!


  • 4.  RE: I have a question regarding setting of values when

    Posted 03-12-2017 14:24
    I have fought with this on and off over the last few days and don't understand why a seemingly simple script is not working. I have set the StartProgram to RA_RECEIPTS_UI and tried Table Post-Read, Pre-Write, Post-Write, Column Post Validate on Order Date, etc. but can't get this to work. Has anyone else had luck performing some scripts with RMA/SO transactions? I have to make sure that this Ship Date calculation takes place only once, which is when the Sales Order gets created from RMA Generate Transactions, so I believe I have to reference the StartProgram.


  • 5.  RE: I have a question regarding setting of values when

    Posted 03-13-2017 12:10
    It might be helpful if you posted the script or a snippet of it. Also what does ""not work"" mean - is your DebugPrint showing you made it at least to the point of SO_SalesOrder_bus for the new order creation? As a test, do you get further by not restricting by StartProgram?


  • 6.  RE: I have a question regarding setting of values when

    Posted 03-13-2017 12:51
    I just tried Generate from RMA. The StartProgram is actually RA_GENERATETRANSACTIONS_UI I created a Post-Read script for SO Entry like this to find out how. 'SO_RMA_Generate_Test.txt OrderNo = oBusObj.GetKey() SP = oSession.StartProgram If Left(SP,2) = ""RA"" Then sMsg = ""Order "" & OrderNo & "" "" & SP r=oScript.DebugPrint(sMsg) retMsg = oSession.AsObject(oSession.UI).MessageBox("""", sMsg) retLog = oSession.WriteLog(""M"", sMsg) ' retVal = oBusObj.SetValue(""Comment$"", SP) End If


  • 7.  RE: I have a question regarding setting of values when

    Posted 03-13-2017 18:05
    Thank you for taking the time on this, Alnoor. I failed at even the creating the debug script, so I really appreciate the help, and will be able to use this in the future. I even adapted your Left function rather than ""RA_GENERATETRANSACTIONS_UI"" since that didn't work either in my script, and I still can't get this to work for Receipt sales orders, only Xpress sales orders. Do you have any idea why these two act so differently? Here's what I have (and tried as Post- Read, Post-Write, etc): SP = oSession.StartProgram If Left(SP,2) = ""RA"" Then sOrderDate = """" : sOrderDate21 = """" : sShipDate = """" : sMDY = ""%M/%D/%Y"" retVal = oBusObj.GetValue(""OrderDate$"", sOrderDate) sOrderDate = oSession.FormatDate(sOrderDate, sMDY) sOrderDate21 = DateAdd(""d"", 21, sOrderDate) sShipDate = oSession.GetFormattedDate(CStr(sOrderDate21)) retVal = oBusObj.SetValue(""ShipExpireDate$"", sShipDate) End If


  • 8.  RE: I have a question regarding setting of values when

    Posted 03-13-2017 18:45
    sOrderDate = oSession.FormatDate(sOrderDate, sMDY) Umm so that line is missing the middle argument and Left of = sign should be a retVal Try these 3 replacement lines. I haven't tested it myself: VBOrderDate = """" 'Append this to your initialized VARs retVal = oSession.FormatDate(sOrderDate, VBOrderDate, sMDY) 'This is like GetValue into the VBOrderDate var sOrderDate21 = DateAdd(""d"", 21, VBOrderDate) 'Adding 21 days to VB formatted order date 'rest is the same Assuming it works now think of which event to fire on. Post-Read the most logical one, your OrderDate will come from the Defaults button of S/O Entry. Usually this is today's date but can be changed by a user. You can force using today's date if need be: retVal = oSession.FormatDate(oSession.SystemDate, VBOrderDate, sMDY)


  • 9.  RE: I have a question regarding setting of values when

    Posted 03-22-2017 16:51
    Alnoor, thanks for your help on this. I still was unsuccessful in getting generated sales orders to recognize my script, and even borrowed one of my developers to check my work, but we could not figure it out. I might try a different angle and then give it up for providex coding instead. Just wanted to make sure I came back to thank you for your time!


  • 10.  RE: I have a question regarding setting of values when

    Posted 03-22-2017 20:58
    OK I will call you then.


  • 11.  RE: I have a question regarding setting of values when

    Posted 03-24-2017 14:07
    Summary: Turns out script was working on Post-Read but Ship Date was being overwritten at a later point by RMA Generation during its SO order creation routine. So Ship Date stayed same as Order Date. Solution was move script to Pre-Write and then there was joy.


  • 12.  RE: I have a question regarding setting of values when

    Posted 03-24-2017 14:13
    Thanks again for your help!! I was going to put the first part of my scripts here that worked after I cleaned them up. This one is for Xpress Sales Orders: 'Desc: Calculates today's date plus 21 days and sets the new date as the Ship Expire Date 'Runs for sales orders only if order is created from RMA Xpress Sales Order 'Bus Object: SO_SalesOrder_bus 'Event: Table - Post-Read If oSession.StartProgram = ""RA_RETURN_UI"" Then ... And for sales orders created from Generate Transactions: 'Desc: Calculates today's date plus 21 days and sets the new date as the Ship Expire Date 'Runs for sales orders only if order is created from RMA Generate Transactions 'Bus Object: SO_SalesOrder_bus 'Event: Table - Pre-Write If oSession.StartProgram = ""RA_GENERATETRANSACTIONS_UI"" Then ...