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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

how to initialize field using chain of command

(0) ShareShare
ReportReport
Posted on by 932

hello, 

I add  new field in table the I want to  initialize this field using chain of command in class extension,

I add  code like this : 

[ExtensionOf(classStr(OutLogisticOrderOut))]
 final class OutLogisticOrderOut_Extension
{
    public void createDetLOLine(Envelope _envelope, EnvLOOut _envLOOut, Warehouse _warehouse, ExchangeLineInfo _lineInfo)
    {
        Common                  sourceLine;
        DetLOLineOut            detLOLineOut;
        SalesLine               salesLine;
        sourceLine = this.retrieveSourceLine(_lineInfo);
        salesLine = sourceLine;
        detLOLineOut.PrepackGroupId = salesLine.Code;
        next createDetLOLine( _envelope,  _envLOOut,  _warehouse,  _lineInfo);
    }

}

the method createDetLOLine() : insert data in the table DetOLLine : 

how can I use the chain of command  :  i  initialize the field after or befor the next()?

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi BASMA,

    It should be the before the next call. If you add the code after next your custom field doesn't get a value because record gets inserted into a table DetOLLine at line number 12.

    Also don't create a new buffer for DetOLLineOut table. Use the buffer that is referred in the original method "createDetLOLine".

    Thanks,

    Girish S.

  • BASMA Profile Picture
    932 on at

    hello,

    I get error When I delete the declaration of buffer :

     public void createDetLOLine(Envelope _envelope, EnvLOOut _envLOOut, Warehouse _warehouse, ExchangeLineInfo _lineInfo)
        {
            Common                  sourceLine;
            SalesLine               salesLine;
            sourceLine = this.retrieveSourceLine(_lineInfo);
            salesLine = sourceLine;
            detLOLineOut.PrepackGroupId = salesLine.Code;
            next createDetLOLine( _envelope,  _envLOOut,  _warehouse,  _lineInfo);
        }

    Error The qualifier 'detLOLineOut' is not valid for field 'PrepackGroupId'.

  • GirishS Profile Picture
    27,827 Moderator on at

    What is the buffer name for "DetLOLineOut" table declared inside the method createDetLoLine?

    Just navigate to the method and see the buffer name for "DetLOLineOut".

    Use the same buffer to initialize values to your custom field.

    Thanks,

    Girish S.

  • BASMA Profile Picture
    932 on at

    yes I use the same buffer name

    the declaration is : 

    DetLOLineOut     detLOLineOut;

  • GirishS Profile Picture
    27,827 Moderator on at

    After adding the new field have you done build and synch?

    Try doing build and synch of your model and check again.

    Error says that field 'PrepackGroupId' is not available in table.

    Thanks,

    Girish S.

  • BASMA Profile Picture
    932 on at

    I do the build of model with synch , but the same error .

    the field existe in table.

    when I add declaration of buffer in COC I don't get the error

  • GirishS Profile Picture
    27,827 Moderator on at

    Check whether intelli sense is working - Just type the buffer name and see whether its showing any suggestion for that buffer.

    If that doesn't work then try adding the logic on table level insert or initValue method before next keyword.  But make sure you will have required values to assign it to your custom field.

    Thanks,

    Girish S.

  • BASMA Profile Picture
    932 on at

    intelli sense doesn't work

    also I must use this class to initialize field

  • GirishS Profile Picture
    27,827 Moderator on at

    Is the buffer 'detLOLineOut" is declared globally or declared inside the method 'createDetLoLine'?

    I think its declared inside the method that's why you are getting the error.

  • BASMA Profile Picture
    932 on at

    yes,  its declared inside the method

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans