Thursday, January 20, 2011

saving another entity form from one form

Suppose we want to put an entity record in another entity form and on change of anything in the parent we also want to put the value in the child record and also want to save that. This can be done :)

var iframe = crmForm.all.IFRAME_CustomEntity
var iDoc = iframe.contentWindow.document;
var iframe_isSaved = true;

// checking if the Custom Entity has been changed
if (iDoc.crmForm.IsDirty())
{
// save Custom Entity
var iframe_isSaved = iDoc.crmForm.Save();
}

if (iframe_isSaved == false) // validation failed on Custom entity
{
event.returnValue = false; // Cancel the SAVE on Account
return false;
}

Just test and see.

No comments:

Post a Comment