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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

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

(0) ShareShare
ReportReport
Posted on by 290

I have a custom gate pass form with two data source first called gate pass table and the other one is driver table. Table gate pass has a foreign key relation with driver table on a national ID. It means national Id is in the both tables. In the form, we have also three fields driver national ID, driver name and driver contact number. I want to enable user to select national ID by lookup and also she can add new national ID by writing it in the national Id field. if national Id is exist in driver table the related name and contact should load. other wise user should enter those as well and new record should be added to the driver table. 

I can easily implement this requirement(by code). 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 join source property of the driver 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 load automatically but I should refresh data source to see the update.

2) If user enter new national Id error comes "The value 'xxxxx' in field 'Driver nationalId' is not found in the related table 'DriverDetails'."

I have the same question (0)
  • Verified answer
    Evaldas Profile Picture
    1,800 on at

    To solve the problem #2 set Validate property on your relation to No.

  • Nastaran Profile Picture
    290 on at

    Dear Evaldas,

    I lose the look up for the field after changing validate property to No. why this happen?

  • Blue Wang Profile Picture
    on at

    Hi Nastaran,


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


    Why don't you want to use the code?
    You can use a validation.
    You can use the lookup form, or you can perform match verification based on manual input, and add it if it doesn't exist.

    My example:

    public boolean validate()
    
    {
    
      boolean ret;
    
      InventTable  inventTable;
    
      ret = super();
    
      if(InventJournalTrans.ItemId)
    
      {
    
          inventTable = InventTable::find(InventJournalTrans.ItemId);
    
          if(!inventTable.recid)
          {
    
               ret = checkFailed("Item ID is not exist in table master item table.");
            //insert
          }
      }
    
      return ret;
    
    }

  • Nastaran Profile Picture
    290 on at

    Dear Blue Wang,

    Thank you, because I want to deeply know about d365. There are too many strong features in d365 which help developers and also most of them cause better performance.

    first I have set validation property on the relation to NO and then I have written something like your code on modified method and everything works fine.

      public void modified()
                {
              
                    super();
                    DriverDetails		driverDetailsLocal;
                    select driverDetailsLocal where driverDetailsLocal.nationalid == GatePassTable.DriverNationalId;
                    if(!driverDetailsLocal)
                    {
                        DriverDetails.NationalId	=	GatePassTable.DriverNationalId;
                        DriverDetails_ds.object(fieldNum(DriverDetails, Name)).allowEdit(true);
                        DriverDetails_ds.object(fieldNum(DriverDetails, ContactNumber)).allowEdit(true);
                    }
                    if(driverDetailsLocal)
                    {
                        DriverDetails_ds.object(fieldNum(DriverDetails, Name)).allowEdit(false);
                        DriverDetails_ds.object(fieldNum(DriverDetails, ContactNumber)).allowEdit(false);
                        DriverDetails_ds.setRecord(driverDetailsLocal);
                        DriverDetails_ds.research(true);
                        GatePassTable_ds.research(true);
                    }
    				
                }

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans