Quantcast
Channel: Martin Dráb's Activities
Viewing all 17532 articles
Browse latest View live

Join first line in AX 2012

$
0
0

You sometimes need to join only one related record for each parent record, for example one order line for each order header. I’m always suspicious of such requirements, because it often means that users/analysts didn’t realize that there may be more than one record, or they didn’t think enough of identifying the one record they actually need. Nevertheless there are valid scenarios when showing only the first or the last record is exactly what’s required.

If you wrote it in T-SQL, you could use a subquery, but how to achieve the same in AX? If you read my blog post about Subqueries in views, you already know that computed columns can be for building subqueries. Let’s apply the same approach to this problem.

In my example, I’ll create a form showing information from sales lines and from the last shipment for each sales line. It’s based on a real implementation, nevertheless it’s simplified so we don’t have to deal with too complex computed column or form. (Also please don’t forget that computed columns are not supported in AX 2009 and older versions).

View

First of all, create a view and call it SalesLineLastShipmentView. Add SalesLine datasource and drag InventTransId field from the datasource to the Fields node.

ViewWithInventTransId

InventTransId is the primary key of the SalesLine table and we’ll later use it for a join with SalesLine. The view will also contain ShipmentId (the primary key of WMSShipment table), which will be used for a join as well. To get the ID of the last shipment, first create a method on the view and put the following code there:

publicstaticserverstr lastShipmentId(){
    SysDictTable orderTransDt =new SysDictTable(tableNum(WMSOrderTrans));
 
    SysDictTable productCategoryDt =new SysDictTable(tableNum(EcoResProductCategory));
    DictView dv =new DictView(tableNum(SalesLineLastShipmentView));
 
    str s =strFmt('SELECT TOP 1 %1 FROM %2 WHERE %2.%3 = %4 ORDER BY %5 DESC',
        orderTransDt.fieldName(fieldNum(WMSOrderTrans, ShipmentId), DbBackend::Sql),
        orderTransDt.name(DbBackend::Sql),
        orderTransDt.fieldName(fieldNum(WMSOrderTrans, InventTransId), DbBackend::Sql),
        dv.computedColumnString(tableStr(SalesLine),fieldStr(SalesLine, InventTransId), FieldNameGenerationMode::WhereClause),
        orderTransDt.fieldName(fieldNum(WMSOrderTrans, DlvDate), DbBackend::Sql));
 
    returnstrFmt('ISNULL((%1), \'\')', s);
}

If it’s not clear what it does, wait a moment until we look at the resulting SQL query; it will be much more readable.

Now right-click the Fields node of the view and choose New > String Computed Column. Open properties of the column and set them as follows:

  • Name = ShipmentId
  • ExtendedDataType = WMSShipmentId
  • ViewMethod = lastShipmentId

Properties

Save the view, open it in table browser if you have some shipments in your system, you should see them mapped to InventTransIds.

ViewInTableBrowser

If you’re curious, open SQL Server Management Studio, find views in your AX database, right-click SalesLineLastShipmentView view and choose Design. It opens a view designer and you can find the actual SQL query there. This extremely useful especially if your view doesn’t work as expected and you want to see how exactly was translated to SQL.

This is the definition of our view:

SELECT INVENTTRANSID, DATAAREAID, PARTITION, RECID,CAST(ISNULL
	((SELECT TOP (1) SHIPMENTID
		 FROM dbo.WMSORDERTRANS
		 WHERE(INVENTTRANSID = T1.INVENTTRANSID)ORDERBY DLVDATE DESC),'')AS NVARCHAR(10))AS SHIPMENTID
FROM dbo.SALESLINE AS T1

You should recognize the subquery defined in our view method. It finds the first only (TOP (1)) WMSOrderTrans record for each SalesLine and return the ShipmentId. If none is find, it returns an empty string instead of NULL (because AX doesn’t expect NULL values in this case). That’s handled by ISNULL() function.

Note that you should always use ORDER BY if you look for first or last records, because otherwise the order is not defined and a different row may be returned every time you execute the query.

Form

Now we have a mapping between InventTransId and ShipmentId and because we want to see more fields in a form, we have to join tables to our view and build a form showing the fields.

Create a new form and add three datasources:

  • SalesLine (the root datasource)
  • SalesLineLastShipmentView (inner-joined to SalesLine)
  • WMSShipment (joined SalesLineLastShipmentView with outer join, because some sales lines have no shipment at all)

Because we don’t have any relation between SalesLine and SalesLineLastShipmentView, we have to add it in code. Override init() method of SalesLineLastShipmentView datasource and add the following code below super():

