locked
CRM Online - How to prevent an Account to be saved without an associated Contact? RRS feed

  • Question

  • Does anyone know what I could do to prevent an Account to be saved without an associated record, for example, a Contact, or another custom entity in a N:N relationship? Is this possible via JScript? I know how to do it with fields, I mean, it is possible to make them requied out of the box, but how about records?

    Thanks.

    Thursday, February 14, 2013 12:27 PM

All replies

  • Hi,

    If i undestand your essential question you want check if a subgrid has rows, check next code:

    function ExistsRows() 
    {
    	var gridControl = document.getElementById(subGridName).control;
    
    	if (gridControl.getRecordsFromInnerGrid().length == 0) 
    	{
    		alert("Fill Contacts");
    		Xrm.Page.context.getEventArgs().preventDefault();
    		
    	}
    }
    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.


    Pedro Azevedo Crm Specialist 4.0\2011

    Thursday, February 14, 2013 2:16 PM
  • Hi Pedro,

    I would like to try this code, but it looks like CRM 4.0 code, am I right?

    Thanks.

    Thursday, February 14, 2013 3:52 PM
  • Hi Elvis,

    This is CRM 2011 code, to get reference to a subgrid is like that. Check more information here.

    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.


    Pedro Azevedo Crm Specialist 4.0\2011


    Thursday, February 14, 2013 4:16 PM