Nastaran Hakimi
Nastaran Hakimi

Reputation: 735

Automatically insert records to both data source of the form using join data source

I have a custom form called gate pass with two data sources The first data source is called gate pass table and the other one is called driver table.

gate pass table has a foreign key relation with driver table on field national ID. That means national Id is a field in both tables.

In the form, three fields are shown:

I want to enable the user to select national ID using a lookup and also be able to add a new national ID by entering it in the driver national ID field. If the national Id exists in the driver table the related name and contact should load. Otherwise the user should enter those as well and a new record should be added to the driver table.

However I want to meet this requirement by using Dynamic 365 features. I wonder whether I can use join data source property or not?

I have set the join source property of the driver table data source to gate pass data source with Active link type. There are two problems:

  1. When I select national Id in the main form the name field and contact field are loaded automatically but I should refresh data source to see the update.

  2. If the user enters a new national Id, the following error is shown:

"The value 'xxxxx' in field 'Driver nationalId' is not found in the related table 'DriverDetails'."

PS: In the gate pass form, the data source of the national Id field is gatepass and the data source of fields driver name and contact is driver table.

Upvotes: 0

Views: 943

Answers (1)

Hannes
Hannes

Reputation: 311

this seems to be not entirely possible without custom code. That said, the wanted behavior can be achieved by utilizing the change group functionality. Please refer to the docs here as well as this blog, which gladly did the heavy lifting for me.

You also might want to add a table_ds.executeQuery() for the FK field. So that if data is already there, it gets queried and displayed on the form if the user selects the key.

Hope this information helps.

Greetings, Hannes

Upvotes: 0

Related Questions