this.queryBuildDataSource().addLink(fieldNum(SalesLine, InventTransId),fieldNum(SalesLineLastShipmentView, InventTransId));

We don’t need the same procedure for WMSShipment, because it’s already handled by the table relation on WMSShipmentID data type.

The last thing is to create a form design. To keep is simple, create a grid and drag some fields there from SalesLine and WMSShipment.

FormWithData

Summary

Views are powerful even without computed columns. For example, if you simply wanted the highest shipment ID for each line, you could build a view like this (and join it with SalesLine and WMSShipment tables):

SELECT InventTransId,MAX(ShipmentId)AS ShipmentId FROM WMSOrderTrans
    GROUPBY InventTransId

Nevertheless computed columns add another dimension to views and allow you to use many more features of T-SQL. This ultimately allows you to implement business requirements that would be difficult to achieve by other means. Unfortunately the syntax for defining computed is far from perfect – it’s not easy to write nor read and you get little compile-time control. Here definitely is room for improvement. But this is definitely no argument for giving up all the power that computed columns offer.

Download

Zipped .xpo with the view and the form (built in AX 2012 R3


Populating Grid from code

$
0
0

Is there possibility to define each field in row in grid separately?

Something like this pseudo code:

someObject.FirstColumn = "Macbeth";

someObject.SecondColumn = "Hamlet";

someObject.ThirdColumn = "A Midsummer night dream";

myGrid.Add(someObject);

otherObject.FirstColumn = "Othello";

otherObject.SecondColumn = "King Lear";

otherObject.ThirdColumn = "Twelfth Night";

myGrid.Add(otherObject);

At this point I would like to have two rows with three columns each.

Entity action cannot be specified.

$
0
0

Hi,


I try to create a customer in AX2012 through WEB service

I use inbound port with HTTP adapter, data policies is enabled all elements.

SOAPaction: localhost/.../create

I retrieve the error:

Customer.createList    Line=1, Pos=172, Xpath=/Customer/CustTable[1]    Entity action cannot be specified.

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:SOAP-ENV="schemas.xmlsoap.org/.../envelope" xmlns:dat="schemas.microsoft.com/.../datacontracts">
    <SOAP-ENV:Header>
        <dat:CallContext>
            <dat:Company>DAT</dat:Company>
        </dat:CallContext>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <tns:CustomerServiceCreateRequest xmlns:tns="schemas.microsoft.com/.../services" xmlns:ns="schemas.microsoft.com/.../EntityKey" xmlns:tnsA="schemas.microsoft.com/.../EntityKeyList" xmlns:nsA="schemas.microsoft.com/.../sharedtypes" xmlns:tnsB="schemas.microsoft.com/.../Customer" xmlns="schemas.microsoft.com/.../QueryCriteria"  xmlns:xsi="www.w3.org/.../XMLSchema-instance">
            <tnsB:Customer>
                <tnsB:DocPurpose>Original</tnsB:DocPurpose>
                <tnsB:SenderId>DAT</tnsB:SenderId>
                <tnsB:CustTable class="entity" action="create">
                    <tnsB:CustGroup>Test</tnsB:CustGroup>
                    <tnsB:DefaultDimension>
                        <nsA:Values>
                            <nsA:Value>
                                <nsA:Name>Customer</nsA:Name>
                                <nsA:Value>0001</nsA:Value>
                            </nsA:Value>
                        </nsA:Values>
                    </tnsB:DefaultDimension>
                    <tnsB:DirParty class="entity" action="create">
                        <tnsB:Name>Simple Name</tnsB:Name>                        
                    </tnsB:DirParty>
                </tnsB:CustTable>
            </tnsB:Customer>
        </tns:CustomerServiceCreateRequest>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

What I do incorrect?

Problem is in XML or in configuration?

Find and Read requests work fine, have problem only with update and create.

Any idea?

I will be glad to any answer )

[AX 2012 R3] Database deadlock during wave processing

$
0
0

Hi Guys,

we experienced strange database locks during wave processing (Task 3) recently. We are using R3 CU8.

The lock occurres very rarely (the second time this year) but if it happens it's repeatable. It happens when WHSWorkCreate (createTempLine Line 139-149) trys to insert a WHSTmpWorkLine. Here is a screenshot.

The first condition is the standard case. If i force the debugger into the second condition the insert is executed successfully, so i suspect the independant transaction has a high potential to cause a lock.

Down below is the SQL statement which is blocked. We currently trying to find out which SQL statement causes the block.

(@P1 int,@P2 nvarchar(20),@P3 nvarchar(21),@P4 nvarchar(21),@P5 numeric(32,16),@P6 nvarchar(21),@P7 numeric(32,16),@P8 nvarchar(11),@P9 int,@P10 nvarchar(21),@P11 int,@P12 nvarchar(21),@P13 nvarchar(21),@P14 nvarchar(21),@P15 int,@P16 bigint,@P17 numeric(32,16),@P18 nvarchar(11),@P19 nvarchar(26),@P20 int,@P21 nvarchar(11),@P22 nvarchar(11),@P23 nvarchar(11),@P24 nvarchar(11),@P25 nvarchar(21),@P26 nvarchar(21),@P27 int,@P28 bigint,@P29 nvarchar(21),@P30 nvarchar(21),@P31 nvarchar(21),@P32 numeric(32,16),@P33 nvarchar(21),@P34 numeric(32,16),@P35 nvarchar(21),@P36 nvarchar(11),@P37 int,@P38 nvarchar(20),@P39 nvarchar(21),@P40 nvarchar(26),@P41 numeric(32,16),@P42 nvarchar(61),@P43 nvarchar(21),@P44 int,@P45 nvarchar(26),@P46 numeric(32,16),@P47 nvarchar(21),@P48 nvarchar(21),@P49 nvarchar(21),@P50 nvarchar(21),@P51 nvarchar(26),@P52 nvarchar(21),@P53 int,@P54 nvarchar(20),@P55 int,@P56 nvarchar(21),@P57 int,@P58 nvarchar(11),@P59 nvarchar(11),@P60 nvarchar(5),@P61 int,@P62 bigint,@P63 bigint)INSERT INTO WHSTMPWORKLINE (WORKTYPE,WMSLOCATIONID,INVENTTRANSID,ITEMID,INVENTQTY,WORKTEMPLATECODE,DIRECTIVEQTY,DIRECTIVEUOM,ORIGINTYPE,ORIGINREFID,WORKTRANSTYPE,WORKCREATEID,INVENTDIMID,INVENTLOCATIONID,REFTABLEID,REFRECID,HIGHESTQTY,HIGHESTUNITID,LICENSEPLATEID,WORKCREATED,WAVEATTRIBUTECODE,WAVEATTRIBUTECODE2_,WAVEATTRIBUTECODE3_,WAVEATTRIBUTECODE4_,INVENTBATCHID,INVENTSERIALID,WORKBREAK,LOADLINEREFRECID,WAVEID,LOADID,SHIPMENTID,PACKINGQTY,ORDERNUM,LINENUM,WORKID,REQUESTEDTYPEID,PACKQTYCOMPARE,STARTLOCATIONID,ZONEID,CONTAINERID,INVENTUNITIZEQTY,TRANSTXT,RELEASETOWAREHOUSEID,CONTAINERLEVEL,HIGHESTCONTAINERID,AVAILPHYSICAL,CARRIERCODE,CARRIERSERVICECODE,CUSTVENDAC,FEFOBATCHID,LOCATEDLPID,MODECODE,REPLENDEMAND,REPLENLOCATIONID,SORTCODE,TOWAREHOUSE,PRODBOMOPRNUM,WHSFILTERNUM,ECORESSIZENAME,DATAAREAID,RECVERSION,PARTITION,RECID) VALUES (@P1,@P2,@P3,@P4,@P5,@P6,@P7,@P8,@P9,@P10,@P11,@P12,@P13,@P14,@P15,@P16,@P17,@P18,@P19,@P20,@P21,@P22,@P23,@P24,@P25,@P26,@P27,@P28,@P29,@P30,@P31,@P32,@P33,@P34,@P35,@P36,@P37,@P38,@P39,@P40,@P41,@P42,@P43,@P44,@P45,@P46,@P47,@P48,@P49,@P50,@P51,@P52,@P53,@P54,@P55,@P56,@P57,@P58,@P59,@P60,@P61,@P62,@P63)

Restarting the AOS didn't help. Deleting the WHSTmpWorkLine before processing a wave sometimes helped for a while but not reliable

Did anybody experienced this behavior?

Regards

Nils

Moving Database Table changes from Development to Production Environemnt

$
0
0

Hi,

I have added some new fields to database table in MicrosoftDynamicsAX database. When i try to compare the changes while importing, it shows the new field, but does not let me move only the new field to the production database table. Instead it imports the complete table.

Please someone let me know how to move database table changes from development to produciton.

Thanks,

Abdul Aziz

Error in invoice posting job (in Batch)

$
0
0

Hi 

I get a "directory not found error" while I try to post my invoices in batch.

For until some time ago it used to work fine, but suddently it keeps crashing, and throwing a directory not found error.

We used to create those "temp" directory and put the invoice in them and after the invoice were posted. the directory get deleted.

The following code throws the error.

@SYS72247: "Directory %1 is not found!"

public str fileName(str _value = fileName)
{
    #WinAPI
    str directory;

    // if setter is called, then get directory and check if valid, else throw error.
    if (_value && !prmisDefault(_value))
    {
        directory = System.IO.Path::GetDirectoryName(_value);     



        // if the directory is empty then use the users temp path.
        if (!directory)
        {
            directory = SRSPrintDestinationSettings::getTempFilePath();

            // create the file name by combining the temp path the filename.
            fileName = System.IO.Path::Combine(directory, _value);
        }
        else
        {
            if (printMediumType == SRSPrintMediumType::File && !System.IO.Directory::Exists(directory))
            {
                throw error(strFmt("@SYS72247", directory));
            }
            
            if (printMediumType == SRSPrintMediumType::NCEBoks && !System.IO.Directory::Exists(directory))
            {
                throw error(strFmt("@SYS72247", directory));
            }
           
            // if directory is valid, then just assign the value to member variable.
            fileName = _value;
        }

        // if file name is changed, user may be prompted for overwriting existing file; pass false to allow this prompt to happen
        this.parmOverwriteFileIsSet(false);
    }

    return fileName;
}

Select entities for export to Office

$
0
0

Dear all,

 

I have a Doubt at DIXF, When i am Export the Data for a Particlur Ledgal Entity, Where can i select the Entity .. the option is not there in Dynamics AX Tab in Ms-Office

 

Plz Clarify the Doubt.. and plz tell me the solution ASAP

 

Regards

Vinod P  

Number Sequence Table Permission

$
0
0

I try to create record through form and it successfully created, but when i tried to create record through code get the following error.

"Cannot select a record in Number Sequence Code (NumberSequenceTable). Access Denied you do not have sufficient permission"


Move .xpo file to new Environmen

$
0
0

Hi all friends, and Experts,

I have to two environment 1 for DEV, 1 for TEST.


Info DEV : Using SQL 2008R2.

Infor Test : Using SQL 2014

When my developer he finished coding. He want to export .xpo from DEV and import .xpo to Test. I don't know DEV in SQL 2008 can compatibility with SQL 2014 ??

Any comments for my before i process this Task ?

Thanks all friends, and Experts so much!!

How to add text in form's status bar?

$
0
0

