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

Inserting Records in two tables at same time

(0) ShareShare
ReportReport
Posted on by 454

Hi, 

Im having two tables named Student Information , Student Marks . The Student Information table has two fields , Student Name and Rollno , the Student Marks table contains two fields Rollno and marks . If im Entering Roll no in Student information table the same roll no should be inserted in Student marks table . and also if im modifying the roll no in student infomation table it also updated in student marks table . i need x++ code for that . i am new to AX. 

Thanks in Advance . 

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,289 Most Valuable Professional on at
    RE: Inserting Records in two tables at same time

    It looks like the same topic as what's already discussed in your other thread Inserting Data into Two Tables at same time by using Code.

  • Suggested answer
    abdullah0094@hotmail.com Profile Picture
    85 on at
    RE: Inserting Records in two tables at same time

    Please check similar job

    Student Information -> student Name, RollNo -> StudentInformation

    Student Marks -> Roll no, marks -> StudentMarks

    public static void main(Args _args)

    {

    StudentInformation  student;

    StudentMarks    marks;

    ;

    ttsbegin;

    //Insertion of new record

    student.clear();

    student.rollNo = '1';

    student.name = "Check";

    student.insert();

    select marks where

    marks.rollNo == student.rollNo;

    if(!marks)

    {

    marks.rollNo = '1';

    marks.marks = '91';

    marks.insert();

    }

    ttscommit;

    //for updation

    select forupdate student

    where student.rollNo == '1';

    student.rollNo = 20;

    student.update();

    update_recordset marks

        setting roll = '20'

    where roll = '1';

    info("done");

    }

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,188

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 593 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans