My 2p about ERP Solutions, Information Worker Solutions and other software products (mainly Microsoft Dynamics AX and Microsoft SharePoint).

04 November 2011

Use a worker in multiple legal entities

Business requirement

In AX 2012, there is the whole new concept about the Organization Model. One of the scenarios you can support is to use a worker in multiple legal entities. To do so, you have to employ the worker in multiple legal entities. Let’s say for example the worker has to be able to enter hours in multiple legal entities.

Scenario

  1. Hire a new worker by going to Human resources > Workers > Hire new worker. You’ll have to specify a Legal entity in which you are hiring the worker:
  2. Once you’ve created the worker, change to another legal entity and create a project hour journal. Add a line and try to choose the created worker: it won’t appear.
  3. To be able to enter hours for the created worker, go to the worker list page and choose Employment > Employment Details > New and employ the worker in another legal entity:
  4. Now you’ll be able to enter hours for the worker in the second legal entity.


Continue reading......

by Patrik Luca 1 comments

24 October 2011

Printing documents linked with Document Handling while printing Reports

Business requirement: Printing documents linked with Document Handling while printing Reports

This post describes how you can print automatically documents linked with Document Handling while printing a Report. This post elaborates following business scenario: users attach documents to the Project entity. Upon printing the Project Invoice, these documents should be printed right away and in an automatic way.

Solution:

Add a new ProjTable variable to the classDeclaration of the Report ProjInvoice: it will be used to store the value of our currently printed Project.

Create a method on table ProjInvoiceJour to get the ProjId for the currently printed Project Invoice. In this scenario we suppose no Project Invoices are made over multiple Projects, so there is a one to one link between a Project Invoice and a Project (which is not an obligation in Dynamics AX).


display ProjId projId()
{
ProjInvoiceItem projInvoiceItem;
ProjInvoiceEmpl projInvoiceEmpl;
ProjInvoiceCost projInvoiceCost;
ProjInvoiceRevenue projInvoiceRevenue;
ProjInvoiceOnAcc projInvoiceOnAcc;
ProjId projId = '';
;

while select projInvoiceEmpl
where projInvoiceEmpl.ProjInvoiceId ==
this.ProjInvoiceId
&& projInvoiceEmpl.InvoiceDate == this.InvoiceDate
{
if (projId && projId != projInvoiceEmpl.ProjId)
return "";
projId = projInvoiceEmpl.ProjId;
}

while select projInvoiceItem
where projInvoiceItem.ProjInvoiceId ==
this.ProjInvoiceId
&& projInvoiceItem.InvoiceDate == this.InvoiceDate
{
if (projId && projId != projInvoiceItem.ProjId)
return "";
projId = projInvoiceItem.ProjId;
}

while select projInvoiceCost
where projInvoiceCost.ProjInvoiceId ==
this.ProjInvoiceId
&& projInvoiceCost.InvoiceDate == this.InvoiceDate
{
if (projId && projId != projInvoiceCost.ProjId)
return "";
projId = projInvoiceCost.ProjId;
}

while select projInvoiceRevenue
where projInvoiceRevenue.ProjInvoiceId ==
this.ProjInvoiceId
&& projInvoiceRevenue.InvoiceDate == this.InvoiceDate
{
if (projId && projId != projInvoiceRevenue.ProjId)
return "";
projId = projInvoiceRevenue.ProjId;
}

while select projInvoiceOnAcc
where projInvoiceOnAcc.ProjInvoiceId ==
this.ProjInvoiceId
&& projInvoiceOnAcc.InvoiceDate == this.InvoiceDate
{
if (projId && projId != projInvoiceOnAcc.ProjId)
return "";
projId = projInvoiceOnAcc.ProjId;
}

return projId;
}


Call this method in the fetch of the Report ProjInvoice.




...
projInvoiceTable = ProjInvoiceTable::find(
projInvoiceJour.ProjInvoiceProjId);
// BGN Get ProjId for the ProjInvoiceJour
projTable = ProjTable::find(projInvoiceJour.projId());

projFormLetterReport.loadPrintSettings(
// END
...


Create a method printLinkedDocuments in the Report ProjInvoice.




void printLinkedDocuments()
{
#WinAPI
DocuRef docuRef;
;
while select docuRef
where docuRef.RefCompanyId == projTable.dataAreaId
&& docuRef.RefTableId == tableNum(ProjTable)
&& docuRef.RefRecId == projTable.RecId
{
if(docuRef.RecId)
{
if (element.printJobSettings().getTarget() ==
PrintMedium::Printer)
{
WinAPI::shellExecute(docuRef.completeFileName(),
element.printJobSettings().printerPrinterName(),
‘’,
#ShellExePrint);
}
}
}
}


Call this method in the fetch method of the ProjInvoice Report.




...
this.printDocumentHeader();
this.send(formLetterRemarks);
// BGN Print documents linked with document handling
this.printLinkedDocuments();
// END

if (element.page() != 1)
{
...


When printing the ProjInvoice Report to a Printer, the linked documents will be printed too: the linked documents will be printed on the default Windows printer of the user.



Continue reading......

by Patrik Luca 2 comments

21 October 2011

Print ranges on Generated Design of a Report

Business Requirement: printing ranges on a report

Printing the ranges with which a Report has been executed is only available for a AutoDesignSpecs Design of a Report.

Unfortunately this option is not available for Reports having a Generated Design.

Solution: override executeSection method in PageHeader

You can print the ranges with some X++ code modifications in your report.

  1. Add a PageHeader control to the Report, if there isn’t yet such a control in your Report.
  2. Override the executeSection method of the PageHeader control as follows:

    public void executeSection()
    {
    // BGN Printing ranges
    SysReportRun locSysReportRun;
    ;
    //END

    super();

    // BGN Printing ranges
    locSysReportRun = element;
    locSysReportRun.printRanges(true);
    SysReportRun::executePrintRangeSection(element);
    // END
    }



Continue reading......

by Patrik Luca 0 comments

09 August 2011

Intercompany with direct delivery and WMS setup

Problem description: Intercompany orders with direct delivery cannot be created because of the WMS setup

Creation of a direct delivery purchase order for an intercompany vendor may fail with following error message: Intercompany orders with direct delivery cannot be created because of the WMS setup on dimension group for item ….

This error occurs because the item being traded has one (or both) storage dimensions Location or Pallet ID active on its Dimension group and Blank receipt allowed and Blank issue allowed aren’t checked.

Solutions

You can easily solve this problem by allowing blank receipt and issue on the items Dimension group.

However, in some cases this isn’t possible, for example, you cannot allow blank receipt/issue on a storage dimension which is part of the financial inventory.

If it is a storage dimension with only Location active, then you can tweak the code a bit like this in the class PurchCreateFromSalesOrder, method run:



...
if (salesTableLocal.InterCompanyDirectDelivery
&& SalesTableType::construct(
salesTableLocal).canCreatePurchOrder()
&& VendTable::find(
tmpPurchLinePrice.AccountNum).interCompanyAccountExist())
{
select firstonly RecId from inventTable
where inventTable.ItemId == salesLineLocal.ItemId
join inventDimGroup
where inventDimGroup.DimGroupId ==
inventTable.DimGroupId
join inventDimSetup
where inventDimSetup.DimGroupId ==
inventDimGroup.DimGroupId
// no check for location: if the warehouse has a
// default issue and receipt location or the
// items have a default issue and receipt
// location, then check isn't needed
//&& (inventDimSetup.DimFieldId ==
// fieldNumWMSLocationId
// || inventDimSetup.DimFieldId ==
// fieldNumWMSPalletId)
&& (inventDimSetup.dimFieldId ==
fieldNumWMSPalletId)
&& inventDimSetup.Active == true
&& (inventDimSetup.AllowBlankIssue == false
|| inventDimSetup.AllowBlankReceipt == false);
if (inventTable.RecId)
{
throw error(strfmt("@SYS99182",
salesLineLocal.ItemId));
}
}
...

Just make sure that your setup for your warehouse always has a default receipt and issue location: as such it isn’t a problem that there is no check anymore on the location field, as it will be filled up always.





Or make sure each such item has a default receipt and issue location




Continue reading......

by Patrik Luca 3 comments

13 July 2011

X++ Code Snippet: create PurchTable

This X++ Code Snippet describes how to create a PurchTable.


PurchTable purchTable;
NumberSeq numberseq = NumberSeq::newGetNumFromCode(
PurchParameters::numRefPurchId().NumberSequence,
true);

purchTable.clear();

purchTable.PurchId = numberSeq.num();
purchTable.initValue();
purchTable.OrderAccount = "0001";
purchTable.initFromVendTable();
purchTable.insert();

numberSeq.used();


Continue reading......

by Patrik Luca 0 comments

08 July 2011

Extract date from a DateTime field

This post is a code snippet showing how to extract the date from a DateTime field

myDate = DateTimeUtil::date(ContactPerson.LastEditAxDateTime)


Continue reading......

by Patrik Luca 0 comments

10 June 2011

Set mail recipient and mail subject during posting

Business requirement: automatic setting of mail recipient and mail subject during posting

This post describes how to set the mail recipient and mail subject dynamically, but in an automatic way upon posting the packing slip for a purchase order. The printed packing slip is added as PDF to the created mail message. The solution is on an Axapta 3.0 installation, but probably the same can work for other Dynamics AX versions.

Solution

Create a new method in the class PurchFormLetter_PackingSlip.

void initPrintJobSettings()
{
PrintJobSettings printJobSettings;
;
printJobSettings =
new PrintJobSettings(printerSettingsFormletter);
// set the output format of the packing slip to PDF
printJobSettings.preferredMailFormat(PrintFormat::PDF);
// set the mail recipient (this could be parameterised,
// in the example it is hardcoded)
if (purchTable)
printJobSettings.mailTo(“foo@hotmail.com")
// set the mail subject if (purchTable)
printJobSettings.mailSubject(‘@SYS72882’
+ “ “ + purchTable.PurchId);
this.updatePrinterSettingsFormLetter(
printJobSettings.packPrintJobSettings());
}

Add a new method in the class PurchFormLetter.


void initPrintJobSettings()
{
}

Call the method in the main method of the class PurchFormLetter.


{
…
purchFormLetter.parmId(parmId);
purchFormLetter.transDate(systemDateGet());
purchFormLetter.initPrintJobSettings();
if (purchFormLetter.prompt())
{
…
}


Continue reading......

by Patrik Luca 3 comments

Patrik Luca, Ieper, BELGIUM
Feel free to use or spread all of the content on my blog. In return, linking back to my blog would be greatly appreciated. All my posts and articles are provided "AS IS" with no warranties.

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Most Read Entries

Categories

Recommended Books


Subscribe feeds rss Recent Comments

This Blog is part of the U Comment I Follow movement in blogosphere. Means the comment field of this blog is made DOFOLLOW. Spam wont be tolerated.

Blog Archive

My Blog List

Followers

Links