Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Passing multiple records from one form to another

(0) ShareShare
ReportReport
Posted on by 582

Hi Experts,

I have a customized form which has two data sources Header Table and Line Table. When I create a record in my form and select the salesId in a field in the header part it should show the lines associated with the salesId in the bottom (Line table) of the form. I was trying to get it done using below code in the modified method of the field salesId in the datasource. I am not sure if this is the proper way to do it and I have an issue here that if i select the same salesid multiple times before saving the record it will create unnecessary records in the line table since the insert is called each time when the field is modified. what is the best way to achieve it ?

public void modified()
{
SalesTable salesTable;
Salesline salesLine;

super();

select salesTable where salesTable.salesId == MyTable.salesId;

MyTable.salesId = salesTable.salesId
MyTable.CustReference = salesTable.custReference

while select salesLine where salesLine.salesId
{
MyTable.salesId = salesLine .salesId
MyTable.ItemId = salesLine.ItemId
MyTable.insert();
}
}

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: Passing multiple records from one form to another

    modified is not the right place for this operation. The user did not save the record. He/she can change the selection, or completely abandon it, etc.

    You can write it in the insert method of the table. Also, if you open the salesLineRecId field on the line and add a check before creating the record, you will prevent duplicate records.

  • Suggested answer
    greengrimms Profile Picture
    1,400 on at
    RE: Passing multiple records from one form to another

    Hi!

    Is there a reason why you're using a custom table instead of the original (SalesLine) as a datasource?

    I think what you need is to link both parent and child datasource, in order to show the data related to the SalesLine in the details.

    That can be done by associating header and lines in the datasources properties. Select the lines datasource, and on the properties, select the header datasource as Join Source.

    Another thing I would do is just use the original SalesLine table as datasource, if this is only for displaying purposes.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans