Get all dimension values from Default Dimension

DefaultDimensionView can be used to get dimension values of default dimension.

Default Dimension View


Encryption / decryption(Cryptography) Using x++

Many times we have sensitive data that we don’t want to display to the users. One example for this case is the budget amount in the forecast budgets for the employees’ end of service. We can encryption and decryption in AX by using .Net provided classes.

Below is the example for the encryption.

public static str encrypt(str _txtToEncrypt, str _password)


// convert from string to byte array

ClrObject txtByteArray = System.Text.Encoding::get_ASCII().GetBytes(_txtToEncrypt);

ClrObject encryptor;

ClrObject cryptoStream;

ClrObject encryptedtxt;

System.String stringEncrypted;

ClrObject pdb = new ClrObject(‘System.Security.Cryptography.PasswordDeriveBytes’ , _password, OTH_Cryptography::passwordNasheet());

// create intance of memory stream

System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();

ClrObject streamMode = ClrInterop::parseClrEnum(‘System.Security.Cryptography.CryptoStreamMode’, ‘Write’);

// define the alogorithm you would lime to use,  MD5, DES etch

ClrObject algorithm = System.Security.Cryptography.DES::Create();

// Now set the key and the IV.



// create intance of CryptoStream

encryptor = algorithm.CreateEncryptor();

cryptoStream = new ClrObject(‘System.Security.Cryptography.CryptoStream’ , memoryStream, encryptor, streamMode);

// Write the data and make it do the encryption

cryptoStream.Write(txtByteArray, 0, txtByteArray.get_Length());


encryptedtxt = memoryStream.ToArray();

// convert from byter array to string

stringEncrypted = ClrInterop::staticInvoke(‘System.Convert’, ‘ToBase64String’, encryptedtxt);

return stringEncrypted;


public static str decrypt(str _cipherText, str _password)


ClrObject cryptoStream;

ClrObject decryptor;

ClrObject decryptedData;

System.String decrryptText;

ClrObject cipherBytes = System.Convert::FromBase64String(_cipherText);

ClrObject pdb = new ClrObject(‘System.Security.Cryptography.PasswordDeriveBytes’ , _password, OTH_Cryptography::passwordNasheet());

System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();

ClrObject streamMode = ClrInterop::parseClrEnum(‘System.Security.Cryptography.CryptoStreamMode’, ‘Write’);

ClrObject algorithm = System.Security.Cryptography.DES::Create();



decryptor = algorithm.CreateDecryptor();

cryptoStream = new ClrObject(‘System.Security.Cryptography.CryptoStream’ , memoryStream, decryptor, streamMode);

// Write the data and make it do the decryption

cryptoStream.Write(cipherBytes, 0, cipherBytes.get_Length());


decryptedData = memoryStream.ToArray();

// Now we need to turn the resulting byte array into a string.

decrryptText =  System.Text.Encoding::get_ASCII().GetString(decryptedData);

return decrryptText;



Tags: , , , , , , , , , , , ,

Replace financial dimension value in the Budget Ledger dimension(Budget Planning)

In my recent post, Replace financial dimension value in the ledger dimension. we saw how can we replace the financial dimension in the ledger dimension.

In AX 2012 R3,  Budget planning functionality brought budget ledger dimension which is the extension of the ledger dimension.

Today, we will see how can we replace financial dimension in the budget ledger dimension.

AxdDimensionUtil having methods for the budget planning ledger dimension here is the link for that. Budget Planning helper methods in the AxdDimensionUtil

Below is the method can be used to replace dimension value in the budget planning ledger dimension. Just pass the ledger dimension(RecId), DimensionName (which you want to replace ) and new dimension value.

public static LedgerDimensionBudgetPlanning replaceDimValueBudgetPlanning(
LedgerDimensionBudgetPlanning   _ledgerDimension,
Name                            _dimAttrName,
DimensionValue                  _dimValue)
LedgerDimensionBudgetPlanning   ledgerDimension;
container                       conLedgerDimension;

conLedgerDimension = AxdDimensionUtil::getBudgetPlanningAccountValue(_ledgerDimension);

if (conFind(conLedgerDimension, _dimAttrName))
conLedgerDimension = conpoke(conLedgerDimension, conFind(conLedgerDimension, _dimAttrName)+1, _dimValue);
conLedgerDimension = conpoke(conLedgerDimension, 3, conPeek(conLedgerDimension, 3) +1);
conLedgerDimension = conIns(conLedgerDimension, conlen(conLedgerDimension) +1, _dimAttrName);
conLedgerDimension = conIns(conLedgerDimension, conlen(conLedgerDimension) +1, _dimValue);

ledgerDimension = AxdDimensionUtil::getBudgetPlanningAccountId(conLedgerDimension);

return ledgerDimension;



Tags: , , , , , , , ,

Get value from budget planning ledger dimension.

AxdDimensionUtil class is providing helpful methods for handling the budget planning ledger dimension.

To get the ledger dimension from the value (offset string)
To get more details see To get the ledger dimension from the value
To get the value (offset string from the ledger dimension)
conLedgerDimension = AxdDimensionUtil::getBudgetPlanningAccountValue(
This method return the container

//3110101-104190-1305—00000005,Account structure – MRKT,4,

It gives you the display value, account structure,  number of dimension including main account.


Tags: , , , , , ,

Replace financial dimension value in Ledger dimension

Dimension value can be replaced in a default dimension by using  below standard method.


What If we need to replace the dimension value of a ledger dimension. Below method can be used to replace  the dimension value in a ledger dimension.

public server static LedgerDimensionAccount replaceDimensionValue(
LedgerDimensionAccount _ledgerDimension,
DimensionAttribute     _dimAttr,
DimensionValue         _toDimensionVal)
LedgerDimensionAccount              ledgerDimension;
DimensionDefault                    defaultDimension;
DimensionDefault                    replaceDimension;
DimensionAttributeValue             dimAttrValue;
DimensionAttributeValueSetStorage   dimAttrValDimStorage;

if (_toDimensionVal != ”)
// convert to Default dimensions
defaultDimension =       DimensionStorage::getDefaultDimensionFromLedgerDimension(_ledgerDimension);
dimAttrValDimStorage = DimensionAttributeValueSetStorage::find(defaultDimension);

dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(_dimAttr, _toDimensionVal);

// add dimension value to Default dimension
dimAttrValDimStorage.addItemValues(_dimAttr.RecId, dimAttrValue.RecId, dimAttrValue.HashKey);
replaceDimension =;

ledgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(_ledgerDimension, replaceDimension);



ledgerDimension = _ledgerDimension;


return ledgerDimension;


Tags: , , , , , , , , ,

How to make http request with X++

Below code shows how can we make http request with x++. We are using .Net classes to send the request.

System.Net.WebRequest       Request;
System.Net.WebResponse      Response;
System.IO.Stream            RequestStream;
System.IO.Stream            ResponseStream;
System.IO.StreamReader      readStream;
System.IO.StreamWriter      writer;
str                         strResponse;
str                         postAddress;

postAddress = #AXToServicePath + messageType;
Request = System.Net.WebRequest::Create(postAddress);

// Wrap the request stream with a text-based writer
writer = new  System.IO.StreamWriter(Request.GetRequestStream());
// Write the XML text into the stream
// Send the data to the webserver

Response = Request.GetResponse();
ResponseStream = Response.GetResponseStream();

readStream = new System.IO.StreamReader(ResponseStream);
strResponse = readStream.ReadToEnd();


Tags: , , , , , ,