Read this article
http://www.inogic.com/blog/2012/06/how-to-debug-plugins-using-profiler/
http://www.inogic.com/blog/2012/06/how-to-debug-plugins-using-profiler/
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="quote">
<attribute name="owneridname" />
<attribute name="customerid" />
<attribute name="quotenumber" />
<attribute name="totalamount" />
<attribute name="discountpercentage" />
<attribute name="totallineitemamount" />
<attribute name="quoteid" />
<attribute name="modifiedon" />
<attribute name="new_billtoaddress" />
<attribute name="new_shiptoaddress" />
<attribute name="new_termsconditions" />
<attribute name="new_projectname" />
<attribute name="new_contactphonecell" />
<attribute name="new_fax" />
<attribute name="discountamount" />
<attribute name="new_properties" />
<attribute name="new_quoteapprovedbygm" />
<attribute name="new_salesconsultant" />
<filter type="and">
<condition attribute="quoteid" operator="eq" uitype="quote" value="@QuoteId" />
</filter>
<link-entity name="quotedetail" from="quoteid" to="quoteid" alias="am" link-type="outer">
<attribute name="productid" alias="am_productidname"/>
<attribute name="priceperunit" alias="am_priceperunit"/>
<attribute name="quantity" alias="am_quantity"/>
<attribute name="extendedamount" alias="am_extendedamount"/>
<attribute name="productdescription" alias="am_proddescription"/>
<attribute name="new_properties" alias="am_properties"/>
<attribute name="manualdiscountamount" alias="am_manualdiscountamount"/>
<attribute name="new_discount" alias="am_discountPercentage"/>
<link-entity name="product" from="productid" to="productid" alias="an">
<link-entity name="annotation" from="objectid" to="productid" alias="ao">
<attribute name="subject" />
<attribute name="notetext" />
<attribute name="filename" />
<attribute name="documentbody" />
<attribute name="annotationid" />
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +
"<entity name='email'>" +
"<attribute name='subject' />" +
"<order attribute='subject' descending='false' />" +
"<attribute name='to' />" +
"<attribute name='from' />" +
"<attribute name='createdon' />" +
"<attribute name='activityid' />" +
"<link-entity name='activityparty' from='activityid' to='activityid' alias='ad'>" +
"<link-entity name='contact' from='contactid' to='partyid' alias='ae'>" +
"<link-entity name='new_account_contact' from='contactid' to='contactid' visible='false' intersect='true'>" +
"<filter type='and'>" +
"<condition attribute='accountid' uitype='account' value='" + accountid + "' operator='eq'/>" +
"</filter>" +
"</link-entity>" +
"</link-entity>" +
"</link-entity>" +
"</entity>" +
"</fetch>";
function dynamicallyFilterSubGrid() {
var objSubGrid = window.parent.document.getElementById("RelatedContactEmails");
//CRM loads subgrid after form is loaded.. so when we are adding script on form load.. need to wait unitil subgrid is loaded.
// thats why adding delay..
if (objSubGrid == null) {
setTimeout(dynamicallyFilterSubGrid, 2000);
return;
}
else {
if (objSubGrid.control != null) {
var accountid = Xrm.Page.data.entity.getId();
var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +
"<entity name='email'>" +
"<attribute name='subject' />" +
"<order attribute='subject' descending='false' />" +
"<attribute name='to' />" +
"<attribute name='from' />" +
"<attribute name='createdon' />" +
"<attribute name='activityid' />" +
"<link-entity name='activityparty' from='activityid' to='activityid' alias='ad'>" +
"<link-entity name='contact' from='contactid' to='partyid' alias='ae'>" +
"<link-entity name='new_account_contact' from='contactid' to='contactid' visible='false' intersect='true'>" +
"<filter type='and'>" +
"<condition attribute='accountid' uitype='account' value='" + accountid + "' operator='eq'/>" +
"</filter>" +
"</link-entity>" +
"</link-entity>" +
"</link-entity>" +
"</entity>" +
"</fetch>";
objSubGrid.control.SetParameter("fetchXml", FetchXml);
objSubGrid.control.Refresh();
}
else {
setTimeout(dynamicallyFilterSubGrid, 2000); // this setTimeout function is necessay because first objSubGrid.control is null
}
}
}
function DeleteAccount() {
//get Server url
var serverURL = Xrm.Page.context.getClientUrl();
//create Xml request object
var service = new XMLHttpRequest();
//below line is used to delete the entity record
service.open("DELETE", serverURL + "/api/data/v8.0/accounts(1DD18913-11CB-E511-80D2-C4346BDC11C1)", false);
service.setRequestHeader("Accept", "application/json");
service.setRequestHeader("Content-Type", "application/json; charset=utf-8");
service.setRequestHeader("OData-MaxVersion", "4.0");
service.setRequestHeader("OData-Version", "4.0");
service.send();
if (service.readyState == 4 /* complete */) {
if (service.status == 204) {
//show alert message
alert('Field Value Deleted');
}
else {
var error = JSON.parse(service.response).error;
//show error message
alert(error.message);
}
}
}
function UpdateAccount() {
var serverURL = Xrm.Page.context.getClientUrl();
var account = {};
account["name"] = "Create record Web API Example"; //set single line of text field
account["address1_city"] = "Islamabad";//set single line of text field
//Lookup
account["primarycontactid@odata.bind"] = "/contacts(0D7AFC02-891C-E611-80E1-5065F38B0371)"; //setting existing lookup
//Below code will create contact on fly and set in primarycontact
//account["primarycontactid"] = {
// "firstname": "Mahender",
// "lastname": "Pal"
//};
//optionset
account["industrycode"] = 1; // set optionSet field
//two options
account["donotphone"] = true; //set boolean field
//number
account["numberofemployees"] = 20;//set whole no field
//date time
//account["him_approvaldate"] = new Date();
var req = new XMLHttpRequest();
req.open("PATCH", serverURL + "/api/data/v8.0/accounts(1DD18913-11CB-E511-80D2-C4346BDC11C1)", false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.send(JSON.stringify(account));
if (req.readyState == 4 /* complete */) {
if (req.status == 204) {
} else {
}
}
}
function CreateAccount() {
var serverURL = Xrm.Page.context.getClientUrl();
var account = {};
account["name"] = "Create record Web API Example"; //set single line of text field
account["address1_city"] = "Islamabad";//set single line of text field
//Lookup
account["primarycontactid@odata.bind"] = "/contacts(0D7AFC02-891C-E611-80E1-5065F38B0371)"; //setting existing lookup
//Below code will create contact on fly and set in primarycontact
//account["primarycontactid"] = {
// "firstname": "Mahender",
// "lastname": "Pal"
//};
//optionset
account["industrycode"] = 1; // set optionSet field
//two options
account["donotphone"] = true; //set boolean field
//number
account["numberofemployees"] = 20;//set whole no field
//date time
//account["him_approvaldate"] = new Date();
var req = new XMLHttpRequest();
req.open("POST", serverURL + "/api/data/v8.0/accounts", false);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.send(JSON.stringify(account));
if (req.readyState == 4 /* complete */) {
if (req.status == 204) {
var accountUri = this.getResponseHeader("OData-EntityId");
var ID = accountUri.substr(accountUri.length - 38).substring(1, 37); //get only GUID
// Xrm.Utility.openEntityForm("account", ID); //Open newly created account record
} else {
var error = JSON.parse(req.response).error;
alert(error.message);
}
}
}
Below line is used to make field readonly in power app portal through js $( "#bdo_relationshiprole_name" ).parent().css( "po...