New Sales Invoice Report Design by condition from code

Hello,

i have 2 custom Sales Invoice designs, i know i can specify 1 in form setup but this isnt the case, my code is below, im trying to switch between INSSalesInvoice.Report and INSSalesInvoice.CommReport by checkbox in SalesTable but it doesnt work, can someone help me understand how do i switch between 2 designs in code instead of form setup by salestable checkbox ?

class INSSalesInvoiceControllerExt extends SalesInvoiceController
{
public static void main(Args _args)
{
CustInvoiceJour custInvoiceJour;

GiroPrintMgmtFormLetterController formLetterController = SalesInvoiceController::construct();

custInvoiceJour = _args.record();

formLetterController.parmArgs(_args);

if(custInvoiceJour.salesTable().INSCommInvoice)
{
formLetterController.parmReportName(ssrsReportStr(INSSalesInvoice, CommReport));
}
else
{
formLetterController.parmReportName(ssrsReportStr(INSSalesInvoice, Report));
}

formLetterController.parmShowDialog(false);
formLetterController.parmDialogCaption("@SYS22766");
formLetterController.startOperation();
}

protected void outputReport()
{
SRSCatalogItemName reportDesign;

if(custInvoiceJour.salesTable().INSCommInvoice)
{
reportDesign = ssrsReportStr(INSSalesInvoice,CommReport);
}
else
{
reportDesign = ssrsReportStr(INSSalesInvoice,Report);
}

this.parmReportName(reportDesign);
this.parmReportContract().parmReportName(reportDesign);
formletterReport.parmReportRun().settingDetail().parmReportFormatName(reportDesign);

super();
}

///


/// Runs the print report.
///

protected void runPrintMgmt()
{
Common printMgmtReferencedTable;
//
LanguageId originalLanguageId;
//
LanguageId originalLanguageId_AE;

if (!journalList)
{
throw error("@SYS26348");
}

journalList.first(custInvoiceJour);

do
{
if (!custInvoiceJour)
{
throw error("@SYS26348");
}
//
if (custInvoiceJour.custInvoiceJour_W().InvoiceType_MY == InvoiceType_MY::GST
&& !TaxGSTHelper_MY::getGSTRegistrationNumber(custInvoiceJour.InvoiceDate))
{
throw error("@SYP4860820");
}
//

// Determine where to start looking for Print Mgmt settings
if (SalesParameters::find().DeleteHeading == NoYes::Yes)
{
// The original SalesTable record no longer exists, so skip that Print Mgmt level
// and start with the customer instead.
printMgmtReferencedTable = custInvoiceJour.custTable_InvoiceAccount();

if (printMgmtReferencedTable == null)
{
printMgmtReferencedTable = custInvoiceJour.custTable_OrderAccount();
}
}
else
{
printMgmtReferencedTable = custInvoiceJour.salesTable();
}

formLetterReport.loadPrintSettings(custInvoiceJour, printMgmtReferencedTable, custInvoiceJour.LanguageId);

PrintMgmtPrintSettingDetail printSettingDetail = this.printSettingDetail();

if(custInvoiceJour.salesTable().INSCommInvoice)
{
printSettingDetail.parmReportFormatName(ssrsReportStr(INSSalesInvoice, CommReport));
}

else

{
printSettingDetail.parmReportFormatName(ssrsReportStr(INSSalesInvoice, Report));
}

if (printSettingDetail)
{
formLetterReport.parmReportRun().loadSettingDetail(printSettingDetail);
}

this.outputReports();

DocumentAttachment documentAttachment = DocumentAttachment::construct(PrintMgmtDocumentType::SalesOrderInvoice);
documentAttachment.parmJournal(custInvoiceJour);
documentAttachment.parmInnerReportDataContract(reportContract);
documentAttachment.parmPrintCopyOriginal(formLetterReport.parmPrintType());
documentAttachment.run();
//
//
if (CustVendInvoiceJour::needToPrintInCompanyLanguage_SA(custInvoiceJour))
{
originalLanguageId = custInvoiceJour.LanguageId;
CustVendInvoiceJour::setLanguage_SA(custInvoiceJour, CompanyInfo::languageId());
}
else
if (originalLanguageId)
{
if (! custInvoiceJour.Proforma)
{
CustVendInvoiceJour::setLanguage_SA(custInvoiceJour, originalLanguageId);
}
originalLanguageId = ‘’;
}
//

if (CustVendInvoiceJour::needToPrintInCompanyLanguage_AE(custInvoiceJour))
{
originalLanguageId_AE = custInvoiceJour.LanguageId;
CustVendInvoiceJour::setLanguage_AE(custInvoiceJour, CompanyInfo::languageId());
}
else if (originalLanguageId_AE)
{
CustVendInvoiceJour::setLanguage_AE(custInvoiceJour, originalLanguageId_AE);
originalLanguageId_AE = ‘’;
}
}
while (this.parmArgs().dataset() != tableNum(CustInvoiceDuplicateTable_W)
&& (originalLanguageId || journalList.next(custInvoiceJour)
|| (originalLanguageId_AE))
&& !this.parmCancelRun());
//
}

}