SBX - Search With Button

SBX - Forum Post Title

Sub Grid - Get Add New to create record or hide Lookup

Microsoft Dynamics CRM Forum

Romolo asked a question on 22 Feb 2017 4:14 PM

Question Status

Suggested Answer

Hi Everyone,

I wanted to have effectively a table with related records to parent and for the child records to only ever be visible to the parent.

I created an entity. Added a sub grid.

Trouble is.. Add New starts a lookup. If I click Mag Glass... I get records for other parents even though I only see the related records in the sub grid view.

Posts say make related field business required to make Add New do this. But it is business required in the child entity as I reused name field

And in Contact which it is related to... I have linked to the Contact entity not any particular field

a) Please suggest better way to achieve this.

b) Advise how to hide lookup

c) Make Add New go straight to new record and have NO lookup.

CRM 2016 On-Premise

Thanks everyone

R

Reply
Suggested Answer

Hi,

It is the look-up to the parent contact that you need to make mandatory on the child entity. This will make the add new create a new record without the look up.

Hope this helps

Reply
Nadeeja Bomiriya responded on 22 Feb 2017 8:23 PM
My Badges
Suggested Answer

Hi Romolo,

+1 for Scott's suggestion.

Since the child record's lookup is mandatory, this field must be populated on creation of a record, which forces CRM to display the New form instead of providing the option to associate an existing record.

Reply
Alagu nellaikumar.S responded on 23 Feb 2017 1:17 PM
My Badges
Suggested Answer

Hi

In  your child entity make parent entity lookup field as mandatory

Reply
Romolo responded on 24 Feb 2017 3:11 AM

Sorry everyone. I was replying by email but that does not seem to populate a response

I do not have a 'Contact' field within the child entity.

Renamed Name field on child entity and added a Date field

Created Many to many relationship against Contact.
Dropped a sub grid onto the Main Contact Form.
I do not have a lookup field on the child entity to make mandatory.

Can you guys be more specific as I might be doing 2+2 = 5 :)

Thanks

R

Reply
Alagu nellaikumar.S responded on 24 Feb 2017 4:42 AM
My Badges
Suggested Answer

without creating lookup how do you have many to many realtionship

Reply
Nadeeja Bomiriya responded on 24 Feb 2017 4:43 AM
My Badges
Suggested Answer

Hi Romolo,

The parent lookup in child entity mandatory rule doesn't apply for N:N relationships.

community.dynamics.com/.../availability-of-add-new-and-add-existing-buttons-in-sub-grids

Reply
Nadeeja Bomiriya responded on 24 Feb 2017 4:47 AM
My Badges
Suggested Answer

Hi Alagu,

If you create a lookup it becomes a 1:N relationship.  You can create a N:N relationship directly. Please see below.

technet.microsoft.com/.../dn531171.aspx

Reply
Alagu nellaikumar.S responded on 24 Feb 2017 4:50 AM
My Badges
Suggested Answer

Hi

What Nadeeja said is correct. N:N lookup only existing button will display if you still want then add custom code to open the entity record in the + button in the subgrid using ribbon work bench

msdn.microsoft.com/.../jj602956.aspx

or

Create the button in the html webresource and open the entity

msdn.microsoft.com/.../jj602956.aspx

Reply
Romolo responded on 1 Mar 2017 5:10 AM

I think Ribbon workbench is the best option.

As I cannot do what other posts are suggesting.

But unfortunately it errors when I try to use it... The software writer did send one message. But nothing more...

So I am stuck again.

R

Reply
Romolo responded on 4 Mar 2017 3:35 PM

Hey All... trying to get Ribbon Workbench working so I can edit the command bar.

But I just get the following error when I try to use a solution.. new one too and even on a virgin new Org as a test.

Any help please peeps... Just did a regular on-premise install...

Server stack trace:

  at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrImmutable()

  at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

Exception rethrown at [0]:

  at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

  at System.ServiceModel.ICommunicationObject.Open()

  at Microsoft.Crm.Sandbox.SandboxClientBase`1.Open()

  at Microsoft.Crm.Sandbox.SandboxClientBase`1.get_Proxy()

  at Microsoft.Crm.Sandbox.SandboxCallbackService.ProcessException(Exception e, SandboxSdkClient client)

  at Microsoft.Crm.Sandbox.SandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)

  at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)

  at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [1]:

  at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

  at Microsoft.Crm.Sandbox.ISandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)

  at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)

  at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.RetrieveMultipleInternal(QueryBase query)

  at RWB2016.Plugins.RibbonCustomisationsPlugin.GetSolutionRecord(LocalPluginContext localContext, String solutionUniqueName)

  at RWB2016.Plugins.RibbonCustomisationsPlugin.GetSolutionDetails(LocalPluginContext localContext, ITracingService trace, String inputData)

  at SparkleXrm.Plugins.Plugin.Execute(IServiceProvider serviceProvider)

Stack Trace:

