Record level security in AX 2012

Hi Experts,

This is an important functionality which is a part of XDS (extensible data security) which I have updated in my technical stuff list. XDS extends data security from a single table to the tables and views that contain related data.

The main difference between role-based security and record level security is  as follows.

Role-based security: By using role-based security, you restrict the menus, forms, and reports that role members can access.

Record level security: By using record level security to set restrictions on specific records or tables in the database, you can restrict the data that is shown in reports and on forms.

The following examples demonstrate how you can use record-level security.

  • Allow members of a Sales role to see only the accounts they manage.
  • Prohibit financial data from appearing on forms or reports for a specific role.
  • Prohibit account details or account IDs from appearing on forms and reports for a specific role.
  • Restrict form and report data according to location or country/region.

When a record-level security policy and a data security policy filter the same data, they may not work together as expected. For example, if the constrained table in the data security policy differs from the primary table in the record-level security filter, the existing record-level security policy is not added to the data security policy query. To achieve the desired behavior, you must add the ranges from the record-level security policy to the data security policy query.

Security policies enable developers and administrators to block access to subsets of data rows in tables. A policy is roughly similar to a where clause in an SQL select statement. A security permission increases the access a user has to data, but a security policy decreases access to data.

Data security policy concepts

When developing a data security policy, you need to become familiar with several concepts, such as constrained tables, primary tables, policy queries, and context. This section outlines these concepts. Subsequent sections will use these concepts to illustrate how they work together to provide a rich policy framework.

Constrained table
A constrained table is the table or tables in a given security policy from which data is filtered or secured, based on the associated policy query. For example, in a policy that secures all sales orders based on the customer group, the SalesOrder table would be the constrained table. Constrained tables are always explicitly related to the primary table in the policy.
Primary table
A primary table is used to secure the content of the related constrained table. For example, in a policy that secures all sales orders based on the customer group, the Customer table would be the primary table.
Policy query
A policy query is used to secure the constrained tables specified in a given extensible data security policy. This query will return data from a primary table that is then used to secure the contents of the constrained table.
Context
A policy context is a piece of information that controls the circumstances under which a given policy is considered to be applicable. If this context is not set, then the policy, even if enabled, is not enforced.
Contexts can be of two types: role contexts, and application contexts.

A role context enables policy application based on the role or roles to which the user has been assigned.

An application context enables policy application based on information set by the application.

Let us proceed with an example now.

Scenario: Restricting SO Form with read level access according to country wise through record level security.

Steps are as follows

  1. privilege with which menuitem SalesTable form with read-level access
  2. Drag above created privilege in newly created duty.
  3. Drag this duty into newly created role.
  4. Create query which is below.
  5. Create a policy which is major part in record level security and assign query and primary table to it which is shown below.

aaaa

bbbb

As you can see from above screenshot, primary table is SalesTable and constraint table is logisticspostalAddress. Context type is Role name in which you are using this policy.

Note: Range plays important part to filter records. Be Careful.

Use this role and test.

Till then, Happy Daxing….

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…