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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Error message is comin...
Finance forum

Error message is coming while opening the update order line - " Function PurchTable2LineField.getFieldDescription has been used incorrectly

(0) ShareShare
ReportReport
Posted on by 1,845

Hello everyone,

Error message is coming while opening the update order line - " Function PurchTable2LineField.getFieldDescription() has been used incorrectly.

Navigation - Procurement and sourcing < Setup < Procurement and sourcing parameters < General.

The code I have written is :

[ExtensionOf(classStr(PurchTable2LineField))]
final class PurchTable2LineField_Extension
{
    protected FieldLabel getFieldDescription(FieldId _fieldId)
    {
        FieldLabel description;
        description = next getFieldDescription(_fieldId);
        switch (_fieldId)
        {
            case fieldnum(PurchTable, PreparationDate) :
                return fieldId2PName(tableNum(PurchLine), fieldNum(PurchLine, PreparationDate));
                break;
        }
        return description;
    }
}
I have the same question (0)
  • startax Profile Picture
    1,845 on at

    Hi,

    Anyone suggest me how to stop next call for _fieldID = PreparationDate.

    In debug i found for every fieldID,  description = next getFieldDescription(_fieldId); is called. When PreparationDate is comming it throw error from description = next getFieldDescription(_fieldId);

  • Sukrut Parab Profile Picture
    71,735 Moderator on at

    There is delegate given getFieldDescriptionDelegate exactly for the purpose you are trying . Did you try to  implement that ?

  • startax Profile Picture
    1,845 on at

    Hi Sukrut,

    Not tried . Can you share any example to implement delegate.

    Thanks

  • Sukrut Parab Profile Picture
    71,735 Moderator on at

    Check this link

    community.dynamics.com/.../d365-delegates-to-dynamics-ax

  • startax Profile Picture
    1,845 on at

    Hi Sukrut,

    Thanks for suggestions.

    I written delegate  subscribe  method in class  and called that method in my extended  method. But still i am receiving same error

  • Suggested answer
    Jialin Liu Profile Picture
    on at

    Hi,

    Maybe it is a little bit late... but this should work...

    at the end of the method, return the _result

    /// <summary>

    ///

    /// </summary>

    /// <param name="_fieldId"></param>

    /// <param name="_result"></param>

    [SubscribesTo(classStr(PurchTable2LineField), delegateStr(PurchTable2LineField, getFieldDescriptionDelegate))]

    public static void PurchTable2LineField_getFieldDescriptionDelegate(FieldId _fieldId, EventHandlerResult _result)

    {

    FieldLabel description;

           description = next getFieldDescription(_fieldId);

           switch (_fieldId)

           {

               case fieldnum(PurchTable, PreparationDate) :

                   description = fieldId2PName(tableNum(PurchLine), fieldNum(PurchLine, PreparationDate));

                   break;

           }

           return _result.result(description);

       }      

    }

  • ShruthiKrishnaswamy95 Profile Picture
    50 on at

    Hi Jialin, The method has the return type as Void, this cannot be returned.

    @Sukrut, I am trying the same with the delegate, but I still get the error.

       [SubscribesTo(classStr(PurchTable2LineField), delegateStr(PurchTable2LineField, getFieldDescriptionDelegate))]

       public static void PurchTable2LineField_getFieldDescriptionDelegateDIS(FieldId _fieldId, EventHandlerResult _result)

       {

           

           switch (_fieldId)

           {

               case fieldNum(PurchTable, ShippingDate_DIS) :

                   _result.result(fieldId2PName(tableNum(PurchLine),fieldNum(PurchLine,ShippingDate_DIS)));

                   break;

               case fieldNum(PurchTable, ConfirmedShippingDate_DIS) :

                    _result.result(fieldId2PName(tableNum(PurchLine),fieldNum(PurchLine,ConfirmedShippingDate_DIS)));

                   break;

           }

       }

    Similar code can be found in ITMPurchTable2LineFieldClassEventHandler class in InboundTransportationManagement model. If I comment out my code, the same error is thrown from the ITM code. Also ITM class is an internal class, unable to hook or wrap around it as well. Should I check with MS? Any help will be appreciated.

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    Guys, could you please Insert > Insert Code to paste source code? It prevents the double line spacing, among other things.

    ShruthiKrishnaswamy95, could you please debug your code? I don't see the problem, therefore it's likely time to check out what's going on at runtime.

    By the way, you can simplify your code by replacing

    fieldId2PName(tableNum(PurchLine), fieldNum(PurchLine, ShippingDate_DIS))

    with

    fieldPName(PurchLine, ShippingDate_DIS)

  • ShruthiKrishnaswamy95 Profile Picture
    50 on at

    Hi Martin,

    Thanks for the suggestion, have modified to fieldPName().

    Currently there are three subscriptions to the delegate, one from ITM(InboundTransportationModel by MS), one from ASCS(AdvancedSupplyChainSoftware which is an ISV) and one is ours. Once the code breaks from our delegate, I think it goes to ASCS delegate which I think is sending result value as ' ' because the EventHandlerResult parameter shows so. I am not able to see their code because its an ISV. After which it goes to the ITM delegate. 

    It breaks when the resultvalue is sent as ' '.

    Is there any way I can check the ISV code?

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    Hmm, it indeed sounds like a bug in the ISV solution.

    If you didn't get source code from them, there is a way, but it's a bit complicated. What you can do is decompiling their binaries back to source code. But... there is no CIL decompiler to X++. But you can use decompilers to other languages, such as C#, which is similar to X++. Obviously you won't get the original source code, but it should be enough to understand what it does. Also note that decompiled code isn't easy to read, because there is a lot of infrastructure code for CoC, type conversions etc.

    There are several free decompilers, such as ILSpy. Give it a try, if you wish. (I personally use a commercial decompiler for some reasons, therefore I don't which of the free decompilers works the best.)

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans