Thursday 14 November 2013

How do I add scan-able barcode in my SSRS report?

Many times we need to show a barcode on ssrs report.
We might need it for SalesId, PurchId, ItemId, CustId etc.

Follow these steps to implement this:

1. On the temporary table of the ssrs report, add a new string field "Mybarcode".
2. Set the extended data type property to "BarCodeString".

Now we have added the field that would hold the barcode string. Now there are two phases we need to cover:
1. Implement logic in our report data provider class (RDP class) to populate our field "Mybarcode" with the barcode string.
2. Make changes in our report designer to display the newly added barcode field.

Add this code in your RDP class, in this example we are using ItemId field.
    Mybarcode= BarcodeCode128::construct();
    Mybarcode.string(true,myTmpTable.ItemId);
    Mybarcode.encode();
    myTmpTable.Mybarcode= barcodePurch.barcodeStr(); 
2.  Now open your ssrs report in the visual studio, update the data set. Make sure, it shows the newly added field.

Add a new text box in the report designer, set the expression and font as shown in the attached screenshots.
Well that's all you need to do.




Monday 10 June 2013

How do I fetch data if my table/view name comes as a parameter in a string?

Well, that's where I got stuck once.
But after much investigation, I discovered the solution.

You can make use of SysDictTable class here, pass the name as a string and store the data in buffer of type Common so that no error is raised.


SysDictTable dictTable = SysDictTable::newName('myTableName');
Common common = dictTable.makeRecord();

Now if you want to read a particular field "Description" from table myTableName, if you try doing that by writing Common.Description  you would get an error.

Instead, you should follow this method:

while select common
{
info (common.(dictTable.fieldName2Id('Description')));
}

   

Thursday 23 May 2013

How do I find individual dimension attributes from dimension display value?



This method would return a map- a key value pair.
The key gives the segment name, whereas the value gives the segment value.
private Map getDimAttributes(DimensionAttributeValueCombination _DimensionAttributeValueCombination)
{
    DimensionAttributeValueCombination  dimAttrValueComb;
    DimensionStorage        dimensionStorage;
    DimensionStorageSegment segment;
    int                     segmentCount, segmentIndex;
    int                     hierarchyCount, hierarchyIndex;
    str                     segmentName, segmentDescription;
    SysDim                  segmentValue;
    str retVal;
    ;
    DimAttributesMap = new Map(Types::String,Types::String);
    dimAttrValueComb = DimensionAttributeValueCombination::find(_DimensionAttributeValueCombination.RecId);
    dimensionStorage = DimensionStorage::findById(dimAttrValueComb.RecId);
    if (dimensionStorage == null)
    {
        return DimAttributesMap;
    }
    hierarchyCount = dimensionStorage.hierarchyCount();
    for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)
    {
        segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);
        for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)
        {
            segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);
            if (segment.parmDimensionAttributeValueId() != 0)
            {
                segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;
                DimAttributesMap.insert(segmentName,segment.parmDisplayValue());
            }
        }
    }
    return DimAttributesMap;
}

Friday 8 February 2013

How to find out number of records in each table using code?

static void myJob(Args _args)
{

#AOT
#Properties
TreeNodeIterator iterator;
TreeNode treeNode;

iterator = Treenode::findNode(#TablesPath).AOTiterator();
//make the tree node point to the first table

treenode = iterator.next();

while (treeNode)

{

if (treeNode.AOTgetProperty(#PropertyTableGroup) == 'Main' && treeNode.AOTgetProperty(#PropertySaveDataPerCompany) == 'Yes')

{

info(strFmt("Table Name : %1 Legal Entity: %2 Total Records:%3", treenode.AOTname(), curext(),SysDictTable::casRecordCount(TreeNode.AOTname(),true)));

}

treeNode = iterator.next();

}

}

Monday 28 January 2013

How do I find insert logic of any record in my form?



Select the record on your form, right click and click "Record info".






Click "Script", paste it in your text editor.






Sunday 27 January 2013

Hello world!

Hello folks,
In this blog I intend to share tips and tricks related to Dynamics AX 2012.
I don't want to share much in depth topics, which you can surely find in the books.
However, I intend to address daily "How do I do it in AX? " issues faced by developers out there.