Thursday, April 30, 2015

Code for how to disable a fields of a form in ax 2012 based on enum value

FormèDatasourceèMethodsèselectionChanged()
public void selectionChanged()
{
   EmployeTable_s ETS; //declaring table
    ;
    super();
    ETS=EmployeTable_s;// declaring table= datasource of a form
// if (DatasourceName.EnumField == EnumName::EnumElement)  // Your Required Condition
        if(ETS.AccountStatus_s== AccountStatus_s::Inactive)
    {

        EmployeTable_s_EmpID.allowEdit(false); //Grid field names like (EmployeTable_s_EmpID),(EmployeTable_s_EmpName)
        EmployeTable_s_EmpName.allowEdit(false);
        EmployeTable_s_EmpID.enabled(false);
        EmployeTable_s_EmpName.enabled(false);
        EmployeTable_s_AccountStatus_s.allowEdit(false);
        EmployeTable_s_AccountStatus_s.enabled(false);
      
    }
    else
    {
        EmployeTable_s_EmpID.allowEdit(true);
        EmployeTable_s_EmpName.allowEdit(true);
        EmployeTable_s_EmpID.enabled(true);
        EmployeTable_s_EmpName.enabled(true);
        EmployeTable_s_AccountStatus_s.allowEdit(true);
        EmployeTable_s_AccountStatus_s.enabled(true);
      
    }




}


OP:

Sunday, April 26, 2015

Enum Fuctions in ax 2012

                 Enum Fuctions in ax 2012
1.enum2Str Function:
Converts the specified enumerated text to a character representation.
Syntax:
str enum2Str(enum enum)
Example:
The following example returns the string " EUTrade." It is the label for the ListCode enumeration type.
    ListCode l;
    ;
    l =  ListCode::EUTrade;
    info(enum2Str(l));
we can also use(enum2Value) this below code to retrieve value of enum elements.
ListCode ls;
    ;
    ls=  ListCode::EUTrade;
    info(enum2Value(ls));
Op: EUTrade

2.enumCnt Function:

Retrieves the number of elements in the specified enumeration type.

Syntax: int enumCnt(enum enumtype)

Example:
print enumCnt(NoYesUnchanged);// Op: 3
or
print enumCnt(ListCode);// Op:9
pause;

KEEP DAXING !!!

Friday, April 24, 2015

Date functions in ax 2012

Date Functions in ax 2012


1.dayName Function:
Retrieves the name of the day of the week specified by a number.
Syntax:
str dayName(int number)

Example:
Note:
The valid values for the number parameter are 1 through 7. Monday is represented by 1, Tuesday by 2, and Sunday by 7.
    str s;
    s= dayName(4);
    info(strFmt("fourth day of a week is %1",s));

Op: fourth day of a week is Thursday

2.dayOfMth Function:

Calculates the number of the day in the month for the specified date.

Syntax:

int dayOfMth(date date)
 
Example:
Note:
An integer between 1 and 31 that indicates the day of the month for the specified date.
Date format:
 
    int i;
    ;
    i = dayOfMth(11\6\2014);  
    info(strFmt("today's day of the month is %1",i));
Op: today's day of the month is 11

or

    info("today's day of the month is");
    info(int2str(i));
Op: today's day of the month is
     11


or
    int i;
    ;
    i=dayOfMth(today());
    print "today’s day of month is "+int2str(i);
    pause;
op: returns today’s day of month is 24


3.dayOfWk Function:

Calculates the number of day in the week for the specified date.

Syntax: int dayOfWk(date date)
 

Example:

    int i;
    ;
    i=dayofwk(today());
    print "todays day of Week is "+int2str(i);
    pause;
op: todays day of Week is 5


4.dayOfyr Function:
Calculates the number of days between January 1 and the specified date.
Syntax: int dayOfYr(date _date)

Example:

int i;
    ;
    i=dayofyr(today());
    print "todays day of year is "+int2str(i);
    pause;

op: todays day of year is 114.

5.mthOfYr Function:

Retrieves the number of the month in the year for the specified date

Syntax:

int mthOfYr(date date)

 

Example:

    int i;
    ;
    i=mthofyr(today());
    print "Current month of year is "+int2str(i);
    pause;

op: Current month of year is 4.

 

6.wkOfYr Function:

Calculates the week of the year in which a date falls, according to the ISO 8601 specification.

Syntax : int wkOfYr(date _date)

 

Example:

    int i;
    ;
    i= wkOfYr(today());
    print "Current week of year is "+int2str(i);
    pause;

op: Current week of year is 17.

7.year Function:

Retrieves the year from a date value.

Syntax: int year(date _date)

 

Example:

    int i;
    ;
    i= year(today());
    print "Current year is "+int2str(i);
    pause;

 

