Wednesday 27 May 2015

AX 2012 HCM Creating a Worker x++ code

Creating a worker in AX 2012

private HcmPersonnelNumberId nextPersonnelNumberId()
{
HcmPersonnelNumberId hcmPersonnelNumberId;
NumberSequenceReference numberSeqReferencePersonnelNum;
NumberSequenceTable numberSeqTablePersonnelNum;
NumberSeq numberSeqPersonnelNum;

// Number Sequence
numberSeqReferencePersonnelNum = NumberSeqReference::findReference(extendedTypeNum(HcmPersonnelNumberId));
numberSeqTablePersonnelNum = NumberSequenceTable::find(numberSeqReferencePersonnelNum.NumberSequenceId);

if (numberSeqTablePersonnelNum)
{
// generate worker personnel number if number sequence code is created.
numberSeqPersonnelNum = NumberSeq::newGetNumFromId(numberSeqTablePersonnelNum.RecId, true, true);

if(numberSeqPersonnelNum)
{
hcmPersonnelNumberId = numberSeqPersonnelNum.num();
}
}
return hcmPersonnelNumberId;
}

private void createHCMWorker()
{
AxDirPerson person;
AxDirPersonName personName;
HcmWorker worker;
HcmPersonnelNumberId hcmPersonnelNumberId;

hcmPersonnelNumberId = this.nextPersonnelNumberId();

if (!hcmPersonnelNumberId)
return;

// Create a person
person = AxDirPerson::construct();
person.parmName("Santa Claus");
person.save();

personName = AxDirPersonName::construct();
personName.parmPerson(person.dirPerson().RecId);
personName.parmFirstName(person.dirPerson().Name);
personName.parmValidTo(DateTimeUtil::maxValue());
personName.save();

// Create the worker
HcmWorkerTransition::newCreateHcmWorker(personName.dirPersonName(), hcmPersonnelNumberId);
}

AX 2012 SSRS REPORT ERRORS AND TROUBLESHOOT

AX 2012 SSRS - Misc Problems and Solutions

Problem
You get a http 503 service unavailable during installation of Report Extensions.

Solution
Check the remote registry settings.Remove Report Server settings in AX.

Problem
The title of the window of a SSRS report doesn't change as expected when editing it on the menu item or from Visual Studio.

Solution
Delete usage data in AX.

Problem
Error while setting server report parameters. Error message: The DefaultValue expression for the report parameter ‘AX_CompanyName’ contains an error: Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (rsRuntimeErrorInExpression)

Solution
Open the file C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\rssrvpolicy.config
Set PermissionSetName to “FullTrust” at Name=Report_Expressions_Default_Permissions

See:
http://community.dynamics.com/product/ax/axtechnical/b/axsupport/archive/2012/02/02/microsoft-dynamics-ax-2012-reporting-extensions-error-system-security-permissions-environmentpermission-while-running-report.aspx

Problem
The reports are deployed to the wrong report folder.

Solution
AX was started with the wrong active client configuration. You need to set the client configuration to the AOS that you wish to deploy to, even though you are overriding it on the client shortcut. Don't forget to restart AX afterwards - the setting is cached when AX is started.

Problem
The report cannot be deployed because it couldn't find the network path.

Solution
Start Windows service "Remote Registry"
See: http://technet.microsoft.com/en-us/library/gg724094.aspx

Problem
Error when running SSRS in batch:
"System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Ax.Xpp.DictMethod' to type 'Dynamics.Ax.Application.SysDictMethod'."

Solution
Change SysDictMethod to DictMethod on line 3 in:
\Classes\SrsReportRdpRdlWrapperContractInfo\buildMemberAndNestedObjectMap

Problem
Error while setting report parameters. Error message: An error has occurred during report processing. (rsProcessingAborted)

Solution
See: https://community.dynamics.com/ax/b/axsupport/archive/2013/03/12/cannot-be-processed-at-the-receiver-due-to-a-contractfilter-mismatch-at-the-endpointdispatcher.aspx

SQL STATEMENT IN AX X++ CODE

SQL statement in Ax code x++ generated 

So here is another small tip based on me reading Inside Microsoft Dynamics AX 2012 R3.

If you want to know what SQL statement the SQL Server query processor generates based on a regular X++ select statement, you can add to the keyword generateOnly to the statement and afterwards call the getSQLStatement method on the record buffer.

Example:
   AccountingEvent         accountingEvent;
   SourceDocumentHeader sourceDocumentHeader;

   select generateonly accountingEvent
   join sourceDocumentHeader
    where sourceDocumentHeader.RecId == accountingEvent.SourceDocumentHeader;

   info (accountingEvent.getSQLStatement());

Issue while working in Dev Environment

Client crashes very frequently.


Set-AXModelStore -InstallMode



QR Code DAX 2012

static void JobCreateforQRCode(Args _args)
{
Image image;
container imageContainer;
str url;
EFDocQRCode_BR qrCode;

// The url to create the QR code.
url = 'http://www.google.com';

// Create an instance of the QR code class
qrCode = new EFDocQRCode_BR();

// Generate a QR code for the URL and save the result to a container
imageContainer = qrCode.generateQRCode(url);

// Use AX's good old Image class to load the image from the container
// and save it as a file
image = new Image();
image.setData(imageContainer);

image.saveImage("F:\QrCode.jpg", ImageSaveType::JPG);
}

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...