Posts

Showing posts from 2016

Age Calculation in CRM

function functionName() {     var CurrentAge = 0;     var Years = 0;     if (Xrm.Page.getAttribute("new_dateofbirth") != null && Xrm.Page.getAttribute("new_dateofbirth").getValue() != null && Xrm.Page.getAttribute("new_age") != null) {         var DateOfBirth = Xrm.Page.getAttribute("new_dateofbirth").getValue();         var birthDate = new Date(DateOfBirth);         var todayDate = new Date();         var todayYear = todayDate.getFullYear();         var todayMonth = todayDate.getMonth();         var todayDay = todayDate.getDate();         var birthYear = birthDate.getFullYear();         var birthMonth = birthDate.getMonth();         var birthDay = birthDate.getDate();         var decrese = false;         var a...

Controlling Fields and Tabs using java script

function controllingFieldsAndTabs() {     debugger;     Xrm.Page.ui.controls.get("parentaccountid").setVisible(false);     //Get the value from a CRM field     var value = Xrm.Page.getAttribute(“CRMFieldSchemaName”).getValue();     //Set the value of a CRM field     Xrm.Page.getAttribute(“CRMFieldSchemaName“).setValue(“New Value”);     //Get the value from a CRM OptionSet field     var value = Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).getValue();     //Get the text from a CRM OptionSet field     var text = Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).getText();     //Set the value of a CRM OptionSet field     Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).setValue(“1”); // OptionSet Value    // Get the selected text of a CRM OptionSet field     Xrm.Page.getAttribute(“CRMOptionSetSchemaName”).getSelectedOption().text; ...

lookup field related data is set to lookup filed in same record

///////////lookup field related data is set in same record///////////// function getCustomerLookupDetails() {     var customerId = null;     var billToId = null;     var shipToId = null;     var customerObject = null;     var billToAddressObj = null;     var shipToAddressObj = null;     //var jobId = Xrm.Page.data.entity.getId();     customerObject = Xrm.Page.data.entity.attributes.get("mtctb_customerid").getValue();     billToAddressObj = Xrm.Page.getAttribute("mtctb_billtoaddress").getValue();     shipToAddressObj = Xrm.Page.getAttribute("mtctb_shiptoaddress").getValue();     if (customerObject != null) {         if (customerObject.length == 0) {             customerObject = null;             return;         }     }     if (billToAddre...

creating view for lookup in ms crm

 var accountId = null;     var APPVersion = null;     try {         APPVersion = APPLICATION_VERSION;     }     catch (e) {         APPVersion = parent.APPLICATION_VERSION;     }     var entityName = Xrm.Page.data.entity.getEntityName();     if (entityName == "account" || enityName == "contact") {         var accountObj = Xrm.Page.getAttribute("mtctb_accountid").getValue();     }     if (accountObj != null) {         if (accountObj.length == 0) {             accountObj = null;             return;         }         accountId = accountObj[0].id.replace("{", "").replace("}", "");     }     if (accountId != null) {         var viewId = "{00000000-0000-0000-000...

Create Button in CRM Form without a Field using Javascript

///http://missdynamicscrm.blogspot.in/2015/06/create-button-in-crm-form-javascript.html function btncal() {     createButton(id, defaultText, intWidth, onClickEventFunctionName); } function createButton(id, defaultText, intWidth, onClickEventFunctionName) {     debugger;     var btn = document.createElement("BUTTON");     // Create a <button> element, you can also use input,but need to set type to button     var t = document.createTextNode(defaultText);     btn.appendChild(t);     btn.className = "ms-crm-Button";     btn.id = id;     if (intWidth != null) {         btn.style.width = intWidth + "px";     }     else {         //defaulted width         btn.style.width = "100%";     }     btn.onmouseover = onCRMBtnMouseHover;     btn.onmouseout = onCRMBtnMouseOut...

Java Script Code Reference MS CRM

Javascript Code Reference Topics for CRM Get value from a CRM field var temp = Xrm.Page.getAttribute("CRMFieldSchemaName").getValue(); Set value of a CRM field Xrm.Page.getAttribute("CRMFieldSchemaName").setValue('My New Value'); Get Guid of current entity var id = Xrm.Page.data.entity.getId(); Hide a tab in a CRM Form Xrm.Page.ui.tabs.get(5).setVisible(false); or Xrm.Page.ui.tabs.get("tab_5").setVisible(false); Show a tab in a CRM Form Xrm.Page.ui.tabs.get(5).setVisible(true); or Xrm.Page.ui.tabs.get("tab_5").setVisible(true); Hide a section in a CRM Form Xrm.Page.ui.tabs.get("tab_5").sections.get("tab_5_section_2").setVisible(false); Show a section in a CRM Form Xrm.Page.ui.tabs.get("tab_5").sections.get("tab_5_section_2").setVisible(true); Stop AutoSave //Stop Auto Save var saveEvent = context.getEventArgs(); if (saveEvent.getSaveMode(...

Sample CRUD Operations Using C# in MSCRM

Sample CRUD Operations Using C# in MSCRM Steps to Achieve: Create a console Application in Visual Studio and add (Microsoft.Crm.Sdk.Proxy.dll, Microsoft.Xrm.Sdk.dll) in references section. Download this C# Class files to get crm service ,If you have this files just skip this step https://www.dropbox.com/s/pyj6zym6u9ea7wp/deviceidmanager.cs?dl=0 https://www.dropbox.com/s/q82xp39jn0nqi0j/OnlineService.cs?dl=0 Open OnlineService.cs file and enter your crm credentials as shown below            ClientCredentials credentials = new ClientCredentials();             credentials.UserName.UserName = "Username@Domain.onmicrosoft.com";//Username             credentials.UserName.Password = "yourpasswordhere";//Password             var _servproxy = new OrganizationServiceProxy(new     Uri("https://Domain.api.crm5.dynamics.com/XRMServices/2011/Organization.svc"), n...