N:N Lookup on the new record form? Let’s do it!

By | January 31, 2020

It was great to see how N:N lookup PCF control has sparked some interest, but there are still a few things that could(and probably should) be added.

For example, what if I wanted to make it work when creating a new record? Normally, a subgrid won’t event show up on the new record form. But, in the updated version of the N:N lookup, it’s actually possible now:

ntonmultiselectoncreate

So, where is the catch?

The problem there is that there is no way for the PCF control to associate anything to the record being created, since, of course, that record does not exist yet. But, I thought, a “post operation” plugin would certainly be able to do it:

 

image

If you wanted to try it, here is what you need:

NToNMultiSelect control has been updated, too

You can use the same approach with any entity, just keep in mind a few things.

NToNMultiSelect is supposed to be bound to a single line text control. I should probably change this to “multiline”, but, for now, that’s what it is. Since this control is passing JSON data through that field, the field should be long enough (2000 characters). Yes, there is still room for improvement.

Also, you will need to register a plugin step on each entity which is using this control:

image

It should be registered in the PostOperation, and it should be synchronous.

The plugin will go over all the attributes, and, if any of them includes data in the required format, it will parse the data, and it will create required record associations.

That’s it for today – have fun with the Power! (just testing a new slogan hereSmile )

6 thoughts on “N:N Lookup on the new record form? Let’s do it!

  1. Pankaj

    Hi Alex,

    I installed your above solution in our trial environment for testing purposes and enabled “N: N Multiselct Lookup” PCF control for the “Single Line of Text” field and it works as expected until we “Save” the record. But after saving when we refresh the page it throws an error (i.e. [object object])

    Also, we noticed that the values that we were selected in the “N: N Multiselct Lookup” field got cleared. And also we were getting the “No result found” message inside the field when we were trying to select values again in the field.

    Can you please provide your suggestion on the same or if I am missing anything while using the “N: N Multiselct Lookup” control.

    Thanks!

    Reply
  2. Luke

    This is a really great addition.

    What would be even more useful would to update the underlying text field with a concatenated string of the selected record’s names. The text field could then be used in queries with fetchxml/Advanced Find in a similar fashion to a mult-select optionset.

    Reply
  3. Rob

    It’s amazing how Dynamics365 still does not have this functionality out of the box. Am I the only one facing this issue: in practice, we have many option sets (Choices) that in forms require MutliOptionset field (users must have the ability to pick several options at once).
    The issue with MultiOptionset:
    – no ability to update it outside administrator level roles (within Solution). Am I correct? So particular user roles (outside admin or customizer) cannot be granted the ability to add/update values for a particular Optionset (as if it were an entity)
    – no ability to define additional data (fields) for each option, as if it were a separate table or entity
    Of course, the obvious solution would be to define an extra Entity and link it with N-to-N relationship.
    However, the issue here is:
    – no OOB ability to display this as a typical View Column and offer search/filter capabilities as with any other field within views. No ability to Export and update with Excel either.
    – no ability to present this in the form without heavy PCF customization, which you showed is possible – but still, why not OOB as it seems a typical scenario I just described above

    Reply
  4. Dileep

    Hi, I have a pcf control, its working perfectly now. I got a new requirement. There is an option set in the form which has single or multi options. If it’s single, the pcf control should allow only one lookup value to be selected. Right now its always allowing multiple values. I have tried finding this options set control in index.ts but its not available. I tried onchange event of pcf control but its getting fired after the index.ts is finished. How can I do this? I really appreciate your help. Thank you.

    Reply
  5. Jay Patel

    I have configured this on Quick create form and it is working but didn’t associate record while same way it is working on Main form, so is there any reason behind this?

    Reply
  6. Manali

    What is the use of “Reset” property in this control? Can we use it for refreshing a control based on certain validations?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *