31 August 2010

Enable Grid Filter for a Form

If you want a form to open with enabled grid filter you can use the following code in the run Method of the form
public void run()
{
    #define.strgG(2855)
    ;
    super();

    //enable Grid Filter
    this.task(#strgG);
}
Therefor the grid should be the selected control. If this isn't the case use the firstField Method of the form:
public void firstField(int _flags=1)
{
    ;
    Grid.setFocus();
}

29 July 2010

Loop through multiSelect grid selection

First of all the multiSelect property of the grid should be set to YES and if you need a button to process multiple grid selection you also should activcate the MultiSelect property of this button. Otherwise it won't be enabled.
To loop through the selected rows of the grid just use the following for statement:
void clicked()
{
    SalesLine salesLine;
    ;
    super();

    for (salesLine = SalesLine_ds.getFirst(true) ? 
                     SalesLine_ds.getFirst(true) : SalesLine_ds.cursor();
         salesLine;
         salesLine = SalesLine_ds.getNext())
    {
        salesLine.doSomethingVerySpecial(:-);
    }
    SalesLine_ds.research(true);
}

26 July 2010

SysImageRessources - Finding image ressource id

If you are looking for an Icon to display on a menuItem in an actionPane or whereever you'll need to find out the ressource id of an sysImage. To find out which images are available as ressources in Dynamics AX you should have a look at the Form SYSImageRessources Form (I always try to find it under tutorials). It shows the id, a preview of the image and the type of the image.

25 May 2010

Finding double entries like RecIds via SQL

If you need to find double entries in an SQL DB u can use the following statement:
SELECT COUNT(RECID), RECID
  FROM [ADDRESSSTATE]
GROUP BY RECID HAVING count(RECID) > 1
Another example finding adresses in different countries:
SELECT count([COUNTRYREGIONID]), COUNTRYREGIONID      
  FROM [dbo].[ADDRESS]
  GROUP By COUNTRYREGIONID having COUNT([COUNTRYREGIONID]) > 1
GO
Or to find dublicates for a multi column key
SELECT [DIMENSIONATTRIBUTE]
      ,[ENTITYINSTANCE]
      ,[ISDELETED]
      ,count(DIMENSIONATTRIBUTE)
FROM [dbo].[DIMENSIONATTRIBUTEVALUE]
GROUP BY DIMENSIONATTRIBUTE, ENTITYINSTANCE, ISDELETED HAVING count(DIMENSIONATTRIBUTE) > 1  

18 May 2010

create regfile with regasm

When you need to know what happens to your registry when you reg a Dll just execute the following regasm command and have a look in the created regfile.
This Command only creates the regfile. It will not register the dll.
RegAsm.exe mySuper.dll /regfile:mySuper.reg

"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe" mySuper.dll /regfile:mySuper.reg