op: Current year is 2015

8.endmth Function:

retrieves last date of month of the specified date;

Syntax: date endMth(date date)

Example:

   int i;
   ;   
   print endmth(today());
   pause;

 op:30/04/2015

9. maxDate Function:

Retrieves the maximum value allowed for a variable of type date.

Syntax:date maxDate()

Example:

    date maximumdate;
    ;
    maximumdate=maxDate();
    print maximumdate;
    pause;
   

       op:12/31/2154

 

10.mkDate Function:

Creates a date based on three integers, which indicate the day, month, and year, respectively.

Syntax:

date mkDate(int day, int month, int year)

 Example:

Date _CustomDate;
Date _LastDateOfMonth;
Int month_number;
Int years_numbers;
Int day_number;
;
Day_number=1;
Month_number=4 ; // say April
years_numbers=2014;
_CustomDate =mkdate(Day_number, Month_number, years_numbers);

info(strFmt("%1",_CustomDate));
op:
4/1/2014

                        Or
    date d;
      ;

    // Returns the date 01\01\2005.
    d = mkDate(04, 1, 2015); 
    print d;
    pause;
    op:4/1/2015;

11.mthName Function:

Retrieves the name of the specified month

Syntax: str monthName(int number)
 
Example:
     str s;
    s = mthname(12);
    info(strFmt("%1",s));
    Op:December
 

12.nextMth Function:

Retrieves the date in the following month that corresponds most closely to the specified date.

Syntax:

date nextMth(date date)

Example:

 date s;
      s = nextMth(5\6\2014); or s= nextMth(today());
      info(strFmt("%1",s));

 op: 7/5/2014

13.nextQtr Function:

Retrieves the date in the following quarter that corresponds most closely to the specified date.

Syntax: date nextQtr(date date)

Example:

    date d;
    ;
    d = nextQtr(today()); or  d= nextQtr(5\6\2014);
    info(strFmt("%1",d));//op: 9/5/2014

 

14.nextYr Function:

Retrieves the date in the following year that corresponds most closely to the specified date.

Syntax:

date nextYr(date date)

date d;
    ;
    d = nextYr(today());
    info(strFmt("%1",d));

or

date d;
    ;
     d= nextYr(5\6\2014);
    info(strFmt("%1",d));//op: 6/5/2015

 

15.prevMth Function:

Retrieves the date in the previous month that corresponds most closely to the specified date.

Syntax:

date prevMth(date date)
 
Example:
date d;
    ;
    d = prevMth(5\6\2014);
    info(strFmt("%1",d));
op:5/5/2014
   
 

16.prevYr Function:

Retrieves the date in the previous year that corresponds most closely to the specified date.

Syntax:

date prevYr(date date)

 

Example:

date d;
    ;
    d = prevyr(5\6\2014);
    info(strFmt("%1",d));
op: 6/5/2013

17.prevQtr Function :

Retrieves the date in the previous quarter that corresponds most closely to the specified date.

Syntax:

date prevQtr(date date)

 

Example:

date d;
    ;
    d = prevqtr(5\6\2014);
    info(strFmt("%1",d));

op: 3/5/2014;

18.timeNow Function:

Retrieves the current system time.

Syntax: int timeNow()
Note: The number of seconds that have elapsed since midnight.
 

Example:

    int d;
    ;
    d = timeNow();
    info(strFmt("%1",d));// op: 61781

19.today Function:
Retrieves the current date on the system.
 
Syntax: date today()
 

Example:

    date d;
    ;
    d = today();
    info(strFmt("%1",d));

Op: 4/24/2015



<<=Keep Daxing !!!=>>

<<=HaPpYyY  Daxing :)=>>


 

 



 

 





Thursday, April 23, 2015

Session Functions in Ax 2012

Session Functions

1.curext Function:
Retrieves the extension that is used for the current company.
Syntax: str curext() or str curExt()
Example:
Static void ex(Args _args)
{
    str s;
    ;
    // Sets s to the extension of the current company.
    s = curext(); 
   info(strFmt("Current extension is %1 ",s));
 }
Op: Current Extension company is usmf.
2.curUserId:
Retrieves the nonnumeric ID that represents the current user.
Syntax:
str curUserId()
Example:
Static void ex(Args _args)
{
    str s;
    ;
    s = curUserId();
   info(strFmt("Current User id is %1 ",s));
 }
Op: Current Extension userid  is shivkum.

3.getCurrentPartition(Retrieves the short name of the current partition.)
Syntax: str getCurrentPartition()

4.getCurrentPartitionRecId(Retrieves the RecId field of the current partition.)
Syntax: int64 getCurrentPartitionRecId()
example:
int64         iPartition;
str       sPartition;
SelectableDataArea oSelectableDataArea;  // System ExDT.   

