User Defined Scripting

I have created a JobNumber UDF and added it to AR and AP invoice data entry line detail.  Now I would like to create a User Defined Script for the actual Job Number entered during data entry to be written to the JobNumber UDF.  In AR it comes from the header and in AP it comes from the line detail.  The script that I wrote checks out, but it throws an error 88 when I try to enter an invoice.  Any help will be most appreciated!

Thanks in advance.

Parents
  • 0

    ???  Not sure I follow what you are trying to do.

    In your first sentence you indicate you added a JobNumber UDF to AR invoice data entry line detail  and to AP Invoice data entry line detail.  That suggests to me that during invoice data entry you are manually entering that information to the UDFs.

    In the second sentence,  you want to fill in the JobNumber UDFs with a script (which seems to me are already filled in during data entry?).   I assume that you are trying to copy the info from the data entry UDFs to another unnamed file where you have created UDFS?

    I'm lost.

    In addition,  being able to see the script might be helpful to anyone offering assistance.

  • 0 in reply to TomTarget

    I need a UDF that is populated with the Job Number so I can later run reports using the UDF in SMI.  While I know this sounds a little crazy, the goal is to get the Job Number entered during data entry to populate to the UDF by using a script that essentially says "take what has been entered in the Job Number field and copy it into the UDF.  

    I created a UDF and then wrote a script and added the script to the UDF.  

    I am pretty certain that problem with my script is what follows the , in the parenthesis.  But whatever I have tried to put there so far, hasn't worked.

    retVal = 0

    JobNo = ""

    retVal = oBusObj.GetValue("JobNo$",)

    retVal = oBusObj.SetValue("UDF_JOB_NUMBER$",)

  • 0 in reply to jsmith2

    I would suggest sending it to a message box as a test to see if it is reading the JobNo$ field and that there is data there.

  • 0 in reply to jsmith2

    Now put this after each the getvalue and setvalue lines to see which line and what error is actually happening.

    retval = oSession.AsObject(oSession.UI).Messagebox( "This is the jobno retrieved ->" & JobNo   &   "  Error message if any "  & oBusObj.LastErrorMsg)

    BTW what event are you attaching the script to?  Column - post validate for the JobNo field is probably the best bet.

  • 0 in reply to TomTarget

    The event is Table-Set Default Values.  

    So here is the crazy thing... I added the lines to the script as you suggested.  And I changed the event to Column - Post Validate.  Then I decided I should try one thing at a time.  So I deleted the event and reentered Table-Set Default Values.  When I retested, the Job Number populated!  And with no error reporting.  So I removed the added lines from the script, changed the event to Column - Post Validate and tested that.  It worked, as well.

    I wonder if there was some sort of glitch in the original Event setup that wasn't getting read properly.  By deleting it and recreating it, it appears to work now!

    Since both Table-Set Default Values works, do you think Column - Post Validate is still the best bet?  

    Thanks so much for all your help!  

  • 0 in reply to jsmith2

    Column - Post Validate is the correct option.

  • 0 in reply to jsmith2

    To be perfectly honest - I have no clue why Table-Set Default Values would work?   In theory that would fire before you even entered your job number.   I'm guessing that when you recompiled your script you were already in the data entry window.   Seems like a recompiled script doesn't take effect until you exit the data entry and come back in.

    I would stick with Column - Post Validate.

  • 0 in reply to TomTarget

    You have been a great help!!!!  Thanks so much.  One more question.  My script works great for AP.  Now I  have moved on to AR nvoice data entry.  My dilemma...now  I am pulling the JobNo from the Header record to the Line detail record and I think I have to modify my script.  I assume I use oHeaderObj?  Suggestions on how to modify my script?  

  • 0 in reply to jsmith2

    I believe you are on the right track using oHeaderObj.

    The biggest thing you should have learned from this is using the message boxes to show you results and help you figure out where the problems are (is the script running?  where is an error being thrown?  when am I getting results that don't make sense?   etc.).

    Believe me,  without those techniques I would be totally lost.   It's pretty rare for me to not make some silly mistake when I write a script including most of the ones you made in this process.

  • 0 in reply to jsmith2

    Funny... my scripting doesn't seem like rocket science and I feel ridiculous struggling so!  

    I am taking your recommendation and the script is firing.  But I am getting an error when it reads the Header object:  "This is the jobno retrieved ->WMC1599  Error message if any "WMC1599" is not numeric.:"   Then when it is supposed to write to the Line UDF, this is the error:  "This is the jobno retrieved ->WMC1599  Error message if any The 0000079IN00000100000000000001 is invalid.:"

    Unfortunately, I do not know what these errors mean.

    The script is firing and it reads a valid Job Number and my UDF is a string, so I not sure why the header record information would be invalid... it is only supposed to copy the Job Number from the header to the Job Number UDF on the line detail.  

    retval = oSession.AsObject(oSession.UI).Messagebox("Script Fired")

    retVal = 0

    JobNo = ""

    retVal = oHeaderObj.GetValue("JobNo$",JobNo)

    retval = oSession.AsObject(oSession.UI).Messagebox( "This is the jobno retrieved ->" & JobNo   &   "  Error message if any "  & oHeaderObj.LastErrorMsg)

    retVal = oBusObj.SetValue("UDF_JOB_NUMBER_UDF$",JobNo)

    retval = oSession.AsObject(oSession.UI).Messagebox( "This is the jobno retrieved ->" & JobNo   &   "  Error message if any "  & oBusObj.LastErrorMsg)

  • 0 in reply to jsmith2

    retVal=oHeaderObj.GetValue("Field Name$",JobNo)

    retVal=oBusObj.SetValue("Field Name$",JobNo)

  • 0 in reply to BigLouie

    Big Louie:

    Isn't that what I have?  Please let me know what I am missing...  (the extra lines were for error messaging... they are what produced the messages that were supposed to help me figure out where my scripting is wrong.  

    retVal = 0

    JobNo = ""

    retVal = oHeaderObj.GetValue("JobNo$",JobNo)

    retVal = oBusObj.SetValue("UDF_JOB_NUMBER_UDF$",JobNo)

Reply
  • 0 in reply to BigLouie

    Big Louie:

    Isn't that what I have?  Please let me know what I am missing...  (the extra lines were for error messaging... they are what produced the messages that were supposed to help me figure out where my scripting is wrong.  

    retVal = 0

    JobNo = ""

    retVal = oHeaderObj.GetValue("JobNo$",JobNo)

    retVal = oBusObj.SetValue("UDF_JOB_NUMBER_UDF$",JobNo)

Children
  • 0 in reply to jsmith2

    ??  Are you working in A/R or A/P right now?   The second error is suggesting you might be in A/R based on the value with the IN in it.   However other things make me think you are working with A/P?

    What data table and data field have you a attached the event to?   And what event are you using to trigger?

    If you are using oHeaderObj that assumes the event is tied to the detail line file.  

    Also confirm that your user defined field is defined with the correct data type.

    ---

    Note that scripting is not rocket science (or just programming in general),  but neither is it for the faint of heart.   Experience is key and it just takes a little while.  I still struggle at times.    Keep at it.  :)

  • 0 in reply to TomTarget

    Yes, I have moved from AP to AR.  My goal in this project is to bring the Job Number UDF to the General Ledger Transaction Detail for General Ledger reporting by Job Number.  It is a really interesting project and exercise for me!

    I have been successful getting the Job Number from AP Detail lines to my Job Number UDF on the AP Detail lines  (Thanks to your assistance!)  I have also been successful getting my Job Number UDF through the posting processes to the General Ledger Detail Posting file.  It's great!  I can pull up an account in Account Maintenance and see the Job Number UDF populated.  I can also report on it using Business Intelligence.  Very cool!  

    FYI:  I have also been successful in adding the Job Number UDF to my GL data entry routines (JE, Recurring JE and Transaction JE).  But these were much simpler obviously!

    I am now working on AR Invoice Detail.  The Job Number is entered on the AR Invoice Header record, so I am trying to script it to populate to the UDF on the AR Invoice Detail. (Similar to AP, but in AP, the Job Number is actually entered on the AP Invoice Detail, not the header).  

  • 0 in reply to jsmith2

    I repeat:

    What data table and data field have you a attached the event to?   And what event are you using to trigger?

    I'm betting you are tied to the header_record.  If so oBusObj is referring to that, not the detail line.  

    Pushing from the header to the detail is getting a little more complicated as I start to think about it,  because you want it not only to update your lines UDF when the job number changes in the header record, but also as you add a line in the details (meaning you would have to have two versions of the script).

    Any particular reason why you can't just have the UDF in the header and link the files in your report?

  • 0 in reply to TomTarget

    I am using the  ARInvoiceDetail and my Job Number UDF has been added to the line detail. When the Job Number is entered on the AR Invoice header, I want it to copy that job number to my Job Number UDF field in the line detail for each data entry line. This is necessary to get the Job Number to the GLDetailPosting file for reporting reasons.

  • 0 in reply to jsmith2

    Assuming the script is tied to ar_invoicedetal and table-prewrite for the event,  your script looks good to me?

    The error messages don't seem to make sense.   Without some hands on,  I'm not really sure what to tell you at this point.

  • 0 in reply to TomTarget

    OMG!  You won't believe this..  just on a whim, I decided to look at the ARInvoiceDetail file in DFDM... and the Job Number is really populating to my UDF... it just isn't showing in the field I added to the data entry line detail grid.  I am not sure why that is the case.  I just assumed it wasn't getting written because I could see it in the field.  

    You have been a great help and sounding board!  Thanks so much.  

    On to Job Posting Entry!  Figure that one will challenge me because it's legacy...  

  • 0 in reply to jsmith2

    I figured it out!  Table-Post Read works perfectly with my script and the AR Invoice Data Entry fields!  Thanks again.  

    Any helpful hints for Job Posting Entry (I know BOI doesn't work here as it is legacy)?

  • 0 in reply to jsmith2

    Regarding not showing in the grid initially.   I think there is a command that tells the grid to refresh, but I haven't had to use it much so I don't recall.

    Nothing to offer on Job Posting Entry.