Before we get started if your not familiar with the relationship types available to you in Dynamics 365 I'd recommend reading my other post here on relationship types.  I recently had the requirement to map records from the many record back to the 1 record. Out of the box mapping only works when your creating one of the M records from the 1 record. Let's look at this diagram and I'll lay out the scenario.

In this scenario we see that there are three one to many relationships in our system. We have one account has many contacts and it also has many opportunities. We have a relationship where one contact can be associated to opportunities. If your unfamiliar with field mappings I highly recommend taking a look at the msdn article on this here. Let's use the contacts to opportunity relationship to quickly explain field mappings. The ability to do field mappings in Dynamics 365 is only available when creating an opportunity from the contacts form. This means you'd have to access the sub-grid on the contacts and then click create new; this will drive the mapping fields down to the opportunity entity while your creating it.

My problem set was from the opportunity record I had to be able to create the contact record and pass in what account it should be set to based on that opportunities account. I couldn't use the mapping out of the box so I started to think about java-script options or querying the web services to figure this out. The fun thing about this challenge is when creating a contact from the opportunities lookup field; the contact simply isn't matched to that opportunity yet. Dynamics CRM only establishes a link between these entities after the contact has been created and the opportunity has been saved. This created a very tricky issue as I had to set values on that the account value on that new contact record to be the same as the opportunity it was created from. The direction I took was to create a workflow on the create of the contact pull the account from the opportunity field and set it. The interesting thing I had found was even though the account was a required field in the footer of the contact form we were still able to create it from the opportunity without setting it. I had a very specific requirement set here with complexities on relationships but the simplistic solution of creating a process on the oncreate of the 1 record in a 1:M relationship allows us to do a backwards mapping without any code.

I hope you found this interesting as I really did enjoy solving this business issue.