Wednesday, September 4, 2013

CRM 2011 - Get Fetch in Advanced Find form by javascript

function GetFetch() {
try{
//get FetchXML
var advFind=_mainWindow.$find("advFind"), iOldMode = advFind.get_fetchMode();
var sFetchXml=advFind.get_fetchXml();

//get related information
var FetchXml = sFetchXml;
var LayoutXml= FetchXml.LayoutXml;
var EntityName = FetchXml.EntityName;
var DefaultAdvFindViewId= FetchXml.DefaultAdvancedFindViewId;
var ViewId = FetchXml.QueryId;
var ViewType= FetchXml.QueryObjectType;

//your code
} catch (err) {
                txt = "There was an error on this page.\n\n";
                txt += "Error description: " + err.message + "\n\n";
                txt += "Click OK to continue.\n\n";
                alert(txt);
}

}

Monday, July 8, 2013

MS CRM 2011 - Manage the parent customer field of a contact


The following code set the paterent customer in contact entity. I was unable to find any documentation of this, I hope this will be helpful for you.
// Comment

//for contact entity
EntityReference myRef = null;
myRef= new EntityReference("contact", (Guid)myContact.ContactID); 
if (myRef != null) contactEntity["parentcustomerid"] = myRef; 
// Commit entity to CRMGuid 
Guid result = service.Create(contactEntity);

//for account entity
EntityReference myRef = null;
myRef= new EntityReference("account", (Guid)myContact.AccountID); 
if (myRef != null) contactEntity["parentcustomerid"] = myRef; 
// Commit entity to CRMGuid 
Guid result = service.Create(contactEntity);




Thanks 
Nicola Grillo