0

I have an EntityA with 2 Required lookup fields on it. First lookup field is the Contact, which auto populates when I add a new EntityA from the Contact.

The Contact is also associated with one to many of Another EntityB. EntityB is the Second lookup field on the EntityA. I would like to auto populate the EntityB field when the Contact has only one EntityB associated with it.

The end result should be when I selected to add an EntityA, it auto populates the Contact and Another EntityB (when there is only 1) and I fill in the rest of the fields.

I thought this might be OOTB or easily configurable because it makes sense to do when there is only one possible value and the Lookup field is required.

2 Answers2

1

Relationships won't work like that. There is no 1:1 relationship in fact.

If you see, EntityA is N:N between EntityB and Contact literally. When you are creating EntityA from either end, from EntityB or Contact, that particular parent lookup will auto populate.

But the N:1 child record from selected parent cannot be populated (what logic you want system to apply to take the TOP 1 ??)

Either you should create a EntityB lookup field in Contact to capture the TOP 1 record (EntityB-1) & OOTB mapping can be used to populate this record while creating EntityA from Contact (this mapping will pull the field value like any other field from Parent)

Think this scenario like Account - Contact, though you may have N contacts for Account, you have to pick the Primary Contact. Same way Contact can work for N Account, but you have to tell the system whats the Primary Account he's looking into.

  • I agree with the first 3 paragraphs. I want the system to take the Top 1 when there is only one value. In your scenario, if I were to create an EntityA where Contact can work for N Account (EntityB) and the Contact only works for one Account, I'd like that Account to auto populate into my EntityA. If there is more than one Account, I'd like the user to select which Account for the Contact. Thanks! –  Mar 14 '18 at 13:41
  • @Marsharks I would love any system if it works in that way.. unfortunately you have to do coding for that.. – Arun Vinoth-Precog Tech - MVP Mar 14 '18 at 14:35
  • I thought that is what I was asking help with. I have no idea how to code it. –  Mar 14 '18 at 14:38
  • @Marsharks asking code without trying is offtopic in SO. Its broad also. Read Aileen answer: https://community.dynamics.com/crm/f/117/t/136703, try to write JS on form load & ask a new question in SO if you face any issues. – Arun Vinoth-Precog Tech - MVP Mar 14 '18 at 14:51
  • That's the most useless comment I have ever received. If I was a CRM developer, I wouldn't be asking the question. I have no idea even where to begin. What exactly would you want me to post? A blank notepad screen since I have no idea how to make this happen. Thanks for the useless information. –  Mar 14 '18 at 15:06
1

why not use Javascript on the selection for the first lookup to get data for the second using first lookup value joind with all the values related to it using fetchXML or Odata call and it's just a matter of setting fields and saving the form.

Muhammed Saad
  • 131
  • 1
  • 5