martedì 30 giugno 2015

HOWTO: Detecting default values

So I haven’t posted in a long time. I finally fixed some technical issues on the blog and upgraded to a recent version of WordPress. Let’s start with a quick tip to warm up :)
As you know X++ supports methods with default values. In Ax it’s possible to detect when such a default value was used at runtime with prmIsDefault(). To see this for yourself, create a class with a method like this:

void someMethod(int i = 1)
{
    ;
 
    if (prmIsDefault(i))
    {
        info('Default');
    }
    else
    {
        info('Value given');
    }
}
 
And call it from another method.
    o.someMethod();
    o.someMethod(1);
 
Even though the value is the same in both cases a different info message will be displayed.
Now you may be wondering how this can be useful. Some scenarios:
  • Avoiding expensive operations if the default value was used
  • Avoiding unwanted initializations
  • Dealing with customizations that require extra parameters in standard Ax classes
If you do a search for prmIsDefault() in the AOT you will see it’s used often. Classes with the Ax prefix are the most obvious example. Because getters and setters are rolled into a single method it’s necessary to know if the method was used as a getter or a setter and keep track of modified fields.

Reposted from http://sysdictcoder.com/detecting-default-values/

venerdì 5 giugno 2015

HOWTO: Get EcoResColor name by InventColorId

Step 1: Retrive ecoResProductMasterColor

select ecoResProductMasterColorwhere ecoResProductMasterColor.Color == EcoResColor::findByName(inventDim.InventColorId).RecId
&& ecoResProductMasterColor.ColorProductMaster == inventTable.Product
&& ecoResProductMasterColor.ColorProductDimensionAttribute == EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, InventColorId))
;


Step 2: Get color translation

EcoResProductMasterDimValueTranslation::findByProductMasterDimValLanguage(ecoResProductMasterColor.RecId, 'it').Name 

AX 2012: The request was aborted: Could not create SSL/TLS secure channel

The error you're encountering, "The request was aborted: Could not create SSL/TLS secure channel," can occur due to various re...