fredag den 23. august 2013

My apologies.

I recently discovered that I have not been attending my mail box blog@fasor.dk. My sincerest apologies to everyone who have written to this mail box and gotten no answer. The mail box is now set up on my windows phone, and I will be answering sent to it.

fredag den 16. august 2013

How to work around best practice error: "A form that is not associated with other forms should be linked to at least one menu item"

How does one work around the Best practice error: "A form that is not associated with other forms should be linked to at least one menu item", when developing a custom lookup form ?

Developing a possibility of a custom setup on the table ReqSitePolicy, that allows for calculation of "External Invent Onhand level", I added two new extended data types:

ItemSearchInventSiteId exending InventSiteId
ItemSearchInventLocationId extending InventLocationId

and three new fields:

ItemSearchShowAvailInventDataAreaId based on EDT SelectableDataArea
ItemSearchShowAvailInventSiteId based on EDT ItemSearchInventSiteId
ItemSearchShowAvailInventLocationId (based on a EDT ItemSearchInventLocationId)

to the ReqSitePolicy table.

To be able to make lookups for ItemSearchShowAvailInventSiteId and ItemSearchShowAvailInventLocationId fields based on the legal entity chosen in the ItemSearchShowAvailInventDataAreaId field (even though the currently active legal entity might be something else), I prepared two custom lookup forms for the EDTs ItemSearchInventSiteId and ItemSearchInventLocationId. The querys of the custom lookup forms have the property CrossCompanyAutoQuery set to YES.

The custom lookup forms uses the legal entity chosen in the ItemSearchShowAvailInventDataAreaId to make a crosscomapny lookup for InventSiteId and InventLocationId, clearing dynalinks and doing:

this.query().addCompanyRange(dataAreaIdCriteria);

in the executeQuery-method of the datasource of the lookup form.

However compiling the lookup forms resulted in the best practice error: "A form that is not associated with other forms should be linked to at least one menu item".

Well, to solve that problem open the lookupform in the - AOT-path:

Form / "custom lookup form name" / Designs / Design.
Set the "Style" property to "Lookup".

And poof the Best Practice error has gone away.

fredag den 9. august 2013

Modal forms in Dynamics AX

Some years ago, I wrote on this blog of a method to make a form modal in the AX client. The solution was made on Axapta 3.0 and involved calling winapi unmanaged. Someone commented that the method I described was bad code, because he had experienced a computer crash while debugging something that involved the code.

Mindaugas Pocius has suggested a method in his Dynamics AX cookbook books Dynamics AX Cookbooks where the windowtype is set to Popup. This ensures that the form is on top but not that the form you want to be modal, is the only one that is active, so using Mindagaus' method, you are able to leave the form that is "modal".

Now a colleague of mine has found a very simple solution. His scenario was this. From a form you can click a button that opens an other form. This form that is opened must be ontop and the only form in focus and active until you either click OK or CANCEL in this form.

The calling form includes a button, that open the form to be modal. The called form / modal form includes a simple command ( element.wait(true); )in the run method of the form:

public void run()
{
    super();
    element.wait(true);
    // Execution will resume at this point, only after
    // the user has closed the form.
}


So in essence the form you that is modal is in essence waiting for it self to be closed, before the execution path is returned to the calling form.