I have created a form. I would like to add text (for example: which shows me a sum of the lines' value) to status bar of the form (not application).

Is this possible? If yes, How?


Thanks,

which is better MS MVC or MS dynamics?

$
0
0

Hi Everyone

I am .net developer with five years of experience and what is the best for me MS MVC or MS dynamics which will have high packages and Good for my future.

AX 2009 , Logon error : Connection with the Application Object Server could not be established.

$
0
0

I am using .net calling a webservices which uses the Business Connector.On the first load , it dont pull out the data giving me the exception of "Logon error : Connection with the Application Object Server could not be established."

But when you hit F5 it will show the data.

Why it is not connected the first time loading of the page.

Hope to hear from you soon.Thanks

How many way to intergate Dynamics AX with Microsoft Project

$
0
0

Dear all friends end experts.

My customer, thay want use project management in AX. So now. i dont understand , i must install Microsoft Client in AX Server, or Project Server in AX server.

Plz help me, to clearly this information ( above).

Plz help.

Many thanks all friends, end experts.

Thanks all so much!

SysOperationController , SysOperationServiceController use.

$
0
0

Hi All,

Can somebody explain which situation we use SysOperationController/ SysOperationServiceController class? why?

Regards,

Nunna.

Upgrading from AX 2012 R2 to AX 2012 R3

$
0
0

Dear Experts,

I am going to perform the AX upgrade from AX 2012 R2 to R3. Currently we have so much customization over the existing system and as per the procedure of upgrading. We have to remove all the customization and perform the upgrade.

Question is, Is there any other way to perform system upgrade other than remove all customization and perform the upgrade than again implement the customization?

Best Regards,

Ahmed


Upgrading RAM for speeding up AX2012 R3

$
0
0

Hi everyone.

I am a new AX Learner. Recently my friend set up AX2012 R3 on my PC through VMware Workstation. (WIN2012)

As my computer had 4GB RAM installed and used 2GB RAM when setting up VMware Workstation. Now the Application AX is very slow while using and freezes all the time and ruining my mood when training. 

What If I upgrade my computer to another 4GB RAM (8GB over all) ? and change the setting in VMware Workstation to say 6GB. Will it effect AX2012 ? Its been a long session for installing AX2012 R3 and I dont want to interupt or damange .

I want AX2012 to rum smooth as its annoying me now.

Please advice.

Thanks in advance..

Combobox item is being reset to Default value

$
0
0

Hi,

I have two comboboxes in my form- Journal type and Posting Layer. 

When I make a selection in the first combobox i.e. Journal type, to "Allocation" and make a selection in the second combobox i.e, Posting Layer, to other than default ("Current"), it should be remembered.

Then if I change the Journal Type to other and when I again change it to "Allocation", the item in Posting Layer combobox should not be reset to its Default value.

It should be the one which I had selected previously.

Presently it is being reset to default value.

Please suggest what I have to do for this.

Thanks in advance.

Having problems with free Microsoft office 645 one year subscription

$
0
0

I downloaded the office gift app and claimed my subscription with the code I received through email. This took me to the download section where I clicked on install and it said my device was not compatible bearing in mind its a Microsoft Lumia 640 with windows 8. I then tried the windows phone download and it took me to a site that shows you how to use office, I then went back and tried to sign into the office app an it said (something went wrong) or something like that. I tried to do the process again and it said I have not downloaded to any device leaving me with three free installs. I'm used to setting up phones emails and accounts ect. but this has me baffled. If anyone can help it would be very much appreciated. Thanks

Joining AX form datasource with no direct relation through query x++

$
0
0

Hello,

I am trying to join 2 data sources on a form my modifying the query in the executeQuery() of the joined datasource, but after executing the addLink method, I am recieving an error , "Invalid Field/Related field combination".

I am trying to join WMSBillOFLadingOrder onto CustPackingSlipJourusing with SalesId as the relation.

Here is the code:

public void executeQuery()

{

  QueryBuildDataSource   cpj;

  QueryBuildDataSource   bol;

  query    query;

  query = CustPackingSlipJour_ds.query();

  cpj = query.dataSourceTable(tableNum(CustPackingSlipJour));

  bol  = cpj.addDataSource(tableNum(WMSBillOfLadingOrder));

  bol.joinMoIde(JoinMode::ExistsJoin);

  bol.fetchMode(QueryFetchMode::One2One);

  bol.relations(false);

  bol.addLink(fieldNum(CustPackingSlipJour, SalesId), fieldNum(WMSBillOfLading, InventTransRefId));

  super();

}

I tried the same in a job and it worked:

static void Job21(Args _args)

{

   Query       query;

   QueryRun    queryrun;

   QueryBuildDataSource    cpj;

   QueryBuildDataSource    bol;

   QueryBuildRange         qbr1;    

   CustPackingSlipJour     custPackingslipJour;

   WMSBillOfLadingOrder wmsBillOfLadingOrder;

   ;

   query = new query();

   cpj   =   query.addDataSource(tablenum(CustPackingSlipJour));

   qbr1  = cpj.addRange(fieldnum(CustPackingSlipJour,orderAccount));

   qbr1.value(queryvalue('CUST001'));

   bol   = cpj.addDataSource(tablenum(WMSBillOfLadingOrder));

   bol.relations(false);

   bol.joinMode(joinmode::InnerJoin);

   bol.addLink(fieldnum(CustPackingSlipJour,SalesId),fieldnum(WMSBillOfLadingOrder,InventTransRefId));

   queryrun  = new queryrun(query);

   while(queryrun.next())

   {

   custPackingslipJour   = queryrun.get(tablenum(CustPackingSlipJour));

   wmsBillOfLadingOrder = queryrun.get(tablenum(WMSBillOfLadingOrder));

   info(strfmt("%1 - %2",custPackingslipJour.salesid, wmsBillOfLadingOrder.billOfLadingId));

   }    

}

I'm not sure if I'm missing something. Does anyone have any insight?

Any help would be appreciated.

Thanks,

Charu

Integrating AX with console Application on Remote Server

$
0
0

Hi,

I am beginner with AX , trying to connect AX 2012 with a console Application/window Form 

Application on another server. When i add reference business connector dll into my solution on another server.

using namespacs system.Microsoft.BusinessConnectorNet;

and initializing AX object like Axapta ax=new Axapta(); ax.logonas("","",""......);

and Run the Program. it is showing 

"Could not load file or assembly, Microsoft.Dynamics.MaageInterop, Version=6.3.0.0, culture=neutral,public token="31bf3856a364e35" or one of it's dependencies,an attempt was made.."

Please somebody help to come out of this

Thanks.

Viewing all 17532 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>