Welcome at schweda.net | EN | DE
 
 
 
 
 
This post is machine-translated. The original post in german language can be found here.

If you are ever embarrassed to have to create a cost center by code, this job may serve as inspiration:

static void createCostCenter(Args _args)
{
    str 30 _costCenter = "0815"; // Cost center id to create

    OMOperatingUnit omOperatingUnit;
    NumberSeqFormHandler numberSeqFormHandler;
    NumberSeq numberSeq;

    if (_costCenter)
    {
        if (!OMOperatingUnit::findName(
            _costCenter, OMOperatingUnitType::OMCostCenter))
        {
            ttsbegin;
            numberSeq = NumberSeq::newGetNumFromId(
                OMOperatingUnit::getNumberSequenceReference().NumberSequenceId);

            omOperatingUnit.clear();

            omOperatingUnit.initValue();
            omOperatingUnit.omOperatingUnitNumber = numberSeq.num();
            omOperatingUnit.Name = _costCenter;    // Id used as name
            omOperatingUnit.NameAlias = _costCenter;
            omOperatingUnit.omOperatingUnitType = OMOperatingUnitType::OMCostCenter;
            omOperatingUnit.LanguageId = CompanyInfo::languageId();

            if (omOperatingUnit.validateWrite())
            {
                omOperatingUnit.insert();
            }
            ttscommit;
        }
    }
}
These post applies to following versions:
Dynamics AX 2012

Add comment

 

 
Feeds
RSS RSS feed
RSS RSS feed (Comments)
RSS RSS feed (Category)
 
 
posts of the actual month
November 2018
MoDiMiDoFrSaSo
 1234
567891011
12131415161718
19202122232425
2627282930 
 
 
© 2006-2018 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.