Sage Accpac Community
Accpac Support Community
Search in

Update Table Script - Get Latest Data

Last post Thu, Jul 2 2009 2:25 PM by mmalm. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • Thu, Jul 2 2009 12:06 PM

    • mmalm
    • Top 50 Contributor
    • Joined on Tue, Dec 23 2008
    • Posts 14

    Update Table Script - Get Latest Data

     I'm attempting to craft an update table script that takes the information stored in Field A and adds it to Field B, depending on certain conditions.  I managed to get the script to work, but if the script is triggered by editing the data in Field A, Field B gets updated with the old value of Field A, not the new value.

    Example.

    Field A has a value of 1234

    Field A is modified to have a value of 12345

    Update table script fires after edit is saved, and Field B now has a value of 1234.

    Is there any way to refer to the post-update value in the table script?

    Thanks in advance.

    My Script:

    // if comp_EIN is greater than zero, append it to comp_ssnein

    if (comp_EIN > 0 && comp_classification == 'Employer') {

    // sql string that will do the update for this company

    sql = "UPDATE Company SET comp_ssnein=comp_EIN WHERE comp_CompanyId=" + eWare.GetContextInfo('Company','Comp_CompanyId')
    UpdateQuery = eWare.CreateQueryObj(sql);
    UpdateQuery.ExecSql();}
    }

  • Thu, Jul 2 2009 2:25 PM In reply to

    • mmalm
    • Top 50 Contributor
    • Joined on Tue, Dec 23 2008
    • Posts 14

    Re: Update Table Script - Get Latest Data

     Found the answer, thanks to the dev blog.  The Values() function gets me the info I need:

     

    var strNewEIN = Values("comp_EIN")

    // sql string that will do the update for this company

    sql = "UPDATE Company SET comp_ssnein=" + strNewEIN + " WHERE comp_CompanyId=" + eWare.GetContextInfo('Company','Comp_CompanyId')

     

Page 1 of 1 (2 items)