Common SSRS Expressions

Hi Axaptians, This is my first post in this month because of hectic schedule. Any how, I got some time to showcase some of my stuff related to SSRS reports. Here you go…..

2016-04-26_1759

2016-04-26_1801

2016-04-26_1802

2016-04-26_1803

2016-04-26_1805

2016-04-26_1807.png

2016-04-26_1807_001

These would be very helpful going forward.

Till then, Happy DaXing…

Display Email of a customer through x++

Hi Axaptians,

Today, I will going to post on displaying Email of a Customer through x++ code.

Without any delay, here is code….

//Email
select firstonly Location from dirPartyLocation
where dirPartyLocation.Party == custTable.Party
join logisticsElectronicAddress
where logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.IsPrimary == NoYes::No
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email;

return logisticsElectronicAddress.Locator;

Till then, Happy DaXing..,

How to clear cache for AX 2012 R2 in Windows Server 2012

Hi Experts,

Hope you are cool. I would be focusing on clear cache for AX 2012 R2 in Windows Server 2012.
Please have a glance at the following steps listed below.

1. Close the client or Stop the AOS
2. Press Windows Key + R
3. Enter Command %userprofile% in Run and press enter
4. Unhide the system files
5. Locate the AppData folder
6. The ax_{GUID}.auc file is now written to the AppData folder
7. Delete the .auc file
8. Open the client or Start the AOS.

AppData Unhide Folder

Note: Please take backup of *.auc and *.kti files before deleting.

Happy DaXing…

 

Missing labels while importing label file and if it gets created, error will display.

Hi Folks,

I have one post taken from Dynamics community which resolved issues related to label file importing. let’s have dig this question which is being posted by user.

Some labels are missed. I tried to import them using import option/label only. The labels are started with ABS, when I try to create a new label file with label file ID (ABS) the following error is faced  “Cannot create the label file ID ABS. The label file ID already exists” but ABS label file does not appear in the AOT nor in  the drop down list appears in the import screen (Create labels in the label file). Another label file is selected from this dropdown list (HCM) and the labels are created with label Ids starting with HCM so the labels are available with another Ids and so the labels’ texts do not appear ,how can we resolve this problem ?????

Answer for this question is as follows…

Label file ABS are present on the application folder.

Usually “C:\Program Files\…. \Server\XXXXX\bin\Application\Appl\Standard”

So :

1- Stop AOS

2- Delete files axABS*.ald, axABS*.alc and axABS*.ali

3- Start AOS

4- Create the Label file ID

4- Import the Label by XPO

Another way for import the label could be, after label file creation, import the ALD file directly from AOT.

So, from Label Files Aot node, right click and choose the option Create from File. You have to repeat for all languages.

Hope this answer your question.Thanks……..

Happy DaXing………

 

 

 

Axutil Commands

Dynamics 365

* AOS name in Server Configuration

Models List:

axutil list /config: <AOS name>

Model elements :

axutil view /model:<model id> /config:<AOS name>


Create a model:

axutil create /model:<model name> /layer:<layer name> /config:<AOS name>

Delete the existing model :

axutil delete /model:<model id> /config:<AOS name>

 export the modelstore:

axutil exportstore /file:”specify the location” /config:<AOS name>

Import a modelstore:

axutil importstore /file:”specify the location” /config:<AOS name>

 Edit a model properties:

Axutil edit /model:”model id” /manifest:Version=”<to which version>”,Publisher=”<publisher name>”,Description=”<Description>”

export the model:

axutil export /model:<model id> /file:”specify the location” /config:<AOS name>

 Import a model:
A model can be imported using several options which can be defined in the Axutil Command
Simple import of a model:
axutil import /file:”specify the location” /config:<AOS name>
Import with Conflict overwrite option:
axutil import /file:”specify the location” /config:<AOS name> /conflict:overwrite
Import with Conflict push option ( only for developers and technical consultants):
axutil import /file:”specify the location” /config:<AOS name> /conflict:push
Import with conflict overwrite and also use replace keyword:
axutil…

View original post 7 more words

Expression to hide/unhide column and Text box in SSRS

Hi Axaptians,

This is second post on 5th Feb and eager to update regarding expressions used in SSRS reports to hide/unhide column or text boxes. In AX 5.0, reports are configured in Morphx but in AX 6.0, reports are being design in VS which is termed as SSRS reports. So, let’s begin this.

I would give an example where I would to like to hide a column or text box by using expression.

=iif(condition,True,false)

Above express will hide column depending on action applied. Suppose, if it is checked, will hide and if not, it will unhide. Following is the example below.

=iif(Parameters!BOMConsistOfDS_Item_Notes.Value = false,True,false)
or
=iif(Parameters!BOMConsistOfDS_Item_Notes.Value = false,1,0)

As simple as that, there are lot of things to be updated regarding expressions.

Please keep in touch for more updates.

Thanks & Happy DaXing…

How to find model of specific object through X++

Hi Experts,

Hope you are doing well.
I would just like to update you with new stuff which I have learnt recently. So, I will write a piece of code which returns model of specific object, in my case, I will use Class as object but you can use others objects as well. So, here you go.

static void jobGetObjectModel(Args _args)
{
SysDictClass sysDictClass = new SysDictClass(classNum(YourClass));
SysModel sysModel;
SysModelManifest sysModelManifest;

select Model, Name, Publisher, DisplayName from sysModelManifest
where sysModelManifest.Model == sysDictClass.treeNode().AOTGetModel()
join firstonly Layer from sysModel where sysModel.RecId == sysModelManifest.Model
&& sysModel.Layer == UtilEntryLevel::sys; // Change layer here

if (sysModelManifest)
info(strFmt(“Model: %1”, sysModelManifest.Name));
else
info(“Object is not apart of model in given layer”);

}

Query will fetch Model, its name, Publisher and DisplayName.

Note: Select layer in which you are looking for…

Thanks and Happy DaXing…

 

Importing data from an XML file

This is a part of previous post on reading and writing xml file from/to AX.

In Dynamics AX, XML file importing is done in a very similar way as exporting. In this recipe, we will continue using the System.XML wrapper application classes. We will create a new class which reads XML files and displays the content on screen. As a source file, we will use the previously created sales.xml file.

How to do it…

Carry out the following steps in order to complete this recipe:
1. Open the AOT, and create a new class named ReadorWriteXml with the following code.
Use the document created in the previous post:
class ReadorWriteXml
{
}

