Archive for the ‘Uncategorized’ Category

Thanks for the tip, but I figured out it was just as easy to create a code
library (DLL) in C# and use it in Ax. It works fine for me at least.

Here is the C# code I used:
————————————
using System;
using System.Collections.Generic;
using System.Text;
using System.DirectoryServices;

namespace Microsoft.Dynamics.CreateADUser
{
    public class NewUser
    {
        string defaultNC;
        string alias;
        string fullName;
        string password;
        string ou;

        public void setDomain(string _defaultNC)
        {
            defaultNC = "DC=" + _defaultNC;
        }
        public void setAlias(string _alias)
        {
            alias = _alias;
        }
        public void setFullName(string _fullName)
        {
            fullName = _fullName;
        }
        public void setPassword(string _password)
        {
            password = _password;
        }
        public void setOu(string _ou)
        {
            ou = _ou;
        }

        public string execute()
        {
            DirectoryEntry container, user;
            string ret;

            try
            {
                //This creates the new user in the "users" container.
                //Set the sAMAccountName and the password
                container = new DirectoryEntry("LDAP://OU=" + ou + ", " +
defaultNC + ",DC=NO");
                user = container.Children.Add("cn=" + fullName, "user");
                user.Properties["sAMAccountName"].Add(alias);
                user.CommitChanges();
                user.Invoke("SetPassword", new object[] { password });

                //This enables the new user.
                user.Properties["userAccountControl"].Value = 0x200;
//ADS_UF_NORMAL_ACCOUNT
                user.CommitChanges();
                ret = "OK";
            }
            catch (Exception e)
            {
                ret = e.ToString();
            }
            return ret;
        }
    }
}

————————————

Just compile and put the dll-file in the client\bin folder of Ax and create
a reference from the aot and use the class like this in Ax:

————————————
static void Job1(Args _args)
{
    Microsoft.Dynamics.CreateADUser.NewUser user;
    ;
    user = new Microsoft.Dynamics.CreateADUser.NewUser();
    user.setDomain(/*yourdomain*/);
    user.setAlias(/*alias of the user you want to create*/);
    user.setFullName(/*Full name of the user*/);
    user.setPassword(/*Password*/);
    user.execute();
}
————————————

Regards,
Erlend

"Max Belugin [MVP]" wrote:

> I think, you can find and example in C# and port it to X++
>
> http://www.google.com/search?q=create+user+active+directory+C%23
>
> —
> my blog: http://axcoder.blogspot.com
> freeware sidebar for ax: http://belugin.info/sidax
>
>
> "Erlend Dalen" wrote:
>
> > Is it possible to create a new user in AD from Ax 4.0?
> > I have been looking into the System.DirectoryServices, but I haven’t been
> > able to figure out to make it work yet….can anyone help?
> >
> > Regards,
> > Erlend

How to setup Axapta batch server running as user defined windows service
 
 

Setting the AutoQuery property on a form data source to Yes causes the system to automatically generate the query that retrieves data to display in the form.

Modify the system-generated query to display a different set of data as the result of user input in the form.

  1. Declare a variable of the type QueryBuildRange.
  2. Initialize the QueryBuildRange variable.
  3. Modify the form data source executeQuery method.

Declare a Variable of the Type QueryBuildRange

Declare a variable of the type QueryBuildRange in the class declaration method on your form. Following is an example.

class FormRun extends ObjectRun
{
    QueryBuildRange   criteriaOpen;
    ...
}

QueryBuildRange is a system class used to specify the search scope of a query.

Initialize the QueryBuildRange Variable

Initialize the QueryBuildRange variable in the init method on the form data source. To override the init method, right-click the Methods node within the data source node, and then click Override Method > init.

The initialization must be after the super() call that generates the query. Following is an example.

Copy Code

void init()
{
    super();
    criteriaOpen = this.Query().DataSourceNo(1).addRange(
        fieldNum(CustTrans,Open));
    ...
}

Placing the initialization after the super() call in init is equivalent to placing it before the super() call in the run method.

The code sets the criteriaOpen variable to point to the Open field in the CustTrans table.

Following is an explanation of the code:

  • this – a reference to the current form data source.
  • Query() – the member method on the form data source used to retrieve a reference to the form’s query.

    An instance of the Query system class is always available on a form data source. The class is automatically instantiated when the form is opened.

  • DataSourceNo(1) – the method on the Query class used to identify the data source that takes an integer as parameter to identify the data source. The first data source is 1.

    This call returns a QueryBuildDataSource MorphX object.

  • addRange – the method on the QueryBuildDataSource class used to add a search range to the active criteria. addRange takes a field ID as parameter, and then returns a QueryBuildRange object.
  • fieldNum(CustTrans,Open) – a built-in function that returns the field ID (in this case, the ID of the Open field in the CustTrans table).