iPartition = getCurrentPartitionRecId();
sPartition = getcurrentpartition();
   
oSelectableDataArea = Global::getCompany( tableNum(FacultyTable_s)):
   
   
    Global::info( strFmt(
        "getCurrentPartitionRecId =%1 , getCurrentPartition =%2 , getCompany =%3",
        iPartition, sPartition, oSelectableDataArea) );


Op: getCurrentPartitionRecId =5637144576 , getCurrentPartition =initial , getCompany =ac

5.SessionId:
Retrieves the session number of the current session.
Syntax:int sessionId()
Example:
   int session;
    ;
    session = sessionId();
    print "session id is "+int2str(session);
    pause;

Op: Session id is 5;

6.funcName Function:

Retrieves a string that contains the current function context.
Syntax: str funcName()

 Example:

static void Shiv_StringsFunction(Args _args)

{

str s;
    ;
s = funcName();
{
info(strFmt("Current extension is %1 ",s));
}
}
op: Current Function name is Shiv_StringsFunction

7.prmIsDefault Function

Determines whether the specified parameter for the current method has the default value.

Syntax: int prmIsDefault(anytype argument)

 example:

void fn(boolean b = true, int j = 42)
    {
        ;
        if (prmIsDefault(b) == 1)
        {
            print "First parameter is using the default value.";
        }

        else
        {
            print "First parameter is not using the default value.";
        }
    }
    ;
   
    fn();
    fn(false);
    pause;

8.runAs Function:

Syntax:

container runAs(

    str userId,
    int classId,
    str staticMethodName
    [,
    container params,
    str company,
    str language,
    str partition
    ])
Enables the caller to run an X++ method in the security context of another user. This function is most often used with batch processing.
Note: this function does not support at client

 

 Keep Daxing !!!

HaPpYyY  Daxing :)



Introduction & String Functions in AX 2012

Hi Daxer's !!!
I'm very glad to explore my knowledge on Microsoft Dynamics Ax .

-- "Gaining knowledge is the first step to wisdom,

          Sharing knowledge is first step to Humanity !!!


 String Functions in AX 2012   

1.strAlpha Function:

Copies only the alphanumeric characters from a string.
Syntax:
str strAlpha(str _text)
Example:
info(strAlpha("Shiva89^&"));
Op:shiva89

2.strCmp Function :

Compares two text strings.

Note: 0 if the two strings are identical, 1 if the first string sorts earlier, or -1 if the second string sorts earlier.

Syntax:
int strCmp(str text1, str text2)

The comparison performed by this method is case-sensitive.

Example:

print strCmp("shiva","shiva");
        pause;

Op:  returns 0 if two strings are identical

print strCmp("shiva","SHI");
        pause;

Op:  returns 1 if first string is executed first;

print strCmp("sss","ggg");
        pause;

Op: returns 1 if the second string executed first;

print strCmp("hhh","ooo");

        pause;
Op: returns -1 if the second string executed first;

3.strColSeq Function:

Converts all uppercase characters to lowercase characters and also converts all special  design characters like (ÁÎ to ai) to lowercase characters

Syntax:

str strColSeq(str text)

Example:

info(strColSeq("AbçDËãBCdé"));

Op:abcdeabcde

 4.strDel Function:

Creates a copy of a string with the specified substring removed.

Syntax:

str strDel(

    str _text,
    int _position,
    int _number)
 
Example:

using strDel function Note: removes 2 letters from 4th letter onwards

info(strDel("ShivaKumar",4,2));
 
Op:ShiKumar
 
info(strDel("ShivaKumar",4,-3));

Op: SaKumar

Parameters

Parameter
Description
_text
The string to copy from
_position
The position at which to begin ignoring characters during the copy.
_number
The number of characters to ignore.
A minus sign in front of the _number parameter indicates that the (_number-1) characters before the character at the_position parameter are to be removed along with the character at the _position.

 

5.strFind Function:

Searches a string for the first occurrence of one of the specified characters.

Syntax:

int strFind(
    str _text, 
    str _characters, 
    int _position, 
    int _number)
Parameter
Description
_text
The string to search.
_characters
The characters for which to search.
_position
The position in the string where the search begins.
_number
A signed number that indicates the direction of the search and how many positions to search in the string.

 Example:

print strFind("shivaKumar","v",1,10);
    pause;

OP: returns 4

print strFind("shivaKumar","i",6,-4);
    pause;

OP: returns 3

Note: returns 4 and 3 according to the position of given value;

6.strFmt Function:

Formats the specified string and substitutes any occurrences of % n with the nth argument.

Syntax:
str strFmt(str _string, ...)

Example:

static void Shiv_StringsFunction(Args _args)

    {
    str Ax= 'Axapta';
    str W ='World';
    ;
  
     {
       info(strFmt(" Welcome to %1,%2",Ax,w));
   
       }
}

Op: Welcome to Axapta,World

7.strIns Function:

Builds a string by inserting one string into another.

Syntax: str strIns(str _text1, str _text2, int _position)

 Example:

static void Shiv_StringsFunction(Args _args)

{

info(strIns("shKumar","iva",3));// Note:Inserting string  from 3rd letter onwards


}
Op:shivakumar

8.strKeep Function:

Builds a string from only the characters in the first input string that are specified to be kept by the second string.

Or

Shows only specifield value of string

Syntax: str strKeep(str _text1, str _text2)

Example:

info(strKeep("shivaKumar","vaK"));

Op: VaKa

9.strLen Function

Calculates the length of the specified string.

Syntax: int strLen(str text)
Example:
print strLen("shiva");
    pause;
Op:5

10.strLine Function:

Retrieves a single line from a string that spans multiple lines.

Syntax:

str strLine(str string, int count)

Example:

str Ax="Hello\nDaxers\r\n@India\n@dhanush";

    {
        info(strLine(Ax,0));
        info(strLine(Ax,1));
        info(strLine(Ax,2));
       
    }
Op:
Hello

Daxers

@ India

11.strLTrim Function:

Removes leading blanks from a text string. Or removes  left side space of the string

Syntax:

str strLTrim(str text)

Example:

info(strLTrim("   Shiva   "));// op:Shiva

12.strRTrim Function :

Removes the trailing space characters from the end of a string. Or removes right side space of the string value
Syntax: str strRTrim(str _text)
Example:
info(strRTrim("   Shiva   "));// op:   Shiva

13.strLwr Function:

Converts all letters in the specified string to lowercase.

Syntax:

str strLwr(str _text)

Example: info(strLwr("SHiVa")); Op: shiva

14.strNFind Function:

Searches a portion of a text string for the first occurrence of a character that is not included in the specified list of characters.

Syntax:

int strNFind(
    str _text,
    str _characters,
    int _position,
    int _number)
Example:
print strNFind("shiva","shva",1,5); //op: returns 3(position of i)
    pause;
print strNFind("shiva","shIva",1,5); //op: returns 0(position of i)
    pause;

15.strPoke Function:

Overwrites part of a string with another string.

Syntax:
str strPoke(
    str _text1,
    str _text2,
    int _position)

 Example:

info(strPoke("shiva","kumar",4)); //op:shivkumar

16.strPrompt Function:

Appends to a string the specified number of period characters followed by a colon and space character.

Syntax:

str strPrompt(str _string, _int len)
Example:
print strPrompt("Shi",-1); //Returns "Shi ".
print strPrompt("Shi",3); //Returns "Shi ".
print strPrompt("Shi",4); //Returns "Shi: ".
print strPrompt("Shi",5); //Returns "Shi.: ".
print strPrompt("Shi",6); //Returns "Shi..: ".
    pause;
 

 

17.strRem Function:

Removes the characters specified in one string from another string.

Or

Removes the specified value of a string

Syntax: 
str strRem(str text1, str text2)

 Example:

io(strRem(nf"shiva","va")); //op:shi

18.strRep Function:

Repeats a string of characters.
Syntax:
str strRep(str _text, str _number)
 
Example:
info(strRep("shiva",5)); //Op:shivashivashivashivashiva
   

19.strScan Function:

Searches a text string for an occurrence of another string.

Syntax:

int strScan(
    str _text1,
    str _text2,
    int _position,
    int _number)
Example:
print strScan("shivaKumar","h",9,-10);//op:2
    pause;
 
print strScan("shivaKumar","iva",1,10);//op:3
    pause;

20.strUpr Function:

Converts all the letters in a string to uppercase.Syntax:
str strUpr(str _text)

 Example:

info(strUpr("SHiva"));// op:SHIVA

21.subStr Function:

Retrieves part of a string. Or retrieves we required value a part from the string
Syntax: str subStr(str _text, int _position, int _number)
Example:
info(subStr("ShivaKumar",3,6));//op:vakum
Note:Retrives String value from 3rd value  onwards up to 6th letter
info(subStr("ShivaKumar",6,-4));
Note: Retrives String value from 6th value  towards  to 4th letter

22.match Function:

Searches for a string or expression within another string.
Syntax:
int match(str pattern, str text)

Example: print match("<shi","shivakumar");//op: returns 1

pause;

print match("^shi","shivakumar");");//op: returns 1
pause;

 

 Keep Daxing !!!

HaPpYyY  Daxing :)

 


 

 

 

 

 


 

 


 
 

 


 

 

 

 

 







Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...