web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Packing slip posting error with custom code only in one company and only in CIL

(0) ShareShare
ReportReport
Posted on by 2,699

Hi All,

I introduced a custom class which basically creates additional salesLine records against a sales order.

The class is called from the SalesPackingSlipJournalPost class from the method - endPostLine.

The code is set to execute only in certain company/legal entity.

I start this off after the super()

if(curExt() == 'ABC')

{

call custom class which is declared in the class declaration of SalesPackingSlipJournalPost

}

My issue is that the code works and runs fine in company ABC but in company ABB it produces the error

Exception has been thrown by the target of an invocation.

The error only occurs when client runs in CIL.

I have tried to recompile CIL fully and incrementally and I have even cleared the xppil folder as well without any joy.

As a novice to debugging with visual studio I put a break point in at line 217 of the FormLetterService class.

Further analysis gives the following:

Invalid cast from 'System.Decimal' to 'Dynamics.Ax.Application.AG_CreateOrderLineDelRemainder'.

Could this have anything to do with either declaring the custom class AG_CreateOrderLineDelRemainder in the class declartion of SalesPackingSlipJournalPost or is it an issue using curExt in the endPostLine? 

*This post is locked for comments

I have the same question (0)
  • Kauto Profile Picture
    2,699 on at

    Might I add that in company ABC - they use standard sales packing slips and in company ABB they use project based sales packing slips.

  • Verified answer
    Kauto Profile Picture
    2,699 on at

    Update - folks I have removed the declaration of AG_CreateOrderLineDelRemainder from the class declaration of SalesPackingSlipJournalPost and placed it in the endPostLine method instead.  I think because the other company is posting project based packingslips it may not have been able to find the declaration of the class and hence hit an error?

    Anyone with better understanding of this please feel free to let me know.

  • Douglas Noel Profile Picture
    3,905 on at

    Hi Kauto,

    it shouldn't be a problem to use a declared variable within classdeclaration in any method of this class, but ...

    Most often this problems arise through to an missing AX compilation of the baseclass. This is a problem which Ax has in all versions.  It's not the CIL directly, but the wrong pre compilation from ax (which is the base for CIL)

    Take a look at the class SalesPackingSlipJournalPost it extends fromFormletterJournalPost

    (which extends from nothing)

    Most often you should compile the base class forward if doing some changes in class declaration in one of the derived classes. With this "one" forward compile all classes recompiled (even these which derive from your changed class)

    !!!! Due to the changed classdeclaration, more 'space' is required

    And keep in mind 'even this will not work in all cases', because there is no 100%  "ForceCompile".

    Some logic deep dark in the kernel simply skip the compiling sometimes.

    In such an case:  Make the base class 'dirty' (maybe entering some comments in any method)

    Then compile and you can delete your 'dirty hacks' afterwards

    or do a full compile.

    regards

    Douglas

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans