Dynamics 365





Monday, August 18, 2014

Inactivate quote usin EntityMoniker Dynamics CRM 2011.

private SetStateRequest inactiveQuote(Entity entSuspect)
        {
            //to set prospect record inactive

            SetStateRequest setState = new SetStateRequest();

            setState.EntityMoniker = new EntityReference();

            //Pass GUID of the record to be activated or Deactivated
            WinOpportunityRequest oppState = new WinOpportunityRequest();
            oppState.OpportunityClose.EntityState = 0;

            setState.EntityMoniker.Id = entSuspect.Id;

            setState.EntityMoniker.Name = "quote";

            setState.EntityMoniker.LogicalName = entSuspect.LogicalName;

            //Setting ‘State’ i.e., (0 – Active ; 1 – InActive)

            setState.State = new OptionSetValue();

            setState.State.Value = 1;

            oppState.Status = new OptionSetValue(3);

            //Setting ‘Status’ i.e., (1 – Active ; 2 – InActive)

            setState.Status = new OptionSetValue();

            setState.Status.Value = 3;


            return setState;
            //
        }

Tuesday, July 29, 2014

Generate proxy file using CrmSvcUtil.exe from command prompt


Generate proxy file using CrmSvcUtil.exe from command prompt sample.
try below command in cmd


C:\Program Files\Microsoft Dynamics CRM\Tools>CrmSvcUtil.exe /url:http://dynamics/ABCdev/XRMServices/2011/Organization.svc /domain:SP /username:murthy /password:xxxxx  /out:c:\CRMSamples\Xrm.cs /namespace:Microsoft.Crm.Sdk.Samples /serviceContextName:XrmServiceContext

Friday, April 18, 2014

CRM 2011 - Hide or Disable Button from ribbon

CRM 2011   Hide or Disable Button from ribbon

 

 Source:http://mscrmshop.blogspot.com/2011/07/step-by-step-hiding-add-existing-button.html

Here are the steps

  • Create a new solution.
  • Add the contact entity to the solution. Do not include any required components or dependent components to the solution.
  • Export the solution and unzip the solution file.
  • Open the customizations file and look for “<RibbonDiffXml>” tag.
  • Replace the <CustomActions /> with
<CustomActions>
  <HideCustomAction Location="Mscrm.SubGrid.contact.AddExistingAssoc" HideActionId="Mscrm.SubGrid.contact.AddExistingAssoc.HideAction" />
  <HideCustomAction Location="Mscrm.SubGrid.contact.AddExistingStandard" HideActionId="Mscrm.SubGrid.contact.AddExistingStandard.HideAction" />
</CustomActions>
  • Save the file.
  • Replace the customizaions.xml file in your zip solution with this file.
  • Import the solution and publish the changes.
Note: Replace the highlighted "contact” text with your entity name. It can be “opportunity” or a custom entity like “new_entity” etc.

 

Monday, January 20, 2014

Set Notification error messsage in CRM 2011


Please try below code instead of alert box it will be displayed on form.

set_Notification(2, 'source', 'Business Phone must contain 10 numbers.');

Tuesday, January 7, 2014

CRM 2011 - change Ribbon Button Name



Change button Name in ribbon - CRM 2011 dynamics.


Hi,
When we have relationship between two entities, the child entity link add to the left navigation of parent.
For example,
  • “Contacts” link add to the left navigation of “Accounts”
Contacts Associated View In Account Contacts Associated View In Account
The view we call it as “Associate View” and it contains buttons with below naming convention
  • “Add {Display name of child}” (i.e., “Add Contact” in above screen)
  • “Add Existing {Display name of child}” (i.e., “Add Existing Contact” in above screen)
To rename the “Add & Add existing” buttons below are the steps
  • Create a new solution
  • Add child entity (i.e., Contact) in above example
  • Export & Save solution in local folder
  • Extract folder and open “Customizations.XML” in Visual Studio
  • Find <RibbonDiffXml><CustomActions> node
  • Add below XML
          <CustomAction Id=”Mscrm.SubGrid.{Entity Name}.AddNewStandard.CustomAction” Location=”Mscrm.SubGrid.{Entity Name}.AddNewStandard” Sequence=”210″>
<CommandUIDefinition>
<!–New Button Id – AddNewStandard; Existing Button Id – AddExistingStandard–>
<Button Id=”Mscrm.SubGrid.{Entity Name}.AddNewStandard
Command=”Mscrm.AddNewRecordFromSubGridStandard”
Sequence=”20″
LabelText=”My Custom Text
Alt=”My Custom Text
Image16by16=”/_imgs/ribbon/NewRecord_16.png” Image32by32=”/_imgs/ribbon/newrecord32.png”
TemplateAlias=”o1″ ToolTipTitle=”Add New Contact”
ToolTipDescription=”$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipDescription” />
</CommandUIDefinition>
</CustomAction>
  • Save, zip & Export solution

 

 

Saturday, December 14, 2013

CRM 2011 - Auto populate values on lookup value selected - json ODATA

On Lookup up change get Account Entity values get auto populated using ODATA JSON script

function retrieveRecord() {

    var odataSetName = "AccountSet";
    debugger;
    var accountLookup = Xrm.Page.getAttribute("pmax_companyname1").getValue();
    if (accountLookup != null) {
        var AccountID = accountLookup[0].id;
    }
    // Get Server URL

    var serverUrl = Xrm.Page.context.getServerUrl();

    var serverUrl = "http://117.218.28.36/pmax-crm";

    //The OData end-point

    var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

    //Asynchronous AJAX function to Retrieve a CRM record using OData
    debugger;
    $.ajax({

        type: "GET",

        contentType: "application/json; charset=utf-8", datatype: "json",

        url: serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "(guid'" + AccountID + "')",

        beforeSend: function (XMLHttpRequest) {

            //Specifying this header ensures that the results will be returned as JSON.

            XMLHttpRequest.setRequestHeader("Accept", "application/json");

        },

        success: function (data, textStatus, XmlHttpRequest) {

            readRecord(data, textStatus, XmlHttpRequest)

        },

        error: function (XmlHttpRequest, textStatus, errorThrown) {

            alert("Error – " + errorThrown)

        }

    });

}

    function readRecord(data, textStatus, XmlHttpRequest) {

    alert("Record read successfully!!");

    var account = data;

    alert("Name – " + account.d.Telephone1);
    alert("Name – " + account.d.WebSiteURL);

    Xrm.Page.getAttribute("pmax_website").setValue(account.d.WebSiteURL);
    Xrm.Page.getAttribute("pmax_website").setSubmitMode("always");

    Xrm.Page.getAttribute("pmax_businessphone").setValue(account.d.Telephone1);
    Xrm.Page.getAttribute("pmax_businessphone").setSubmitMode("always");
  

    }

Thursday, December 12, 2013

Default the Activities 'Filter on' to 'All' for Account and Contact - CRM 2011


Default the Activities 'Filter on' to 'All' for Account and Contact

 

//default the Activities 'Filter on' to 'All' for Account and Contact 

function filterAllActivities() {
    document.getElementById("navActivities").onclick = function () {
        loadArea("areaActivities"); 
        document.getElementById("areaActivitiesFrame").onload = function () {
            var entityName = Xrm.Page.data.entity.getEntityName();
            var entity = entityName.charAt(0).toUpperCase() + entityName.substr(1);
            var doc = this.contentWindow.document;
            var filterOn = doc.getElementById("crmGrid_" + entity + "_ActivityPointers_datefilter"); 
            filterOn.value = "All";
            filterOn.FireOnChange();
        };
    };