Skip to content

Instantly share code, notes, and snippets.

@matejskubic
Created March 11, 2015 13:44
Show Gist options
  • Save matejskubic/8a20bfb2c052f01c7b13 to your computer and use it in GitHub Desktop.
Save matejskubic/8a20bfb2c052f01c7b13 to your computer and use it in GitHub Desktop.
AX 2012 - DeleteFiscalCalendarYear
static void DeleteFiscalCalendarYear(Args _args)
{
FiscalCalendarYear fiscalCalendarYear;
FiscalCalendarPeriod fiscalCalendarPeriod;
LedgerFiscalCalendarPeriod ledgerFiscalCalendarPeriod;
LedgerPeriodModuleAccessControl ledgerPeriodModuleAccessControl;
FiscalYearName yearToDelete = '2011';
ttsBegin;
delete_from ledgerPeriodModuleAccessControl
exists join ledgerFiscalCalendarPeriod
where ledgerFiscalCalendarPeriod.RecId == ledgerPeriodModuleAccessControl.LedgerFiscalCalendarPeriod
exists join fiscalCalendarPeriod
where fiscalCalendarPeriod.RecId == ledgerFiscalCalendarPeriod.FiscalCalendarPeriod
exists join fiscalCalendarYear
where fiscalCalendarYear.RecId == fiscalCalendarPeriod.FiscalCalendarYear
&& fiscalCalendarYear.Name == yearToDelete
;
delete_from ledgerFiscalCalendarPeriod
exists join fiscalCalendarPeriod
where fiscalCalendarPeriod.RecId == ledgerFiscalCalendarPeriod.FiscalCalendarPeriod
exists join fiscalCalendarYear
where fiscalCalendarYear.RecId == fiscalCalendarPeriod.FiscalCalendarYear
&& fiscalCalendarYear.Name == yearToDelete
;
delete_from fiscalCalendarPeriod
exists join fiscalCalendarYear
where fiscalCalendarYear.RecId == fiscalCalendarPeriod.FiscalCalendarYear
&& fiscalCalendarYear.Name == yearToDelete
;
delete_from fiscalCalendarYear
where fiscalCalendarYear.Name == yearToDelete
;
ttsCommit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment