check etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
check etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

8 Ağustos 2017 Salı

AX 2012 - Check if period closed

Ledger:

FiscalCalendars::checkModuleIsOpen(SysModule::Ledger, myTable.TransDate,FiscalCalendars::findPeriodByPeriodCodeDate(Ledger::fiscalCalendar(CompanyInfo::find().RecId),myTable.TransDate),false)

or

select firstOnly period
        where transDate >= period.StartDate  && transDate <= period.EndDate
            exists join ledgerPeriod
                where ledgerPeriod.FiscalCalendarPeriod == period.RecId &&
                      ledgerPeriod.Status != FiscalPeriodStatus::Open;
    if (period.RecId != 0)
        throw error("Fiscal period is closed!..");

Sales:

FiscalCalendars::checkModuleIsOpen(SysModule::Sales, CustInvoiceJour.InvoiceDate,FiscalCalendars::findPeriodByPeriodCodeDate(Ledger::fiscalCalendar(CompanyInfo::find().RecId),CustInvoiceJour.InvoiceDate),false)

Invent closing:

InventClosing::findClosingDate(endmth(InventJournalTrans.TransDate))

13 Kasım 2015 Cuma

AXAPTA - Security check with X++ code

Sometimes we need security check with code (Display method etc...):



    SecurityKeySet securityKeys = new SecurityKeySet();
    ;
    securityKeys.loadUserRights(curuserid());

   if (securityKeys.access(securitykeynum("KRC_CrossCompany")) ==  AccessType::NoAccess)
   chkCrsCompany.value(NoYes::No);

5 Ağustos 2015 Çarşamba

AX 2009 - Consume web service with TC ID number test sample

I rewrite sample which I wrote for 2012. When I write the service I used Microsoft'un white page about consume web services in 2009. White page written for a web service which is not avaliable than but anyway worked.

First run AOT->References->Add service reference:

Write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to WSDL URL field.

I wrote TCSorgula to .NET code namespace field. I left reference name field with default written TCSorgula value.

After I wrote this method:

public server static boolean Sorgula(Int64 _TCID,str _name,str _surname, int _birthDate, boolean _interActive = false)
{
    TCSorgula.KPSPublicSoapClient  cl;
    boolean ret;
    System.Exception                      ex;

    str st;
    ;
    try
    {
        new InteropPermission(InteropKind::ClrInterop).assert();
        cl = new TCSorgula.KPSPublicSoapClient("KPSPublicSoap");
        ret = cl.TCKimlikNoDogrula(_TCID,_name,_surname,_dogumYili);
        CodeAccessPermission::revertAssert();
    }
    catch(Exception::CLRError)
    {
        exceptionTextFallThrough();
    }
    if (_interActive)
    {
        if (ret)
            info("TC ID verified!..");
        else
            warning("Failed TC ID verification!..");
    }
    return ret;
}



My job for run code:

static void TCKimlikTest(Args _args)
{
    ;
    TCKimlik::Sorgula(11111111111,"METİN","EMRE",1911,true);
}


 
 TC ID verification service returns false when name or birthdate is wrong in case invalid ID strangely run exception. I was catching this case in AX 2012 with search "T.C. Kimlik No alanına girdiğiniz değer geçerli bir T.C. Kimlik Numarası değildir" value in return error string. Unfortunately I failed this with 2009. So I can just catch correct ID or invalid ID/failed service.

If VS doesn't installed you can install .NET framework SDK.