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 :)



No comments:

Post a Comment

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 ...