Note

The previously described code pattern enables you to reference the active query to add a range to it. The only values that vary are the parameters to the DataSourceNo method and to the fieldnum function.

Modify the executeQuery Method

The executeQuery method on the form data source is activated when the form is opened to display data. When overriding the method, you must add your modifications prior to the super() call.

In the following example, the switch statement performs a test on the IncludeAll variable. The QueryBuildRange variable (criteriaOpen) is set to 1 or 0..1, depending on the value of the member variable Value. The query can now be executed.

Copy Code

void executeQuery()
{
    switch (IncludeAll.Value())
    {
        case (1) :
            criteriaOpen.Value('1'); 
            break;
        case (0) :
            criteriaOpen.Value('0..1');
            break;
    }
    super();
}

FROM developer help of AX

copy from developer help
 
==================
 

Query range value expressions can be used in any query where you need to express a range that is more complex than is possible with the usual dot-dot notation (such as 5012 .. 5500).

For example, to create a query that selects the records from MyTable where field A equals x or field B equals y, do the following.

  1. Add a range on field A.
  2. Set the value of that range to the expression (if x = 10 or y = 20), as a string: ((A == 10) || (B == 20))

The rules for creating query range value expressions are:

  • Enclose the whole expression in parentheses.
  • Enclose all subexpressions in parentheses.
  • Use the relational and logical operators available in X++.
  • Only use field names from the range’s data source.
  • Use the dataSource.field notation for fields from other data sources in the query.

Values must be constants in the expression, so any function or outside variable must be calculated before the expression are evaluated by the query. This is typically done by using strFmt.

The example above will then look like the following code example.

strFmt('((A == %1) || (B == %2))',x,y)

To get complete compile-time stability you should use intrinsic functions to get the correct field names, as shown in the following code example.

strFmt('((%1 == %2) || (%3 == %4))',

    fieldStr(MyTable,A), x,

    fieldStr(MyTable,B), y)

Note

Query range value expressions are evaluated only at run time, so there is no compile-time checking. If the expression cannot be understood, a modal box will appear at run time that states "Unable to parse the value".

Example using "inter table" relations

Query  q = new Query();

QueryBuildDataSource qbr1, qbr2, qbr3;

;

 

qbr1 = q.addDataSource(tablenum(ProjCategory));

qbr1.orderMode(OrderMode::GroupBy);

qbr1.addSortField(fieldNum(ProjCategory,CategoryId));

...

qbr2 = qbr1.addDataSource(tableNum(ProjValEmplCategorySetUp),

                          'ProjValEmplCategorySetUp1');

qbr2.addRange(fieldNum(ProjValEmplCategorySetUp,CategoryId)).value(

    strFmt('(%1) || (%2)',fieldStr(ProjValEmplCategorySetUp,CategoryId),

    fieldStr(ProjValEmplCategorySetUp,groupId)));

qbr3 = qbr2.addDataSource(tableNum(ProjValEmplCategorySetUp),

                          'ProjValEmplCategorySetUp2');

qbr3.addRange(fieldNum(ProjValEmplCategorySetUp,CategoryId)).value(

    strFmt('(%1 == %4.%3) && (((%1 == %5.%1) && (%1)) || ((%2 == %5.%2) && (%2)))',

    fieldStr(ProjValEmplCategorySetUp,CategoryId),

    fieldStr(ProjValEmplCategorySetUp,GroupId),

    fieldStr(ProjCategory,CategoryId),

    qbr1.name(),

    qbr2.name()));

// regenerate the record from cartonInquiry to onhand form
void clicked()
{
    WMSPallet wMSPallet;
    Args args = new Args();
    ;
    args.caller(this);
    wMSPallet = WMSPallet::find(sunWMSCartonInquiryView.wMSPalletId);
    args.record(wMSPallet);
    new MenuFunction(menuitemdisplaystr(InventOnhandItem), MenuItemType::Display).run(args);
}

report design section

Posted: June 26, 2007 in Uncategorized
Section:
    Prolog
    PageHeader : print on all pages in case multi-paged report

    Header : print only one page on first

    Section Group
    Footer : print only last page right after body section. you may control position of page with TOP, BOTTOM properties.
    PageFooter : print on all pages on the bottom
    Epilog : add new page next to the last page and print on top of it.
    ProgrammableSection

AX4.01 print PDF using EP

Posted: June 23, 2007 in Uncategorized
Hi,