Error:

  at Xrm_Sdk_OrganizationServiceProxy$endExecute (:5555/MyOrganisationName/%7B636242554040000079%7D/WebResources/rwb_/js/ClientUI.js:4673:13)

  at Anonymous function (:5555/MyOrganisationName/%7B636242554040000079%7D/WebResources/rwb_/js/ClientUI.js:19463:5)

  at delegate (:5555/MyOrganisationName/%7B636242554040000079%7D/WebResources/rwb_/js/ClientUI.js:2223:13)

  at xmlHttpRequest.onreadystatechange (:5555/MyOrganisationName/%7B636242554040000079%7D/WebResources/rwb_/js/ClientUI.js:4723:25)

Trace:

[RWB2016.Plugins: RWB2016.Plugins.RibbonCustomisationsPlugin]

[ac49cdfa-aeef-e611-81d5-0800278d9765: Ribbon Workbench Action]

Entered RWB2016.Plugins.RibbonCustomisationsPlugin.Execute(), Correlation Id: 3c465c94-a366-44ea-a659-74084d7275d1, Initiating User: 336f45d2-6ef0-e511-80c0-00155d00f300

RWB2016.Plugins.RibbonCustomisationsPlugin is firing for Entity: none, Message: rwb_CustomiseRibbon, Correlation Id: 3c465c94-a366-44ea-a659-74084d7275d1, Initiating User: 336f45d2-6ef0-e511-80c0-00155d00f300

Reading operation

Running method

Exception: System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace:

  at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrImmutable()

  at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)

Exception rethrown at [0]:

  at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

  at System.ServiceModel.ICommunicationObject.Open()

  at Microsoft.Crm.Sandbox.SandboxClientBase`1.Open()

  at Microsoft.Crm.Sandbox.SandboxClientBase`1.get_Proxy()

  at Microsoft.Crm.Sandbox.SandboxCallbackService.ProcessException(Exception e, SandboxSdkClient client)

  at Microsoft.Crm.Sandbox.SandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)

  at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)

  at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [1]:

  at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

  at Microsoft.Crm.Sandbox.ISandboxOrganizationService.Execute(String operation, Byte[] serializedRequest)

  at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)

  at Microsoft.Crm.Sandbox.SandboxOrganizationServiceWrapper.RetrieveMultipleInternal(QueryBase query)

  at RWB2016.Plugins.RibbonCustomisationsPlugin.GetSolutionRecord(LocalPluginContext localContext, String solutionUniqueName)

  at RWB2016.Plugins.RibbonCustomisationsPlugin.GetSolutionDetails(LocalPluginContext localContext, ITracingService trace, String inputData)

  at SparkleXrm.Plugins.Plugin.Execute(IServiceProvider serviceProvider), Correlation Id: 3c465c94-a366-44ea-a659-74084d7275d1, Initiating User: 336f45d2-6ef0-e511-80c0-00155d00f300

Exiting RWB2016.Plugins.RibbonCustomisationsPlugin.Execute(), Correlation Id: 3c465c94-a366-44ea-a659-74084d7275d1, Initiating User: 336f45d2-6ef0-e511-80c0-00155d00f300

Reply
Moin Khan responded on 13 Aug 2018 12:21 AM
My Badges

Hi Scott Durow,

Awesome that helped me a lot

i was toooooooo frustrated why the its not working .. :)

Reply
Suggested Answer

Hi,

It is the look-up to the parent contact that you need to make mandatory on the child entity. This will make the add new create a new record without the look up.

Hope this helps

Reply
Nadeeja Bomiriya responded on 22 Feb 2017 8:23 PM
My Badges
Suggested Answer

Hi Romolo,

+1 for Scott's suggestion.

Since the child record's lookup is mandatory, this field must be populated on creation of a record, which forces CRM to display the New form instead of providing the option to associate an existing record.

Reply
Alagu nellaikumar.S responded on 23 Feb 2017 1:17 PM
My Badges
Suggested Answer

Hi

In  your child entity make parent entity lookup field as mandatory

Reply
Alagu nellaikumar.S responded on 24 Feb 2017 4:42 AM
My Badges
Suggested Answer

without creating lookup how do you have many to many realtionship

Reply
Nadeeja Bomiriya responded on 24 Feb 2017 4:43 AM
My Badges
Suggested Answer

Hi Romolo,

The parent lookup in child entity mandatory rule doesn't apply for N:N relationships.

community.dynamics.com/.../availability-of-add-new-and-add-existing-buttons-in-sub-grids

Reply
Nadeeja Bomiriya responded on 24 Feb 2017 4:47 AM
My Badges
Suggested Answer

Hi Alagu,

If you create a lookup it becomes a 1:N relationship.  You can create a N:N relationship directly. Please see below.

technet.microsoft.com/.../dn531171.aspx

Reply
Alagu nellaikumar.S responded on 24 Feb 2017 4:50 AM
My Badges
Suggested Answer

Hi

What Nadeeja said is correct. N:N lookup only existing button will display if you still want then add custom code to open the entity record in the + button in the subgrid using ribbon work bench

msdn.microsoft.com/.../jj602956.aspx

or

Create the button in the html webresource and open the entity

msdn.microsoft.com/.../jj602956.aspx

Reply

SBX - Two Col Forum

SBX - Migrated JS