Showing posts with label permission. Show all posts
Showing posts with label permission. Show all posts

Saturday, April 16, 2016

HOW TO SELECT MULTIPLE/ALL RECORDS IN AX :VIKAS MEHTA

How to select multiple/all records in AX

Recently I came across an issue regarding the selection of multiple records in AX ,


You can do that in many ways:


1) Press offcourse CTRL and then select the records with the mouse.


2) Press SHIFT and scroll the mouse and select the end record(Make sure you keep the mouse button pressed.)


3) Incase you want to select all the records you need to press
 Ctrl+Shift+Home/End : To mark all records between the currently selected record and the first/last    record

 You will get the following warning.

Do you want to continue  loading all the lines? 










Click YES

Thanks,
Vikas Mehta.

Wednesday, April 13, 2016

HOW TO ADD CURRENT PROFILE NAME TO THE WINDOW TITLE

How to add current profile name to the window title


Info class. Expand the method workspaceWindowCreated and add the following code. Next time you start axapta, your profile name will be part of the axapta window title.

void workspaceWindowCreated(int _hWnd)
{
// Put workspace window specific initialization here.

// -- START 070307 FourOne/HL (EnvironmentAddOns4)
session s=new Session();
;
WinAPI::setWindowText(_hWnd, strFmt("%1 - %2 - %3",
xInfo::configuration(),
s.userId(),
WinAPI::getWindowText(_hWnd) ));
}

STORING LAST FORM VALUES : HOW TO SHOW LAST SELECTED VALUES IN A FORM :DYNAMICS AX 2012 CODE

STORING LAST FORM VALUES

Dynamics AX has a very useful feature, which allows saving the latest user choices per user per form. This feature is implemented across a number of standard reports, periodic jobs, and other objects, which require user input.

In this recipe, we will see how to store the latest user filter selections. To make it as simple as possible, we will use existing filters on the General journal form, which can be opened from General ledger | Journals | General journal. This form contains two filters—Show and Show user-created only. Show allows displaying journals by their posting status and Show user-created only toggles between all journals and the currently logged user's journals.

1.Find the LedgerJournalTable form in AOT, and add the following code to the bottom of itsclass declaration:
AllOpenPosted showStatus;
NoYes showCurrentUser;
#define.CurrentVersion(1)
#localmacro.CurrentList
showStatus,
showCurrentUser
#endmacro
------------------------------------------------
2.Create these additional form methods:

public void initParmDefault()
{
;
showStatus = AllOpenPosted::Open;
showCurrentUser = true;
}
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
-----------------------------------------------------------
public boolean unpack(container packedClass)
{
int version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:[version,#CurrentList] = packedClass;
return true;
default:
return false;
}
return false;
}
------------------------------------------
public identifiername lastValueDesignName()
{
return element.args().menuItemName();
}
------------------------------------------
public identifiername lastValueElementName()
{
return this.name();
}
----------------------------------------
public UtilElementType lastValueType()
{
return UtilElementType::Form;
}
----------------------------------------
public userId lastValueUserId()
{
return curuserid();
}
----------------------------------------
public dataAreaId lastValueDataAreaId()
{
return curext();
}

EXECUTING SQL DIRECTLY FROM X++ RUN SQL QUERY FROM AX 2012 CODE HOW TO DYNAMICS AX

Executing SQL directly from X++
The X++ language supports a number of ways to execute native SQL against any SQL data source.

Example #1: Retrieve data:
Since this example uses a Connection class, data is retrieved from the database where Axapta is currently connected.
void Sample_1(void)
{
Connection Con = new Connection();
Statement Stmt = Con.createStatement();
ResultSet R =Stmt.executeQuery(‘SELECT * from table’);
while ( R.next() )
{
print R.getString(1);
}
}
Example #2: Manipulating data (deletion):
void Sample_2(void)
{
str sql;
Connection conn;
SqlStatementExecutePermission permission;
;
sql = ‘delete from salstable’;
permission = new SqlStatementExecutePermission(sql);
conn = new Connection();
permission = new SqlStatementExecutePermission(sql);
permission.assert();
conn.createStatement().executeUpdate(sql);
// the permissions needs to be reverted back to original condition.
CodeAccessPermission::revertAssert();
}

database staging import

public class VikasStagingPricingMasterImport
{

    LoginProperty loginProp;
    ODBCConnection conn;
    Statement statement1;
     Set existingItemIds;
}

private void ConnectToStagingDB()
{
     // Set Server Database
    loginProp = new LoginProperty();
     loginProp.setDSN(abc);
   // loginProp.setServer(bcd);
    loginProp.setDatabase(‘xyz_Db'); 

    // Create Connection and SQL Statement
    conn = new ODBCConnection(loginProp);
    statement1 = conn.createStatement();
}

public static void main(Args _agrs)
{
   System.Exception ex;
   VikasStagingPricingMasterImport importObj=new VikasStagingPricingMasterImport();
 if(Box::okCancel("To you want to Import Price Master ?", DialogButton::Cancel," Price Master Import") == DialogButton::Ok)
        {
    try
    {
     importObj.ConnectToStagingDB();
     importObj.ImportPricingMasters();
    }
    catch( Exception::CLRError)
    {
         ex = ClrInterop::getLastException();

        if (ex != null)
         {
            ex = ex.get_InnerException();
            if (ex != null)
            {
                error("Unexpected Error Occured.   " + ex.ToString() +   "  Please contact Administrator." );
            }
        }
   }

    info(" Import of Pricing master has finished Successfully.");
    }

}



private str formatItemIdsForQuery(Set conItemIds)
{
    SetEnumerator sm;
    str itemIds;
    sm=conItemIds.getEnumerator();
    itemIds="";
    while (sm.moveNext())
        {
            itemIds= itemIds + ",'" +  sm.current() + "'" ;
        }

    if(strLen(itemIds) >0)
    {
        itemIds=subStr(itemIds,2, strLen(itemIds));
    }

    return itemIds;
}

//Sales Price master upload in the system
private void ImportPricingMasters()
{

       str queryPricingMaster,itemId,existingItemIdsList,tempValue;
       ResultSet resultSet;
       InventTable inventTable;
       itemId tempItemId;
      AifEntityKeyList                        keys;
       VIK_RRP_Staging                       RRPStaging;
       PricePriceDiscJournalService            PriceDiscSvc;
       PricePriceDiscJournal                   PriceDiscJour;
        PricePriceDiscJournal_PriceDiscAdmTrans PriceDiscJourAdmTrans;
        PricePriceDiscJournal_InventDim         PriceDiscJourDim;
         #AviFiles
    SysOperationProgress progress1 = new SysOperationProgress();


        PriceDiscSvc = PricePriceDiscJournalService::construct();
        PriceDiscJour = new PricePriceDiscJournal();
        PriceDiscJourAdmTrans = PriceDiscJour.createPriceDiscAdmTrans().avikNew();

        PriceDiscJourDim = PriceDiscJourAdmTrans.createInventDim().avikNew();
        PriceDiscJourDim.parminventDimId("Allblank");

        progress1.setCaption("Updation of pricing master is in progress…");
    progress1.setAnimation(#AviUpdate);

    existingItemIds = new Set(Types::String);

    queryPricingMaster = "Select * FROM [Staging_Db].[dbo].[VIK_STAGING] where DATAUPLOADED = 0 ";
    resultSet = statement1.executeQuery(queryPricingMaster);
    ttsBegin;
    while (resultSet.next())
    {
        itemId="";
        TempValue=resultSet.getString(1);
        tempItemId=resultSet.getString(2);

         progress1.setText(strfmt("Item ID  %1", tempItemId));

        // Set PriceDiscJourAdmTrans
          while select forUpdate * from inventTable
            where inventTable.ItemId == tempItemId
        {


            PriceDiscJourDim.parminventDimId("Allblank");

            PriceDiscJourAdmTrans.parmAccountCode(TableGroupAll::GroupId);
            PriceDiscJourAdmTrans.parmAccountRelation(TempValue);
            PriceDiscJourAdmTrans.parmInventDim().avik(PriceDiscJourDim);
            PriceDiscJourAdmTrans.parmItemRelation(inventTable.ItemId);
            PriceDiscJourAdmTrans.parmItemCode(TableGroupAll::Table);
            PriceDiscJourAdmTrans.parmAmount(resultSet.getReal(3));
            PriceDiscJourAdmTrans.parmFromDate(resultSet.getDate(4));
            PriceDiscJourAdmTrans.parmToDate(resultSet.getDate(7));
            PriceDiscJourAdmTrans.parmrelation(PriceType::PriceSales);
            PriceDiscJourAdmTrans.parmCurrency("INR");
            PriceDiscJourAdmTrans.parmQuantityAmountFrom(0);

           // Post PriceDiscJour
            keys = PriceDiscSvc.create(PriceDiscJour);
            itemId=inventTable.ItemId;

        }
        if(strLen(itemID)>0)
        {
            existingItemIds.avik(itemID);
        }
    }

    existingItemIdsList=this.formatItemIdsForQuery(existingItemIds);
    if(strLen(existingItemIdsList)>0)
    {

    queryPricingMaster = strFmt("UPDATE [dbo].[test] SET [DATAUPLOADED] = 1, LASTUPDATED = '%1' WHERE DATAUPLOADED = 0 AND ITEMNUMBER in (%2)",today(), existingItemIdsList);
    statement1.executeUpdate(queryPricingMaster);
    }
    ttsCommit;

}

PASS VALUES FROM FORM TO REPORT IN AX2009

Pass values from form to Report in Ax2009

Pass Values through Menu Buttons to report in Dynamics AX

1.    Calling menuItem. Task

Form-> MenuButton-> Clicked Method

void clicked()
{
            Args args = new Args();
            MenuFunction menuFunction;
             ;
             args.parm(SalesTable.SalesId);
             menuFunction = new MenuFunction(menuitemoutputstr(Report),
                                                  menuitemType::Output);                                            
                          // Report is menuItem
                        menuFunction.run (args);
                         super ();
                }

Go to Report Init Method

In Report-> init()
Declare the Variable in class Declarations.

public void init()
{

           ItemId  =  element.args().parm();
              ------------------------
             ------------------------------        
           super();
}

Other Way of getting values from form to report…
2.calling report

form->Button
void clicked()
{

Args args = new args();
ReportRun reportRun;
;

args.parm(Table. Field);
args.name(reportstr(Report Name));
reportRun = classFactory.reportRunClass(args);
reportRun.init();
reportrun.run();
========
=======

super ();
}
Report  ‘Override Method –> init’


public void init()
{
;
ItemId  =  element.args().parm();
 ------------------------
 ------------------------------        
super();
}
 

Tuesday, April 12, 2016

HOW TO GIVE RIGHTS IN SHAREPOINT PORTAL IN AX 2012

Access to SharePoint portal in ax 2012

1. Open Internet Explorer
2. Click Site Actions > Site Permissions
3. Click Grant Permissions
4. In the Users\Groups box, enter ABC
5. Click Check Names
6. Check Full Control
7. Click OK
Related Posts Plugin for WordPress, Blogger...