I dont feel that there is any problem with the image path or location, since
company logo is stored and passed as container.

As per my research there is some problem in executing image class (run on
client ) initilization which may require some thing from client side. As EP
runs on server its not able to initilize it.

Even i tried the diffrent way of passing refrence to bitmap field
(Resources, file path, hardcoded server file path) but nothing seems working.
Infact Image class is not able to load the the bitmap data provided by any
mean.

Any thought on same will be appreciated.

Thanks,
JJ

"Chris (Toronto)" wrote:

> Hey JJ,
>
> The "Publish Images" routine just moves the images onto the web server…
> The problem still remains if the files are located on the web server, or on a
> share on another server… Same GDI Error.
>
> I am still struggling with this, no solution found yet.
>
> Chris
>
> P.S. It was interesting to see my slightly modified post today!
>
>
> "Alpesh" wrote:
>
> > …sorry correct AX path should be:
> > Administration>>Setup>>Internet>>Enterprise portal>>Publish
> > Images.
> >
> > "Alpesh" wrote:
> >
> > > Hello,
> > >
> > > I have not been able to get to the bottom of this yet.  However, I have
> > > determined that if you navigate to Administration>>Setup>>Internet>>Publish
> > > Images.  And run the process, all the images against the following tables:
> > > "CompanyImage"
> > > "EmplTable"
> > > "ECPPresentation"
> > > "EPParameters"
> > >
> > > will be copied to:
> > >  "..\Program Files\Common Files\ Microsoft Shared\ web server
> > > extensions\60\TEMPLATE\LAYOUTS\ep\images"
> > >
> > > The challenge I have now is how to get my, say for example, AX report, to
> > > resolve this when in EP. 
> > >
> > > Please note that I am not sure if this line of investigation is correct, but
> > > it seems logical at the moment!
> > >
> > > Can anybody out there help?
> > >
> > > I will update you if I get further.
> > >
> > > Alpesh
> > >
> > > "jj" wrote:
> > >
> > > > I am also facing the same issue … is there any solution or alternative you guys find out ?
> > > >
> > > > EggHeadCafe.com – .NET Developer Portal of Choice
> > > > http://www.eggheadcafe.com
> > > >

 
Hello Chris,

We have got the same issue.  I am testing one or two thoughts on resolving
this.  Will let you know when I am done.

Alpesh

"Chris (Toronto)" wrote:

> Alpesh,
>
> Thanks for your guidance on the Event log… Your right.
>
> The error I’m getting is coming from the PDF Writer class, and it’s because
> of an image…. I’ve read a few posts that talk about removing images from
> reports before printing… But this is not solution… we need the images.
>
> Any ideas on how to fis this error? (Application Error Log listed below)
>
> Chris
>
>
> The Microsoft Dynamics session get object call runWebletItem failed.
>
> GDI+ generic error.
> (C)\Classes\Image\new
> (C)\Classes\PDFViewer\writeBitmap – line 76
> (C)\Classes\ReportOutputUser\writeField
> (C)\Classes\ReportOutputUser\printViaClass
> (C)\Classes\ReportOutput\printPDF
> (C)\Classes\ReportOutput\printToTarget
> (S)\Classes\ReportRun\print
> (S)\Classes\ReportRun\run
> (S)\Classes\ioSendDocument\printSpecSheetPDF – line 43
> (C)\Web\Web Forms\cmooTest\Methods\init
> (C)\Classes\WebFormHtml\run – line 5
> (C)\Classes\WebFormHandler\new – line 45
> (C)\Classes\WebPortalExecutionEngine\processWebContentItem – line 70
> (C)\Classes\WebFormWeblet\run – line 8
> (C)\Classes\WebLet\runFrame – line 39
> (C)\Classes\WebAppWebLet\runFrame – line 4
> (C)\Classes\WebPortalExecutionEngine\runWebletItem – line 64
>
> Object ‘Image’ could not be created
> File Exists: true, \\itvaos2003\EpFiles\Spec(149545).pdf
>
> Microsoft.Dynamics.BusinessConnectorNet.XppException
>    at Microsoft.Dynamics.BusinessConnectorNet.AxaptaObject.Call(String
> methodName, Object[] paramList)
>
>
> "Alpesh" wrote:
>
> > Do you have a bitmap on your source file?  If so, remove it and then try
> > generating your report again.  Also, maybe you already know this, if there is
> > an error generated by EP it will be written to the Application Event lof on
> > the IIS Server.
> >
> > Alpesh
> >
> > "Chris (Toronto)" wrote:
> >
> > > Hello,
> > >
> > > I am attempting to create a PDF from a report on the fly on the Enterprise
> > > portal.
> > >
> > > The following code is being used to generate the report:
> > >
> > > args = new args();
> > >     args.name(reportStr(ioItemSpec));
> > >     args.record(ioTItleLine);
> > >     if (_showExtended)
> > >     {
> > >         args.parmEnum(1);
> > >     }
> > >     args.parm(num2str(_itemPrice,0,2,0,0));
> > >
> > >     reportRun = new reportRun(args);
> > >     reportRun.args().name(‘KeepSettings’);
> > >     reportRun.query().interactive(False);
> > >     reportRun.report().interactive(False);
> > >     reportRun.setTarget(printMedium::File);
> > >     reportRun.printJobSettings().setTarget(PrintMedium::File);
> > >     reportRun.printJobSettings().format(PrintFormat::PDF);
> > >     reportRun.printJobSettings().warnIfFileExists(False);
> > >     reportRun.printJobSettings().suppressScalingMessage(True);
> > >     reportRun.printJobSettings().packPrintJobSettings();
> > >     reportRun.printJobSettings().fileName(filename);
> > > 
> > >     reportRun.run();
> > >
> > > This works great when the report is printed from a client machine…. But
> > > when the report is generated by a webform, or a class called from the EP, the
> > > PDF is corrupt (only 1 K)
> > >
> > > The PDF file created when opened in notepad is:
> > >
> > > %PDF-1.3
> > > % Quotation – Report
> > > % Generated by Guest on 3/21/2007 at 14:26:54
> > > 5 0 obj <<
> > >   /Creator (Axapta)
> > >   /Producer (Guest)
> > >   /Title (Quotation – Report)
> > >   /Author (Axapta  \(build2163\))
> > >   /Subject (Quotation – Report)
> > >  
> > >
> > > Any ideas on why the PDF report is not being generated correctly when the
> > > report is called from the Enterprise Portal?
> > >
> > > Any help would be greatly appreciated!
> > >
> > > Chris

print filtered list only

Posted: June 23, 2007 in Uncategorized
Thanks Mathias i’ll prove and let you now you

Juan Manuel

"Mathias" wrote:

> Am Tue, 17 Apr 2007 15:16:00 -0700 schrieb Juan Manuel:
>
> > Hi, All I’m Newbie in Axapta and working in a developement where i fill a
> > form with a temporary table and the user look for information and make some
> > filters, when the user find the raight information he want to print the
> > information in a report.
> >
> > I’m al ready make an inform but when is calling bring the last filter used,
> > is there some way to know the filters used by the user and passing this
> > values to the class that make the inform ????
> >
> > Any one has/know some exemple of doing this???
> >
> > regadrs and thanks in advance
>
> Hi,
>
> you can use element.dataSource() to get the query with all ranges on your
> form.
> Here is an example that will show you all the ranges in a new dialog. Just
> use a button on your form and overload the method "clicked".
>
> void clicked()
> {
>     FormRun         fr;
>     FormDataSource  fds = element.dataSource();
>     queryRun        queryRUn;
>     ;
>     super();
>     queryRUn = fds.queryRun();
>     queryRun.prompt();
>
> }
>
>
> And you can use this query in your report to get all records based on it.
> To call your report you can use the following code to parse the query from
> your from to your report.
>
> void clicked()
> {
>     ReportRun       reportRun;
>     FormDataSource  fds = element.dataSource();
>     queryRun        queryRUn;
>     args            args = new Args();
>     ;
>     query = fds.query();
>     args.name(reportstr(yourReportName));
>     args.parmObject(fds.queryRun());
>     super();
>
>     reportRun = new ReportRun(args);
>     reportRun.init();
>     reportRun.run();
>     reportRun.wait();
> }
>
> after that you have to set up queryrun on your report.
>
> i hope this will help.
> —
> Mathias Füßler
> My blog: http://starside.eu
>

why don’t you write programmable sections and execute the required sections
depending on your conditions.
take a look at the report Cheque_UK (check the fetch method)

"Chida" wrote:

> Hi Folks,
>
> I would like to hide a section group in my report based on certain
> conditions,How it can be done in x++?
>
> I request the communty members to throw some light on this.
>
> Best Regards
> Chida
>

Making new instance(service name:$01-DAXLive) copy from another one($02-DAXTest).
let’s say new instance name is DAXTest
1. create database server – DAXTest
2. create object server.
3. stop the service $01-DAXLive.
4. copy application file to the backup folder
5. start $01 service.
6. database restore from PROD.
7. database user recreate if needed.
8. start TEST service     
ps. delete *.aoi (index file) – it should be rebuilded.