X++ :13- Update Metodu Ne İşe Yarar?

Bu yazıda Dynamics 365 Finance and Operations tablo metotlarından Update() metodunu anlatacağım. Önceki yazılarımda tabloların temel yapılarından bahsetmiştim. Şimdi ayrıntılı olarak alt seviye nesne ve metotları inceleyeceğim. Tablolar XRecord sınıfından türetilen aslında SQL tabloların sınıf karşılıklarıdır. Sınıflardan temel bir iki farkı vardır. Sınıf olmasına rağmen New ile nesne oluşturmak gerekmez. Alanlar metot gibi davranın ama paranteze ihtiyaç duymaz. Update() metodu tabloda bir kayıt güncellenirken çalışan metottur.

FDBookTable tablosunda Metotlara sağ tıklayıp Update() metodunu Override ettim.

Resim-1

Super()’i daha önce anlatmıştım. Aslı işi yapan yanı DB’deki veriyi güncelleyen ana sınıftaki kodu çağırır. Basit bir kod yazdım her seferinde sayıyı bir arttıracak şekilde.

Resim-2

Tablo tarayıcısını açıp herhangi bir güncelleme yaptığımda sayının arttığını gördüm.

Resim-3

void update(boolean _updateSmmBusRelTable = true, boolean _updateParty = true)

{

CustTable   this_Orig = this.orig();

RecVersion  rv = this_Orig.RecVersion;

ttsbegin;

super();

// Update the full text search table

MCRFullTextSearch::update(this);

this.SysExtensionSerializerMap::postUpdate();

if (_updateSmmBusRelTable)

{

smmBusRelTable::updateFromCustTableSFA2(this, ”, false);

}

if (this_Orig.CustGroup != this.CustGroup)

{

ForecastSales::setCustGroupId(this.AccountNum,

this_Orig.CustGroup,

this.CustGroup);

}

smmTransLog::initTrans(this, smmLogAction::update);

// If the customer group has changed

if (this.CustGroup != this_Orig.CustGroup)

{

// clear the ledger cache

LedgerCache::clearScope(LedgerCacheScope::PartyMainAccountDimensionListProvCust);

}

if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoMX]) && _updateParty)

{

this.copyInfoToParty();

}

ttscommit;

}

CustTable Update() metodunu inceleyelim. Güncelleme olduktan sonra eğer belli bir alanın güncellenip güncellenmediğini kontrol etmek istiyorsanız this.Orig() ile kaydın orijinal halini alıp kıyaslayabilirsiniz.

CustTable   this_Orig = this.orig();

if (this.CustGroup != this_Orig.CustGroup)

Bu iki satır kullanıma güzel bir örnek.

Selamlar.

www.fatihdemirci.net

TAGs: X++,Update, Azure, Azure DevOps, Microsoft Dynamics 365, MsDyn365FO, MsDyn365CE, MsDyn365

 
Comment are closed.