GL_FiscalYearDetail_BUS Not finding record.

SOLVED

I'm trying to retrieve the ending date for a Fiscal Period.  The script opens it but the setkey() is not returning a found flag.  Any ideas what wrong?

retval = oSession.AsObject(oSession.UI).Messagebox( "","Invoice Date Check fired")
Dim Mas_Scr_Dbg

' debug is turned off - set to 1 to enable:
Mas_Scr_Dbg = 1

MasYear = ""
MasPer =""
PeriodEnd = ""
InvDate = ""
retVal = 0
CurYear = 0
CurPer = 0
MaxYear = 0
MaxPer = 0
InvYear = 0
InvPer = 0


retval =oSession.getparameter("S/O","CurrentFiscalYr$",MasYear)
retVal = 0
retval =oSession.getparameter("S/O","CurrentPeriod$",MasPer)
CurYear = int(MasYear)
CurPer = int(MasPer)
retval =oBusObj.GetValue("InvoiceDate$",InvDate)

'********************
oFiscalYear = oSession.GetObject("GL_FiscalYearDetail_BUS")
  if oFiscalYear <> 0 then
   Set oFiscalYear = oSession.AsObject(oFiscalYear)
  else
   retval = oSession.AsObject(oSession.UI).Messagebox( "","oFiscalYear failed")
  return
  end if
 retval = oSession.AsObject(oSession.UI).Messagebox( "","Opened oFiscalYear " & MasYear & " Per " & MasPer)

  retval = oFiscalyear.SetKeyValue("FiscalYear$",MasYear)
  retval = oFiscalyear.setkeyvalue("FiscalPeriod",MasPer)  
  retval = oFiscalYear.SetKey()

 if retval = 1 then
  retval = oFiscalYear.GetValue("PeriodEndingDate$",PeriodEnd) 
  retval = oSession.AsObject(oSession.UI).Messagebox( "","Period End Date " & PeriodEnd)
  
 else
  retval = oSession.AsObject(oSession.UI).Messagebox( "","Not Found")
 end if
retval = oSession.DropObject("GL_FiscalYearDetail_bus")


'*********************

Parents
  • 0
    verified answer

    It is easier to use the GetPeriodDates() method in GL_FiscalYear_Svc.

    PerStartDate = ""

    PerEndDate = ""

    oFiscalYear = oSession.GetObject("GL_FiscalYear_svc")

    Set oFiscalYear = oSession.AsObject(oFiscalYear)

    ' pass in year and period, it returns start date and end date

    retVal = oFiscalYear.GetPeriodDates(MasYear, MasPer, PerStartDate, PerEndDate)

  • 0 in reply to Natasha Chang

    It works fine. I was banging my head against the wall. Insanity is doing the same thing over and over again and expecting a different result.   Do you think there was something I was doing wrong with my setkey() method?

    I need to better understand when to use BUS,UI, and svc.

    Thank you,

  • 0 in reply to jryals

    The GL_FiscalYearDetail_bus object isn't easy to use.  I have to use it though the GL_FiscalYear_bus object to get the period ending date.

    'oFiscalYear is GL_FiscaYear_bus

    'oFiscalYear.DetailObject is GL_FiscalYearDetail_bus

    'Get ending date of 2015 period 1

    retVal = oFiscalYear.SetKey("2015")

    retVal = oFiscalYear.DetailObject.SetKey("201501")

    retVal = oFiscalYear.DetailObject.GetValue("PeriodEndingDate$", endDate)

Reply
  • 0 in reply to jryals

    The GL_FiscalYearDetail_bus object isn't easy to use.  I have to use it though the GL_FiscalYear_bus object to get the period ending date.

    'oFiscalYear is GL_FiscaYear_bus

    'oFiscalYear.DetailObject is GL_FiscalYearDetail_bus

    'Get ending date of 2015 period 1

    retVal = oFiscalYear.SetKey("2015")

    retVal = oFiscalYear.DetailObject.SetKey("201501")

    retVal = oFiscalYear.DetailObject.GetValue("PeriodEndingDate$", endDate)

Children
No Data