public void readXMLFile()
{
XmlDocument doc;
XmlNodeList data;
XmlElement nodeTable;
XmlElement nodeId;
XmlElement nodeName;
XmlElement nodeCustAccount;
#define.filename(@’C:\Temp\sales.xml’)
doc = XmlDocument::newFile(#filename);
data = doc.selectNodes(‘//’+tableStr(SalesTable));
nodeTable = data.nextNode();
while (nodeTable)
{
nodeId = nodeTable.selectSingleNode(fieldStr(SalesTable, SalesId));
nodeName = nodeTable.selectSingleNode(fieldStr(SalesTable, SalesName));
nodeCustAccount = nodeTable.selectSingleNode(fieldStr(SalesTable, CustAccount));
info(strFmt(“%1 – %2 – %3”,nodeId.text(),nodeName.text(),nodeCustAccount.text()));
nodeTable = data.nextNode();
}
}
public static void main(Args args)
{
ReadorWriteXml file = new ReadorWriteXml();
file.readXMLFile();
}

2. Run the class. The Infolog should display the contents of the sales.xml file on the screen:

1

How it works…

In this recipe, we first create a new XmlDocument. We create it from the file and hence we have to use its newFile() method. Then we get all the document nodes of the table as XmlNodeList. We also get its first element by calling the nextNode() method.

Next, we loop through all the list elements and do the following:
1. Get salesId node as an XmlElement.
2. Get salesname node as an XmlElement.
3. Get cust account as an XmlElement.
4. Display the text of nodes in the Infolog.
5. Get the next list element.
In this way, we retrieve the data from the XML file. A similar approach could be used to read any other XML file.

If you need xpo file of this, please specify your mail address in comment.

Hope you understood….
Till then, Happy DaXing…

Exporting data to an xml file

Hi Folks,
Today, I would like to emphasis on exporting data to an xml file in AX 2012.

Extensible Markup Language (XML) defines a set of rules for encoding documents electronically. It allows the creation of all kinds of structured documents to exchange between systems. In Dynamics AX, XML files are widely used across the application.

For example, user profiles can be exported as XML files. Business data, such as financial statements can also be exported as extensible Business Reporting Language (XBRL) files, which are based on XML.

Probably, the main thing that is associated with XML in Dynamics AX is the Application Integration Framework. It is an infrastructure that allows exposing business logic or exchanging data with other external systems. The communication is done by using XML formatted documents. By using the existing XML framework application classes prefixed with Axd, you can export or import data from or to the system in an XML format to be used for communicating with external systems. It is also possible to create new Axd classes using the AIF Document Service Wizard from the Tools menu to support the export and import of newly created tables.

Dynamics AX also contains a set of application classes prefixed with Xml, such as XmlDocument and XmlNodeBasically, those classes are wrappers around the System.XML namespace in the .NET framework.

In this recipe, we will create a new simple XML document by using the latter classes, in order to show the basics of XML. We will create the file with the data from the SalesTable table and will save it as an XML file.

Following are the steps…

Carry out the following steps in order to complete this recipe:
1. Open the AOT and create a new class named ReadorWriteXml with the following code:

class ReadorWriteXml
{
}

public void writeXMLFile()
{
XmlDocument doc;
XmlElement nodeXml;
XmlElement nodeTable;
XmlElement nodeId;
XmlElement nodeName;
XmlElement nodeCustAccount;
SalesTable salesTable;

#define.filename(@’C:\Temp\sales.xml’)
doc = XmlDocument::newBlank();
nodeXml = doc.createElement(‘xml’);
doc.appendChild(nodeXml);

while select RecId, SalesId,SalesName,CustAccount from SalesTable where salesTable.CustGroup == ‘AGENCY’
{
nodeTable = doc.createElement(tableStr(SalesTable));
nodeTable.setAttribute(fieldStr(SalesTable, RecId),int642str(salesTable.RecId));
nodeXml.appendChild(nodeTable);

//append salesId
nodeId = doc.createElement(fieldStr(SalesTable,SalesId));
nodeId.appendChild(doc.createTextNode(salesTable.SalesId));
nodeTable.appendChild(nodeId);

//append salesname
doc.createElement(fieldStr(salesTable,SalesName));
nodeName.appendChild(doc.createTextNode(salesTable.SalesName));
nodeTable.appendChild(nodeName);

//append custaccount
nodeCustAccount = doc.createElement(fieldStr(salesTable,CustAccount));
nodeCustAccount.appendChild(doc.createTextNode(salesTable.CustAccount));
nodeTable.appendChild(nodeCustAccount);

}
doc.save(#filename);
info(strFmt(‘file is created.’, #filename));
}

public static void main(Args args)
{
ReadorWriteXml file = new ReadorWriteXml();
file.writeXMLFile();
}

2. Run the class. The XML file sales.xml should be created in the specified folder.Open it using any XML editor or viewer, such as Microsoft Internet Explorer, and review the created XML structure:

Untitled

How it works…

We start the recipe by creating a new XmlDocument using its newBlank() method,which represents an XML structure. Then we create its root node named xml using the createElement() method, and add the node to the document by calling the document’s appendChild() method.

Next, we go through the SalesTable and do the following for each record:
1. Create a new XmlElement node, which is named exactly as the table name, and add
this node to the root node.
2. Create a node representing the salesId field and its child node representing its value. The salesId  node is created using createElement(), and its value is created using createTextNode(). The createTextNode() method basically adds a value as text with no XML tags.
3. Add salesId node to the table node.
4. Create a node representing the sales name field and its child node representing
its value.
5. Add salesname node to the table node.
6. Add Cust Account node to the table node.
Finally, we save the created XML document as a file.
In this way, we can create documents having virtually any structure.

My next post will highlight Importing data from xml.
If you need xpo file of this, please specify your mail address in comment.

Hope you understood….
Till then, Happy DaXing…

Creating a custom service in ax 2012

Hi Experts,

I just thought of updating AIF stuff. Let’s start on digging on creating custom service. Before that, let’s elaborate custom service.

A custom service in Dynamics AX allows any X++ logic to be exposed as a service. Custom services are normal X++ classes decorated with attributes, which allow any existing methods to be exposed as service operations without writing any additional code.

In this, we will create a new custom service with a single, simple operation. The operation will accept salesId of sales order and return sales name.

Following are the steps…

1. In the AOT, create a new class named CustomServiceDemo with the following code:

class CustomServiceDemo
{

}
[SysEntryPointAttribute]
Public SalesName getSalesName(SalesId _salesId)
{
return SalesTable::find(_salesId).SalesName;
}

9

2. Set the class properties as follows:

1

3. In the AOT, create a new service with the following properties:

2

4. Expand the newly created service and choose the Add Operation option from the Operations node’s right-click context menu.

5. On the Add service operations form, select the getSalesName line by marking the Add checkbox and clicking on OK:

3

6. The service in the AOT should look like the following screenshot:

4

7. In the AOT, create a new service group named CustomServiceSalesName.

8. In the service group, create a new service node reference with the following properties:

 5

9. Deploy the service group by selecting the Deploy Service Group option from its right-click context menu. The Infolog should display a number of messages about successful deployment.

10. Open System administration | Setup | Services and Application Integration Framework | Inbound ports to check the newly deployed service:

6

How it works…

In Dynamics AX, any class can be a custom service. Here, we create a new one with a single method that accepts salesId  and returns the sales name. To enable the method as a service operation, we specify the SysEntryPointAttribute attribute at the top of the method, which will ensure that the method is available in the service operation list when creating service nodes. We also set the class to run on the server.

Next, we create a new service node and add the newly created operation to it. In order to deploy it, we also have to create a new service group that includes the created service. Once deployed, a new record is created in the Inbound ports form.

If everything is successful the service will be ready to be consumed, which is explained in the next step.

Consuming a custom service

Custom services are consumed in a way quite similar to any other Dynamics AX service.

The difference is that each custom service can have a totally different set of operations, where the system or document services always expose the same list operations.

In this recipe, we will create a .NET console application to demonstrate how to consume a custom service. We will use the service created in the Creating a custom service recipe, which returns a sales name of the provided salesid.

How to do it…

Carry out the following steps in order to complete this recipe:
1. In Visual Studio, create a new Visual C# Console Application project named
ConsumeServiceSalesName.
2. Add a new service reference named CustomServiceSalesName to the project.
3. Copy the address from the WSDL URI field, from the Creating a custom service recipe, into the Address field:
7

4. Add the following code to the top section of the Program.cs file:

using customServiceSalesName.CustomServiceSalesName;

5. Add the following code to the Main() method:

CustomServiceSalesNameClient serviceClient = new CustomServiceSalesNameClient();
CallContext context = new CallContext{Company = “UK13”};
string SalesName = serviceClient.getSalesName(context, “SO000395276-UK13”);
Console.WriteLine(SalesName);
Console.ReadLine();

6. Run the program to display the results as shown in the following screenshot:

8

How it works…

We start this recipe by creating a new Visual C# Console Application project and adding a new service reference pointing to the address from the previous recipe. Then, we allow the use of the type in a namespace.

The code in the Main() method is very similar to the other recipes. Here, we create a new service client object and call its getSalesName() operation to find the sales name.

Hope you understood my stuff. Happy DaXing…