Scripting

  • 1.  I have a script working on the PO Header - PreTota

    Posted 07-05-2017 10:42
    I have a script working on the PO Header - PreTotals that looks to see if the customer on the any linked SO on the Lines is part of a UDT that has specific costing to populate into the PO. This works perfectly if creating the PO manually & setting the existing SO # on each line. If I do an Auto Generate PO from the SO, it thinks the SO is still in use & gives an Error Log that the SO is locked for writing & it will not write back the PO data to the SO. It does perform the script & set the unit cost in the PO, so it seems to be more of a SO issue than PO... thoughts? I would think the native auto-generation logic would close what needs to be closed on the SO & not sure how I am getting in the way of that. I am updating PO data with my script, not the SO, but I must be holding the SO open somehow...


  • 2.  RE: I have a script working on the PO Header - PreTota

    Posted 07-05-2017 10:50
    why don't you pass that UDT value to the SO and then to the PO? Then you can resolve the costing on the SO line or PO line.


  • 3.  RE: I have a script working on the PO Header - PreTota

    Posted 07-05-2017 11:31
    Are you using a BUS object to reference the SOs (it should probably be a SVC if you're just reading)? Are you closing and cleaning out the SO object prior to the end of the script?


  • 4.  RE: I have a script working on the PO Header - PreTota

    Posted 07-05-2017 12:54
    It all depends on the timing of when your script fires off and when Auto Gen PO from SO is trying to lock (EXTRACT) the SO record so it can update the PO number on the SO lines. If you're lucky it won't lock until it's ready to Write and your script may have completed by then. So then not only use _SVC like Steve said with Find (instead of SetKey) after you do you GetValue's, try doing a .Clear() as in retVal=oSO.Clear() (substitute oSO for whatever you've called it). That will ""clear"" the record for locking by Auto Gen.


  • 5.  RE: I have a script working on the PO Header - PreTota

    Posted 07-07-2017 04:36
    Thank you everyone! It is now working & not locking up the SO & no longer receiving the Error Log. So, I had tried the SVC before, but was getting an error on the SetKey, so using the Find helped that. And, maybe the Clear helped too. I appreciate the help, as always!