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)

How to add/create line in a form?

(0) ShareShare
ReportReport
Posted on by

how to add or create a line in a form using x++ or functionality?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi Kavaljeet,

    create a line in a form  for Sales Order using x++

    static void Esh_CreateSO(Args _args)

    {

       SalesId sid;

       SalesLine sl;

       sl.SalesId=sid;

       sl.ItemId="A0001";

       sl.InventDimId="000458";

       sl.PriceUnit=3750.00;

       sl.SalesQty=5;

       sl.CreateLine(NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes);

       info("Sales Order Created with Line");

    }

  • Community Member Profile Picture
    on at

    thanks for the information and how can we do this with AOT Functionality??

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Your question isn't specific enough. One possible explanation is that you're looking for the create() method of form datasource.

  • Community Member Profile Picture
    on at

    i have to add a line in my form whicg was created by using x++??

    and i have no idea how can i do it?

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Can you give us more information, please? What exactly have you built?

    And why are you building a form from scratch in X++? It seems to be a new fashion, although I've personally done it just a few times in past twelve years (excluding dialogs). It's usually possible and much easier to start with a modeled form and merely modify it at runtime. Even the table browser form uses this strategy.

  • Suggested answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi,

    try this code:

    NumberSeq numberSeq;

    SalesTable salesTable;

    SalesLine salesLine;

    ;

    ttsbegin;

    numberSeq = NumberSeq::newGetNumFromCode(

    SalesParameters::numRefSalesId().numberSequence,true);

    salesTable.SalesId = numberSeq.num();

    salesTable.initValue();

    salesTable.CustAccount = '5312';//Your cust account from form

    salesTable.initFromCustTable();

    if (!salesTable.validateWrite())

    {

    throw Exception::Error;

    }

    salesTable.insert();

    salesLine.SalesId = salesTable.SalesId;

    salesLine.ItemId  = '';    //your item id from form

    salesLine.SalesQty = 0;     //your qty from form

    salesLine.createLine(true, true, true, true, true, true);

    ttscommit;

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