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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

creation header and lines on the same form

(1) ShareShare
ReportReport
Posted on by 942
Hello,
 
I have created a form following the same pattern as SalesTable. I have 2 tables - Header and Lines both having transactionid as a mandatory field (property on the table field). I created a relation by transactionid on the line table to the header table. I added 2 tables to the form datasource and put a relation outerjoin on the lines table. the problem is when I click the new button to create a new header and new lines I always get error message that transactionid is not filled in. however I fill them using initvalue methods on the table level. what is the trick here? I also tried to add lines and then click save with no success
I have the same question (0)
  • dark_knight Profile Picture
    942 on at
    creation header and lines on the same form
    Thanks Martin. I had another one datasource with incorrect property allowcreate to false, which also has got transactionid. Now it works fine!
  • Verified answer
    Martin Dráb Profile Picture
    236,124 Most Valuable Professional on at
    creation header and lines on the same form
    Okay, at least we fixed one bug (outer join), but it seems that you have another bug there.
     
    Do you have a table relation between the tables? You didn't mention that but it won't work without a relation. Then you won't even need initValue() to initializet the values.
     
    Then check that each grid has the the right data source in the Data Source property.
  • Suggested answer
    Waed Ayyad Profile Picture
    8,907 Super User 2025 Season 2 on at
    creation header and lines on the same form
    Hi,
     
    Move the code of number sequence to create method of header DataSource and remove it from initValue() method.
     
     

     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

  • Komi Siabi Profile Picture
    13,047 Most Valuable Professional on at
    creation header and lines on the same form
     , I can see you are using number sequence for the header, and what you have shown us so far is just the method of initValue(). 
    What have you got on the create() of the datasource?
     
    The issue here is the transaction number is not committing to the DB.
  • dark_knight Profile Picture
    942 on at
    creation header and lines on the same form
    Hi Martin,
     
    Changed to delayed. no result.
     
    Thanks.
  • Suggested answer
    Martin Dráb Profile Picture
    236,124 Most Valuable Professional on at
    creation header and lines on the same form
    Using a join is wrong - use the Delayed link instead.
  • dark_knight Profile Picture
    942 on at
    creation header and lines on the same form
    Hello Andre,
     
    When I click on the new button (not addline on lines )here I see my transactionnumber filled by initvalue() method of the header table. I do not create lines yet (I changed link to delayed on the form just in case) then i click save and get this error again

     
     
    If I create lines like that and then  click save I do not see an error

     
     
     
    but if I go back to header view and click save then again this error.
     
     
     
    what's interesting after checking on SQL side. Lines are created but headers are not. So lines are created for each new header but headers themselves ar enot created
  • Verified answer
    André Arnaud de Calavon Profile Picture
    298,364 Super User 2025 Season 2 on at
    creation header and lines on the same form
    Hi Dark Knight,
     
    There can be various reasons for this behavior. At what exact moment do you get the error? Is it when opening the form, when clicking New for a new header or Add line for adding a new line? Or on all these triggers?
     
    One option was mentioned by Waed about the Insert if empty property. This might create a line too early when opening the form. 
     
    When you have the error when using Add line, then check if you have correct X++ logic on the initValue() method to fill the Transaction number on the line from your header table. 
  • dark_knight Profile Picture
    942 on at
    creation header and lines on the same form
    I did set property of both datasources insert if empty to NO. I do outerjoin because not all the headers should contain lines. such is the business requirement. I don;t understand why the system complains about mandatory field. I fill up mandatory field of the header in the initvalue method of the header table

     

    public void initValue()

     

    {

     

        NumberSeq numberSeq;

        super();

        numberSeq = NumberSeq::newGetNum(smmParametersTable::numReTest());

        numberSeq.used();

        this.TransactionId =  numberSeq.num();

     

    }


     
  • Suggested answer
    Waed Ayyad Profile Picture
    8,907 Super User 2025 Season 2 on at
    creation header and lines on the same form
    Hi,
     
    Why you set the relation to outer join? Also did you change the line table DataSource property insert if empty to No?
     
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,140

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 706 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans