Sunday 6 December 2015

Uninstall a model through Windows PowerShell

Hi guys,

A little demonstration on how to Uninstall Model in AX 2012

Steps -

1. Go to the  Start menu > All programs >  Administrative Tolls
2. At windows Powershell command prompt  > PS C:\>
3. Type the follwing command and press enter.

          Uninstall-AXModel -Model <ModelName>

This above command will uninstall specified Model and Confirmation request/Message will will be displayed on the screen.


For Information - click here


Happy DAXing :-)

Wednesday 18 November 2015

Change background color in Microsoft Dynamics AX

Hi guys,


Today I am discussing about very interesting/colourful topic. Generally we face the requirement to change the backgroud color of AX forms. Hence, user can differentiate between companies.
This is very simple you have to overwrite Run method into the "SysSetupFormRun" class and bellow code for changing background AX

Class - "SysSetupFormRun"
> Over
public void run()
{
;
super();
switch(curext)
{
case "AYN":
        this.design().colorScheme(FormColorScheme::RGB);
        this.design().backgroundColor(WinAPI::RGB2int( 204,255,0));
        break;
case "CAT":
        this.design().colorScheme(FormColorScheme::RGB);
        this.design().backgroundColor(WinAPI::RGB2int (155,255,0));
        break;
}
}

You can provide your color: in RGB format :-)


Happy DAXing :-)




Count Row in SSRS report AX [2012]

Hi guys,

Count rows for SSRS report, this is very general requirement for report. 
Use bellow syntax, With this syntax you can find total number of Row in your SSRS report. 

 = RowNumber(scope) 

Note- The value of scope cannot be an expression and must refer to the current scope or a containing scope.

Or  You can use simple syntax bellow

 = RowNumber(nothing) 


Hope it will help....


Happy DAXing :-)

More Info click here 

How to Export/Import Label files in AX [2012]

Hi guys,

Today in this session I am going to explain how to Import/Export labels in AX 2012.
Labels are pretty good to specify the user interface text for report and form. 
You can create Label from Label editor.
Open AOT  >  Tools > Label > Label editor
You view Label log from > AOT > Tools > Label > Label editor

Export label file-
Exporting Label file is very easy - Open AOT  > Label files  > Expand Label > select individual language.
Click on the "Export to the Label file" and provide the  path, Label file will export with the extension ".ald"





  

Import Label File -
Now we have to import Labels Open AOT > select Label File Node > Right click and click on "Create from Label" then browse earlier exported Label file with extension ".ald" and then click OK to Import Label file.






Note- If you want to update Label file follow same steps. 
but it will ask for Do you want to overwrite?
Hit enter.




It will update existing label file. 
And I hope it will helpful for you.......

More Info click here
Happy DAXing :-)

Monday 9 November 2015

Send Workflow Notification / Popup / Alert using X++ [AX 2012]

Hi guys,

Recently I was a requirement to create customized Sales Order Discount Approval workflow. There is  a lot of scenario to mapping  the process.
In this session I am describing  how to send notification or alert to respective User Group / Users as bellow job 

// Send notification or Alert
static void SendAlert_Notication(Args _args)
{
    Dialog          dialog;
    DialogGroup     dialogGroup;
    DialogField     dialogfield;
    DialogBox       dialogBox;    
    
    EventInbox      EventInbox;
    UserGroupList   userGroupList;
    SalesLine       updateSalesLine;
    UserGroupId     groupId;     
    SalesLine       salesLine;
    ;    
    //Dialog call
    dialog= new dialog("Sales Price Discount Approval");
    dialogGroup= dialog.addGroup("Comment");
    dialogfield= dialog.addField(extendedTypeStr(Ale_Comment));
    if (dialog.run())
    dialogfield.value();
    

    while select userId from userGroupList
    where userGroupList.groupId == "Admin"
    {
        while select SysUserInfo order by SysUserInfo.Id where SysUserInfo.Id  == userGroupList.userId 
        {
            EventInbox.InboxId                      =   EventInbox::nextEventId();
            EventInbox.CompanyId                    =   SalesLine.dataAreaId;
            EventInbox.AlertTableId                 =   359;
            EventInbox.AlertCreatedDateTime         =   DateTimeUtil::utcNow();
            EventInbox.ParentTableId                =   359;
            EventInbox.IsRead                       =   NOYES::No;
            EventInbox.Subject                      =   "SalesOrder Discount Approval";
            EventInbox.AlertedFor                   =   dialogfield.value();
            EventInbox.UserId                       =   SysUserInfo.Id;
            EventInbox.ShowPopup                    =   NOYES::Yes;
            EventInbox.Visible                      =   NOYES::Yes;
            EventInbox.Message                      =   dialogfield.value();
        }
    }
    
}    

Hope it will help...


Happy DAXing :-)


Friday 6 November 2015

Microsoft Dynamics AX 7 Development with Visual Studio

Hi guys,

Greetings!
Learn and explore AX 7 through this video....
I saw this video on you tube and thought to share with you. This video demonstrates how to use Visual Studio to create a Dynamics AX 7 Project and Add an EDT in AX without MorphX as we all know by now MorphX is taken out in AX 7.
Good video and thanks for sharing
https://www.youtube.com/watch?v=05KsvTcmySs&list=PLIh45kooHi8fcPZIAF8zosVaOGg0ll-D9&index=4

Happy DAXing :-)

Monday 2 November 2015

Fetch Product Attribute value in [AX 2012]

Fetching Product Attribute value in Ax 2102 is little bit tricky.................
Recently I was a requirement in SSRS report to fetch Product Attribute value. Job seems very easy but after lot of trouble shooting, I explored that there is three major tables as bellow mentioned tables and job...

EcoResProductAttributeValue 
EcoResAttribute              
EcoResValue                   


static void ProductAttributevalue(Args _args)
{
EcoResProductAttributeValue ecoResProductAttributeValue;
AttributeValueText          attributeValueText;
InventTable                 inventTable;  
EcoResAttribute             ecoResAttribute;
EcoResValue                 ecoResValue;


while select crosscompany  InventTable where InventTable.itemid ==  'Item001'
{
    while select crosscompany Product,Attribute,Value from ecoResProductAttributeValue
        where ecoResProductAttributeValue.Product == InventTable.Product
    {
        select crosscompany RecId from ecoResAttribute
             where ecoResProductAttributeValue.Attribute == ecoResAttribute.RecId;

        select crosscompany ecoResValue
             where ecoResValue.RecId == ecoResProductAttributeValue.Value;
        info(strFmt("%1",ecoResValue.value()));
    }
}
}

hope it will help.........

Happy DAXing :-)

Sunday 1 November 2015

Use of Crosscompany to get Data from other companies using X++ [AX 2012]

Hi,

Use of Crosscompany to get Data from other companies.
Today I am explaining how to use Crosscompany in your code.....

Example 1.
static void CrossCompany_example(Args _args)
{
InventTable inventTable;

While select crosscompany * from inventTable

{

info( inventTable.ItemId + " : " + inventTable.NameAlias + " : " + InventTable.dataAreaId);

}

}


Example 2.
static void CrossCompany_example(Args _args)
{
InventTable     inventTable;
container conCompanies = [ 'USRT', 'USSI' ]; // you can assign selected companies
str comp;
;

while select crossCompany : conCompanies * from inventTable
{
info( inventTable.ItemId + " : " + inventTable.NameAlias + " : " + InventTable.dataAreaId);
}

}

For more click  here

Happy DAXing :-)

Thursday 29 October 2015

Add serial number/Line num on Form [AX 2012]

Code for Serial number and write bellow code on Form Data source 
> Create method 

public void create(boolean _append = true)
{
    Table                     table;
    RefRecId                conter;

    super(_append);

    select count(RecId) from table;

    if (!table.RecId)
    table.SerialNo += 1;
    else
    table.SerialNo = table.RecId + 1;

    table_ds.refresh();
}


Happy DAXing :-)

Sunday 25 October 2015

Insert/Update /Replace Financial Dimension in Default Dimension [AX 2012]

Hi,

Insert/Update /Replace Financial Dimension in Default Dimension AX 2012.
I was a requirement to Insert/update Financial Dimension in Default Dimension. The job job was pretty big to play with financial dimension in AX 2012.

Here is the Job bellow to change the dimension....

static void UpdateDefaultDimensions(Args _args)
{

CustTable                       csttbl = CustTable::find("C-00001");
Struct                          struct = new Struct();
container                       defDimensionCon;
DimensionDefault                dimDefault;
DimensionAttributeSetItem       dimAttrSetItem;
DimensionAttribute              dimAttribute;
int i; //For looping


while select Name, BackingEntityType from dimAttribute
where dimAttribute.BackingEntityType == tableNum(DimAttributeSmmCampaignTable) ||
dimAttribute.BackingEntityType == tableNum(DimAttributeOMDepartment) ||
dimAttribute.Type              != DimensionAttributeType::DynamicAccount
join dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimAttribute.RecId &&
dimAttrSetItem.DimensionAttributeSet == DimensionCache::getDimensionAttributeSetForLedger()
{
if (dimAttribute.BackingEntityType == tableNum(DimAttributeSmmCampaignTable))
{
struct.add(dimAttribute.Name, "00006");
}
else if (dimAttribute.BackingEntityType == tableNum(DimAttributeOMDepartment))
{
struct.add(dimAttribute.Name, ‘DEP-002’);
}
}
defDimensionCon += struct.fields();

for (i = 1; i <= struct.fields(); i++)
{
defDimensionCon += struct.fieldName(i);
defDimensionCon += struct.valueIndex(i);
}
if (struct.fields())
{
dimDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(defDimensionCon);

ttsBegin;
csttbl.selectForUpdate(true);
if (csttbl.DefaultDimension)
{
csttbl.DefaultDimension =                             DimensionDefaultingService::serviceMergeDefaultDimensions(dimDefault,           csttbl.DefaultDimension);
}
else
{
csttbl.DefaultDimension = dimDefault;
}
csttbl.doUpdate();
ttsCommit;
}
info("Dimension Updated....");
}


Happy DAXing :-)

Tuesday 29 September 2015

Demonstration on Roles based security in Microsoft Dynamics AX 2012

I am writing this post to demonstrate about Roles and Security in AX 2012.

This section describes the security concepts in AX 2012 and explains how to set up and maintain security in MICROSOFT DYNAMICS AX 2012.
Security has very important roles to play in any ERP implementation. The security aspects of an ERP to helps the administrator to restrict the data to the users and provides the enough right to the user as per the roles and responsibilities(department). Security administrator can controls the rights of access different Modules, Form , reports based on the User group or individual user.

Let's have a look- Privilege:-
Privileges specify the access that is required to perform a duty. A privilege includes one or more permissions i.e we can more than one entry points by simply drag and drop functionality based on the menu item.And you can set the access level on the entry point permission properties as NoAcess, read , update , create , correct and delete. Delete the highest permission level.




Duties:- 
Now we have to create duties under Duties node and a duty is a responsibility to perform one or more tasks.  A duty includes one or more privileges. 






Roles:- 
Now we have to create roles  and drag duties earlier we have created under the Duties node.
All of the users must be assigned at least one security role to have access to Microsoft Dynamics AX. By managing the user’s access through security roles.





Note-   Set the proper roles label ad description. it will help to assign the  roles to the user on "Assign roles to user" Form.



Now assign roles to different user.
Go to the System Administration | Common | Users 






Now edit the user to assign the roles.



Note - You can also assign roles and duties from the path bellow 
System Administration > Setup > Security  > Assign roles to Users

Hope it is clear now on how the access to forms, reports is controlled using the roles, duties and privileges. In next post, I will demonstrate about the Record level securities i.e XDS 

I hope you like this post, Your suggestions are most welcome to get this blog better.
Keep visiting and Keep DAXing.



Happy DAXing :-)
Follow  on Twitter  Atul

Tuesday 4 August 2015

Deploy Dynamics AX 2012 SSRS report through Powershell

Deploy Dynamics Ax 2012 SSRS report though WindiowsPowershell. It is very easy.

Let's have a look.

Press- Window + R > type powershell > enter

To deploy a specific report, enter the name of the report. For example, to deploy the SalesInvoice report, enter the following command:
Publish-AXReport -ReportName SalesInvoice

To deploy multiple report - enter the following command
Publish-AXReport -ReportName SalesInvoice , PurchaseInvoice

To deploy all report - enter the following command
Publish-AXReport -ReportName *

Thank You!
Atul Kumar

List of Expressions and function used in Dynamics Ax 2012 SSRS reports

Expressions and function used in Dynamics Ax 2012 SSRS reports

During working in SSRS reports I have to handle division by Zero error for calculating accumulated cost by dividing Amount by Quantity.


This expression works for me.


IIf(Sum(Fields!xyz.Value) = 0, “N/A”, Sum(Fields!abc.Value) / IIf(Sum(Fields!abc.Value) = 0, 1,Sum(Fields!xvz.Value)))

I did little research on Expressions and function used in these SSRS expressions


Expressions:

Expressions are used for manipulate or update the value, for example, cost show by dividing amount by Quantity. Rounding of decimal. Similarly Expression can be used to highlight the filed if condition meets. Style font can be changed, even you can uses switch statement, to change the display value of report.



Types of Expressions

Globals
Operators – Arithmetic, Comparison, Logical
Common Functions – Text, Date & Time, Math, Inspection, Program Flow, Aggregate, Financial, Conversion, Miscellaneous

We can see each and every one very detail in following.





Globals

Global expressions executes/works in Page Header and Footer parts only.

ExecutionTime shows date and time at when report executes
PageNumber shows page number of each and every page but allowed only in page header and footer
ReportName displays name of the active report what name we have assigned to the active report
UserId shows current user name like company/AtulKumar
Language displays language like US-English…

Operators

Arithmetic
^ power of
* multiplication
/ divides two numbers and returns a floating point result
\ divides two numbers and returns a integer result
Mod divides two numbers and returns remainder only
+ adds two numbers and concatenation for two strings
– subtraction and indicates negative value for numeric values
Comparison
Known operators : < <= > >= <> 
Like compares two strings and return true if matched or else returns False. Ex: =Fields!Title.Value Like Fields!LoginID.Value
Is compare two object reference variables Ex: = Fields!Title.Value Is Null
Concatenation
+ and & symbols uses for concatenation
Logical
Known: And, Not, Or 
Xor SELECT * FROM users where firstname = ‘Larry’ XOR lastname = ‘Smith’
AndAlso First condition will check first and if it is true only, goes to next or else it won’t need to check. Because our execution time is saving in a logical operation in which more conditions is combined using AndAlso function.
OrElse same like above

Common Functions

Text

Asc, AscW returns an integer value represents character code corresponding to a character

Chr, chrw returns the character associated with the specified character code

Filter =Filter(Fields!Title.Value,”Pr”,true,0

Format
=Format(Fields!Price.Value, “#,##0.00″), Format(Fields!Date.Value, “yyyy-MM-dd”)

FormatCurrency =formatcurrency(Fields!SickLeaveHours.Value,3)

FormatDateTime =FormatDateTime(Fields!BirthDate.Value,Integer)
Examples:
0 returns 10/10/2014
1 returns Friday, October 10, 2014
2 returns 6/3/2014
3 returns 12:00:00AM
4 returns 00:00

FormatNumber =FormatNumber(Fields!EmployeeID.Value,2)
Examples: 4.00

FormatPercent =”Percentage : ” & formatpercent(Fields!SickLeaveHours.Value)

GetChar =GetChar(Fields!Title.Value,5)

InStr =InStr(Fields!Title.Value,”a

InStrRev =Instrrev(Fields!Title.Value,”a

LCase Change strings into lower case
=Lcase(Fields!Title.Value)

Left Returns left side characters from a string
=Left(Fields!Title.Value,4)

Len Finds length of a string
=Len(Fields!Title.Value)

LSet Returns some length of a string from left
=Lset(Fields!Title.Value,5)

LTrim Trim left side of a string
=Ltrim(” “&Fields!Title.Value)

Mid Returns characters from the mentioned starting position
=Mid(Fields!Title.Value,InSTrRev(Fields!Title.Value,”T

Replace Replaces one string with another
=Replace(Fields!Title.Value,”a”,”A

Right Returns right side characters from a string
=Right(Fields!Title.Value,10)

RSet Returns some length of a string from left
=Rset(Fields!Title.Value,5)

RTrim Trim left side of a string
=Rtrim(Fields!Title.Value & ” “)

Space Specifies some spaces within strings
=Fields!Title.Value & Space(5) & Fields!Title.Value

StrComp Returns a value indicating the result of a string comparison

vbBinaryCompare 0 Perform a binary comparison.
vbTextCompare 1 Perform a textual comparison.
string1 is less than string2 -1
string1 is equal to string2 0
string1 is greater than string2 1
string1 or string2 is Null Null

StrConv
=Strconv(Fields!Title.Value,vbProperCase)
=Strconv(Fields!Title.Value,vbLowerCase)
=Strconv(Fields!Title.Value,vbUpperCase)

StrDup Returns a string or object consisting of the specified character repeated the specified number of times.
=StrDup(3,”M”)

StrReverse =StrReverse(Fields!Title.Value)

Trim =Trim(” “& Fields!Title.Value & ” “)

UCase =Ucase(Fields!Title.Value)

Date & Time

CDate Converts a object into date format
=Format(CDate(Fields!BirthDate.Value),”MMMM”)

DateAdd Returns a datetime that is the result of adding the specified number of time interval units to the original datetime.

=dateadd(“m”,12,Fields!BirthDate.Value)

DateDiff Find number of days, months and years between two dates
=datediff(“d”,Fields!BirthDate.Value,Now)

DatePart DatePart(DateInterval.Weekday, CDate(“2009/11/13″), FirstDayOfWeek.Monday) returns 5 (Friday)

DateSerial for first day of the month
=DateSerial(Year(Now), Month(Now), 1)
for the last day of the month
=DateSerial(Year(Now), Month(Now)+1, 0)

DateString Returns string value of system date
=datestring()

DateValue Returns current date

Day Returns day value from date
=day(Fields!BirthDate.Value)

FormatDateTime =FormatDateTime(Fields!BirthDate.Value,Integer)
Examples:
0 returns 6/3/2014
1 returns Friday, June 03, 2014
2 returns 6/3/2014
3 returns 12:00:00AM
4 returns 00:00

Hour =Hour(Fields!BirthDate.Value)

Minute =Minute(Fields!BirthDate.Value)

Month =Month(Fields!BirthDate.Value)

MonthName =MonthName(Month(Fields!BirthDate.Value))

Now Indicates current month
=Now() or =Now

Second =Second(Fields!BirthDate.Value)

TimeOfDay =TimeOfDay()
Returns a date value containing the current time of day according to your system

Timer =Timer()
Returns number of seconds elapsed since midnight

TimeSerial =TimeSerial(24,60,60)
Returns a date value representing a specified hour, minute and second

TimeString =TimeString()
Returns string value representing the current time of day according to your system

TimeValue Returns a date value set to jan 1 of year 1
=TimeValue(Fields!BirthDate.Value)

Today Returns Current date

Weekday Returns an integer value representing day of week
=WeekDay(Fields!BirthDate.Value)

WeekdayName =WeekdayName(Weekday(Fields!BirthDate.Value))
Returns name of the day of week

Year =year(Fields!BirthDate.Value)
Returns year of specified date

Math

Abs Returns the absolute value
=Abs(-2.36)

BigMul Returns multiplication value of two specified numbers
=BigMul(2,3)

Ceiling Returns next highest value
=Ceiling(2.67)

Cos
=Cos(2.33)
Returns cos value for specified number

Cosh
Returns hyperbolic cos value
=Cosh(2.33)

DivRem
=DivRem(23,2,5)

Fix
=Fix(23.89)
Returns integer portion

Floor
=Floor(24.54)
Returns largest integer

Int
=Int(24.78)
Returns integer portion of a number

Log
=Log(24.78)
Returns logarithm value

Log10
=Log10(24.78)
Returns the base 10 logaritm value

Max
=Max(Fields!EmployeeID.Value)
Returns larger value in the specified values

Min
=Min(Fields!EmployeeID.Value)
Returns smaller value in the specified values

Pow
=Pow(Fields!EmployeeID.Value,2)
Returns power of value for specified number

Rnd
=Rnd()
Returns a random number

Round
=Round(43.16)
Returns rounded value to the nearest integer

Sign
=Sign(-34534543)

Sin
=Sin(Fields!EmployeeID.Value)
Returns the sin value

Sinh
=Sinh(Fields!EmployeeID.Value)
Returns the hyperbolic sin value

Sqrt
=Sqrt(Fields!EmployeeID.Value)
Returns square root value

Tan
=Tan(Fields!EmployeeID.Value)
Returns the tan value

Tanh
=Tanh(Fields!EmployeeID.Value)
Returns the hyperbolic tan value

Inspection
IsArray
=IsArray(Fields!EmployeeID.Value)
Returns a boolean value indicating whether the specified object is array or not

IsDate
=IsDate(Fields!BirthDate.Value)
Returns a boolean value indicating whether the specified object is Date or not

IsNothing
=IsNothing(Fields!EmployeeID.Value)
Returns a boolean value depends on specified object is Nothing or not

IsNumeric
=IsNumeric(Fields!EmployeeID.Value)
Returns a boolean value depends on specified object is Numeric value or not

Program Flow

Choose
=CHOOSE(3, “Red”, “Yellow”, “Green”, “White”)
Returns a specific value using index in a list of arguments

IIf
=IIF(Fields!EmployeeID.Value>10,”Yes”,”No
Returns any one value depends on condition

Switch
=Switch(Fields!EmployeeID.Value<10,”Red
Fields!EmployeeID.Value>10,”Green
Evaluates list of expressions

Aggregate

Avg
=Avg(Fields!EmployeeID.Value)
Returns average value for all specified values

Count
=Count(Fields!EmployeeID.Value)
Returns count of all specified values

CountDistinct
=CountDistinct(Fields!EmployeeID.Value)
Returns count of all distinct values

CountRows
=CountRows()
Returns count of rows

First
=First(Fields!EmployeeID.Value)
Returns first for all specified values

Last
=Last(Fields!EmployeeID.Value)
Returns last for all specified values

Max
=Max(Fields!EmployeeID.Value)
Returns max for all specified values

Min
=Min(Fields!EmployeeID.Value)
Returns min for all specified values

StDev
=StDev(Fields!EmployeeID.Value)
Returns standard deviation value

StDevP
=StDevP(Fields!EmployeeID.Value)
Returns Population standard deviation value

Sum
=Sum(Fields!EmployeeID.Value)
Returns sum of all values

Var
=Var(Fields!EmployeeID.Value)
Returns variance of all values

VarP
=Var(Fields!EmployeeID.Value)
Returns population variance of all values

RunningValue
=RunningValue(Fields!EmployeeID.Value,sum,nothing)
Returns running aggregate of the specified
expression

Financial

DDB DDB (Double Declining Balance) method computes depreciation of an asset for a specified period.
Syntax: DDB (Cost, Salvage, life, period, factor)

FV FV (Future Value) of an investment based on periodic, constant payments and a constant interest rate.
Syntax: FV (rate, nper, pmt, pv, type)

IPmt IPmt (Interest Payment) for a given period for an investment based on periodic, constant payment and a constant interest rate
IPMT (rate, per, nper, pv, fv, type)

IRR IRR (Interest Rate of Return) for a series of cash flows represented by the numbers in values.
IRR(values,guess)

MIRR MIRR ( Modified internal rate of return ) for a series of periodic cash flows
MIRR(values,finance_rate,reinvest_rate)

NPer Returns the number of periods for an investment based on periodic, constant payments and a constant interest rate.
NPER (rate, pmt, pv, fv, type)

NPV Calculates the net present value of an investment by using a discount rate and a series of future payments (negative values) and income (positive values).
Syntax: NPV(rate,value1,value2, …)

Pmt Calculates the payment for a loan based on constant payments and a constant interest rate.
PMT(rate,nper,pv,fv,type)

PPmt Returns the payment on the principal for a given period for an investment based on periodic, constant payments and a constant interest rate.
PPMT(rate,per,nper,pv,fv,type)

PV Returns the present value of an investment. The present value is the total amount that a series of future payments is worth now. For example, when you borrow money, the loan amount is the present value to the lender.
PV(rate,nper,pmt,fv,type)

Rate Returns the interest rate per period of an annuity. RATE is calculated by iteration and can have zero or more solutions.
RATE(nper,pmt,pv,fv,type,guess)

SLN Returns the straight-line depreciation of an asset for one period.
SLN(cost,salvage,life)

SYD Returns the sum-of-years’ digits depreciation of an asset for a specified period.
SYD(cost,salvage,life,per)

Conversion

CBool Convert to boolean
=CBool(fields!EmployeeID.Value)
CByte Convert to byte
CChar Convert to char
CDate Convert to date
CDbl Convert to double
CDec Convert to decimal
CInt Convert to integer
CLng Convert to long
CObj Convert to object
CShort Convert to short
CSng Convert to single
CStr Convert to string
Fix =Fix(32.342143)
Returns integer portion of a number
Hex =Hex(Fields!EmployeeID.Value)
Returns a hexadecimal value of a number
Int =Int(43.44)
Returns integer portion of a number
Oct =Oct(Fields!EmployeeID.Value)
Returns a octal value of a number
Str =Str(Fields!EmployeeID.Value)
Returns string value of a number
Val =Val(“32.43″)
Returns numeric value in string format

Miscellaneous

Previous =Previous(Fields!EmployeeID.Value)
Returns the previous value



Thank You!
Atul Kumar

Monday 3 August 2015

Send tweets from AX via the Retail module


Today i am writing this post to demonstrate send Tweets from Ax 2012 R3 via the Retails module. Off course this is very interesting topic for Ax developers and to promote your business over digital media like Twitter , Facebook etc..





Thanks You!



How to get Label Id from a text in AX 2012

How to get Label Id from a text in Ax 2012

If you want retrieve the Label ID from a specific text description, here the code.
If are present more Label ID for a specific text, you will have the first.


   sysLabelEdit     sysLabelEdit = New sysLabelEdit();
   labelid          labelid;
   str              txt= "Customer account";
   str              CharsTxt;
    
   CharsTxt = SysLabel::searchStringBuildSpecialCharString(txt);    
   CharsTxt = SysLabel::seachStringBuildExactStr(CharsTxt);
    
   labelid = sysLabelEdit.findLabel("en-us", CharsTxt);
    
   info ( labelid );
















Thank You!

Change the TITLE of the AX Main Window

Change the TITLE of the AX Main Window

When you open Microsoft Dynamics AX, the main windows is a form.
So, if you want to change the Title, the code is very easy :


WinAPI::setWindowText( infolog.hWnd(), "Magic AX");

If you want to manage automatically,is enough move this code to the startupPost method of the Info class.

If you want trigger this code for every workspace of Ax, you have to move the code on the workspaceWindowCreated method of the Info class, like this :

WinAPI::setWindowText( _hWnd, "Magic AX");



Thank you!

Sunday 2 August 2015

"The internal time zone version number stored in the database is higher than the version supported by the kernel (8/7). Use a newer Microsoft Dynamics AX kernel."

I am writing this post to resolve the bellow error in Microsoft Dynamics Axapta 2012 R3

"Fatal SQL condition during login. Error message: "The internal time zone version number stored in the database is higher than the version supported by the kernel (8/7). Use a newer Microsoft Dynamics AX kernel."


I was a task to restore the database of LIVE server on test server i.e means create the replica of live on test environment.
Database and Model store has been restored successfully. Now i have to start the services of Microsoft Dynamics Ax. It gives the error -  
"Windows could not start the Microsoft Dynamics Ax Object Server on Local Computer, refer to service- specific error code 100."
Then i have to check the event viewer  to observe the problem exactly.

Error message:
Object Server 01:  Fatal SQL condition during
login. Error message: "The internal time zone version number stored in the
database is higher than the version supported by the kernel (8/7). Use a newer
Microsoft Dynamics AX kernel."


Solution - 

For the resolution you need to change the value for the column value  SYSTIMEZONESVERSION  in the table "SQLSystemVariables". if you look into the event viewer you can see that it find the value 8, but you need 7 (8/7).

Hence, 
The solution is to set the value to 7.

select SYSTIMEZONESVERSION from SQLSystemVariables

update SQLSystemVariables
set SYSTIMEZONESVERSION = 7



Thank You!

Tuesday 28 July 2015

Upload .csv file through job in ax 2012

Upload .csv file through job in ax 2012

static void Atul_test(Args _args)
{
    CommaIO                     csvFile;
    container                   readCon, ledgerDimension;
    counter                     icount,inserted;
    Dialog                      dialog;
    DialogField                 dfFileName, dlgJournalNum, JVNumber;
    FileName                    fileName;
    Struct                              struct;
    str 50  jid;
    ;
     inserted =0;
    #File
    dialog      = new Dialog("Pick the file");
   dfFileName  = dialog.addField(extendedTypeStr(FilenameOpen));
    dialog.filenameLookupFilter(["All files", #AllFiles]);      
    if(dialog.run())
    {
            fileName = dfFileName.value();
    }
   
    csvFile  = new CommaIO(fileName, 'r');
   
    if(csvFile)
    {  
        ttsBegin;
        while (csvFile.status() == IO_Status::OK)
        {
          readCon  = csvFile.read();
          if(readCon)
            {

            // write your code, which data you want to upload from csv file.  
               
               
              icount++;
              inserted++;
            }  
        }  
         ttsCommit;
    }
                info(strfmt("%1 records Updated out of %2",inserted,icount));
}


Thank you!

Wednesday 15 July 2015

Fetch Financial Dimension and dimension description through code in Ax 2012

I am writing this post to demonstrate to find Fetch Financial Dimension through code in Ax 2012.


// declare buffer

SalesOrderDataTmp                         _salesOrderDataTmp;
DimensionAttributeValueSet           dimAttrValueSet;    
DimensionAttributeValueSetItem   dimAttrValueSetItem;   
 DimensionAttributeValue               dimAttrValue;    
DimensionAttribute                         dimAttr;


// get financial dimension            dimAttrValueSet = DimensionAttributeValueSet::find(salesLine.DefaultDimension);

// Find all of the 'value set items' linked against the 'value set'            
financialDim="";            
while select DimensionAttributeValue from dimAttrValueSetItem                
where   dimAttrValueSetItem.DimensionAttributeValueSet   == dimAttrValueSet.RecId            
{                
dimAttrValue        = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
// Find the underlying attribute.                dimAttr             = DimensionAttribute::find(dimAttrValue.DimensionAttribute);
//info(dimAttr.Name + ' - ' + dimAttrValue.getValue());
if (dimAttr.Name == 'R1_LegalEntity')
{
// *******************************
// dimAttrValue.getName() fetches the description of the dimension
god_salesOrderDataTmp.Dimesnions1   = dimAttrValue.getName();
                        
// *******************************
// dimAttrValue.getValue() fetches the description of the dimension
god_salesOrderDataTmp.Dimesnions1   = dimAttrValue.getValue();
}                
if (dimAttr.Name == 'R2_Department')                    
god_salesOrderDataTmp.Dimension2   = dimAttrValue.getName(); // .getValue();                
if (dimAttr.Name == 'R3_Region')                    
god_salesOrderDataTmp.Dimension3   = dimAttrValue.getName();                
if (dimAttr.Name == 'R4_CostCenter')                    
god_salesOrderDataTmp.Dimension4   = dimAttrValue.getName();               
 if (dimAttr.Name == 'R5_ProductCatagories')                    
god_salesOrderDataTmp.Dimension5   = dimAttrValue.getName();                
if (dimAttr.Name == 'R6_SalesType')                    
god_salesOrderDataTmp.Dimension6   = dimAttrValue.getName();

financialDim += dimAttrValue.getName() +",";            

}
god_salesOrderDataTmp.insert();


Thursday 25 June 2015

I am writing this post to demonstrate to find exchange rate from code for SSRS report in Axapta 2012 R2 , R3.

I am writing this post to demonstrate find exchange rate for SSRS report  in Axapta 2012 R2 , R3.

"CurrencyExchangeHelper" class manages calculations between currencies. with the help of method "calculateCurrencyToCurrency" calculates the amount between the original currency and the resulting currency.

    Let's have a look..

    // find exchange rate
    CurrencyExchangeHelper                  curExchangeRate; ;
    AmountMst                                        calculateCurrency;
    curExchangeRate             = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), systemDateGet());
    calculateCurrency       = currencyExchangeHelper.calculateCurrencyToCurrency("USD" , "SAR" ,1 , true);
    info(strfmt("%1", calculateCurrency));

Now you can get exchange rate USD to SAR , "calculatecurrency" variable provide you the current SAR exchange rate.



Thank you so much!

    

Wednesday 17 June 2015

Call Multiple report on single click in X++, Code for apply Range on From


I am writing this post to demonstrate how to call multiple X++ report on single click in Microsoft Dynamics AX 2009/2012. 


Call Multiple report on single click in X++


void clicked()
{
    Args args = new args();
    ReportRun       reportRun;
    ;

    args.record(PurchTable);
    args.name(reportstr(Report1));
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    args.name(reportstr(Report2));
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    args.name(reportstr(Report13));
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    super();
}


I am writing this post to demonstrate provide rangle on Form in Microsoft Dynamics AX 2009/2012 and best practices to apply range on Form Datasource executeQuery.


public void executeQuery()
{
    QueryBuildDataSource    qbdRGDetail;
    QueryBuildRange         qbrECCNumber;
    QueryBuildRange         qbrNumberSequence;
    ;

    qbdRGDetail = TableName_ds.query().dataSourceTable(tablenum(TableName));
    qbdRGDetail.clearRanges() ;

    qbrECCNumber = SysQuery::findOrCreateRange(qbdRGDetail, fieldnum(TableName, ECCNumber));
    qbrECCNumber.value(TableName2.ECCNumber);
    qbrNumberSequence = SysQuery::findOrCreateRange(qbdRGDetail, fieldnum(TableName, NumberSequence));
    qbrNumberSequence.value(TableName2.NumberSequence);

    super() ;


}


Import General journal from excel in D365 F&O

 Hi Guys, Import General journal from excel in D365 F&O Code:  using System.IO; using OfficeOpenXml; using OfficeOpenXml.ExcelPackage; u...