0

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:

  • driver national ID
  • driver name
  • driver contact number

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.

FH-Inway
  • 4,432
  • 1
  • 20
  • 37
Nastaran Hakimi
  • 695
  • 1
  • 16
  • 36
  • Could you tell us more about the data structure? For example, what is the relation between `gate pass` and `driver table`? From the description, it may be 1:1, but then why not just add the `national ID` field to the `driver table` and remove the `gate pass` table? And is table `DriverDetails` from the error message the same as the described `driver table`? – FH-Inway Nov 12 '19 at 18:37
  • @FH-Inway gate pass table has some other fields and also has a foreign key (national Id) from the driver table. The gate pass table is different from the driver table. – Nastaran Hakimi Nov 12 '19 at 19:36
  • Could you [edit] this new information into the question to help others find it more easily? I'm still unsure what the relation between `gate pass` and `driver table` is (1:1, 1:n, n:m?) and if tables `DriverDetails` and `driver table` are the same. You can help us answer your question if you provide additional details. Also take a look at [ask], which might give you more ideas what to add to your question to improve your chances of receiving an answer. – FH-Inway Nov 14 '19 at 16:44

1 Answers1

0

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

Hannes
  • 311
  • 3
  • 9