22 Ağustos 2017 Salı

Tarih metodları (Date methods)


static void date_Functions(Args _args)
{
    Transdate    d;
    ;

    d = today();

    info(strfmt("Date – %1",d));

    //Gets the month for the given date…
    info(strfmt("Month – %1",mthofYr(d)));

    //Gets the month name from the given date…
    info(strfmt("Month Name – %1",mthname(mthofYr(d))));

    //Gets the day for the given date…
    info(strfmt("Day – %1",dayOfMth(d)));

    //Gets the day name from the given date…
    info(strfmt("Day Name – %1",dayname(dayOfMth(d))));

    //Gets the year for the given date…
    info(strfmt("Year – %1",year(d)));

    //Gets the current weekday number from the date…
    info(strfmt("Weekday number – %1",dayOfwk(d)));

    //Gets the day of the year from the given date…
    info(strfmt("Day of year – %1",dayOfyr(d)));

    //Gets the week of the year from the given date…
    info(strfmt("Week of the year – %1",wkofyr(d)));

    //Gets the start of the month from the given date…
    info(strfmt("Start of the month – %1", DateStartMth(d)));

    //Gets the end of the month from the given date…
    info(strfmt("Enf of the month – %1", endMth(dateMthFwd(d, 0))));

    //Gets the previous month from the given date…
    info(strfmt("The previous month – %1",prevMth(d)));

    info(strfmt("The previous month – %1",maxDate()));

    info(strfmt("current system time %1", DateTimeUtil::utcNow()));

    info(strfmt("current system time %1", DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::utcNow(), DateTimeUtil::getUserPreferredTimeZone())));
}

17 Ağustos 2017 Perşembe

Display Bir Alanda Form İçinde Arama Yapma

Bir formun içerisinde display olan bir alanda arama yapılması isteniyorsa;

Forma arama ve sıfırlama yapmak için iki buton ve arama alanı için bir adet string tipinde alan ekleyip butonların click'ına aşağıdaki kodları ekleyerek çözebilirsiniz.



Forma eklediğimiz alanlar aşağıdaki gibi görünecek. Burada madde adını aratarak filtre koymak istiyoruz.



Eklemiş olduğum OK butonunun Click methoduna şu kodu yazıyoruz;

void clicked() { TRSShipmentReport ShipmentReport; InventTable inventTable; Query q; QueryBuildDataSource qbdShipmentReport; ; super(); if(name.valueStr()) { q = TRSShipmentReport_ds.query(); qbdShipmentReport = q.dataSourceTable(tablenum(TRSShipmentReport)); qbdShipmentReport.clearRanges(); while select inventTable where inventTable.ItemName like "*" + name.valueStr() + "*" { qbdShipmentReport.addRange(FieldNum(TRSShipmentReport, ItemId)).value(SySQuery::value(InventTable.ItemId)); } TRSShipmentReport_DS.query(Q); TRSShipmentReport_DS.executeQuery(); } }
Filtreyi sıfırlamak için de Cancel butonunun Click methoduna aşağıdaki kodu yazıyoruz;
void clicked() { Query q; QueryBuildDataSource qbdTRSShipmentReport; ; super(); q = TRSShipmentReport_ds.query(); qbdTRSShipmentReport = q.dataSourceTable(tablenum(TRSShipmentReport)); qbdTRSShipmentReport.clearRanges(); TRSShipmentReport_ds.query(Q); TRSShipmentReport_ds.executeQuery(); name.text(""); }

11 Ağustos 2017 Cuma

Bizi Unutmayın! | Web

Web sitelerini dolaşırken title'lların farklı sekmeye geçip değiştiğini görünce ilgimi çekti.
Ax'la ilgili değil ama web'le de uğraşanlar için paylaşıyorum.

Bulunduğunuz sekmeden farklı bir sekmedeyken web sitenizin title'ının "Bizi Unutmayın!"
şeklinde değişmesini istiyorsanız, ASP.net ile yaptıyanız web sitenizin master page'ine eklemeniz yeterli olacak.

script> 
var newtitle = ‘ Bizi Unutmayın!’;
var oldtitle = document.title;
window.onblur = function () { document.title =newtitle; }
window.onfocus = function () { document.title = oldtitle; }
 /script>

10 Ağustos 2017 Perşembe

Lookup'a Range Verme

Lookup'ta istenilen kayıtların süzülmesi için Range verebilirsiniz.
Aşağıdaki kod size bu konuda yardımcı olabilir.

 void clicked()
{
    TRSShipmentReport       ShipmentReport;
    InventTable             inventTable;
    Query                   q;
    QueryBuildDataSource    qbdShipmentReport;
    ;
    super();

    if(name.valueStr())
    {
        q                    = TRSShipmentReport_ds.query();
        qbdShipmentReport    = q.dataSourceTable(tablenum(TRSShipmentReport));
        qbdShipmentReport.clearRanges();
        
        while select inventTable
            where inventTable.ItemName like "*" + name.valueStr() + "*"
        {
            qbdShipmentReport.addRange(FieldNum(TRSShipmentReport, ItemId)).value(SySQuery::value(InventTable.ItemId));
        }

        TRSShipmentReport_DS.query(Q);
        TRSShipmentReport_DS.executeQuery();
    }
}

9 Ağustos 2017 Çarşamba

7 Ağustos 2017 Pazartesi

Grid'deki dizaynı düzenleme

Bir rapor yaptınız. Alanlardan bir tanesinin metin uzunluğu fazla olduğu için,
aşağıdaki gibi bir ekran karşınıza gelecektir.


Sizden hücrelerin bu şekilde büyük olmaması istenirse;




Grid'deki ilgili alanın özelliklerinden, Displayheight = 1 yaparsak normale dönecektir.





Kullanıcı Kimliği güncelleme / Created by Update

Dynamics ax 2009 change created By

Dynamics Ax'ta kullanıcı içe aktarırken, kullanıcı kimliğini otomatik atar. Burdan siz isterseniz değiştirebilirsiniz. İçe aktarırken değiştirmediniz, ileride de bu adın değiştirilmesi istenirse;


Kullanıcılardan gidip değiştirmek istediğim kullanıcıyı Yeniden adlandır yapıp eski kayıtları da AX'ın veri tabanından  güncelleyince istenilen kullanıcı kimliği güncelleniyor.

Unutmamanız gereken şey önceki kayıtlarla tutarlı olması için, kullanıcının kayıt girdiği bütün tablolardaki created by alanını da güncellemeniz gerekiyor (Satınalma, satış, talep vs.). (SQL tarafında bunu yapabilirsiniz.)


Nette araştırdığımda SQL tarafına girmeden, aşağıdaki bir kod yardımıyla(Satınalma, satış, talep vs.) ilgili tablolardaki Created by güncellenebilir diyor ama;
 static void MAA_CreatedBy(Args _args)
{
    PurchTable  PurchTable;

 while  select forUpdate   PurchTable
        where PurchTable.createdBy == "maakb4545"

        if(PurchTable.RecId)
            {
              ttsBegin;
               New OverwriteSystemfieldsPermission().assert();
               PurchTable.overwriteSystemfields(true);
               PurchTable.(fieldNum(PurchTable, CreatedBy)) = "makbl";
               PurchTable.doUpdate();
            ttsCommit;
            }

        CodeAccessPErmission::revertAssert();
    info("bitti");
}
Bu kod çalıştığında; aşağıdaki hatayı veriyor.





Bazı blog sitelerde kodu AOS'ta çalıştırın diye tavsiye edilmiş. Fakat burada da aynı hatayı aldım.

Bu yöntemler çözüm olmayınca ancak SQL tarafından çözüm bulabildim.

SQL tarafına yazdığım kod aşağıdaki gibi.
UPDATE PURCHTABLE SET CREATEDBY='makbl' where CREATEDBY='maakb'

Bu kod PurchTable'ı günceller. Siz diğer tabloları(SalesTable, SalesLine, PurchLine vs.) güncellerken tablo adını değiştirip çalıştırabilirsiniz.





Total ciro

static void MAA_SalesTableTotal(Args _args) { SalesTable SalesTable; utcDateTime dateTime; dateTime ...