My Photo

Microsoft Dynamics 365

Official Blog for Microsoft Dynamics Functional and Technical Solutions....
Browsing Category " ms crm 2015 "

Activate / Deactivate a record using c# in MS CRM 2011 , MS CRM 2013 , MS CRM 2015 ( using SetStateRequest )


hey , as we offensively get requirement to activate and reactivate a record then we start using update event , but there is a very simple method to do so , by using SetStateRequest : it require an assembly " microsoft.crm.sdk.proxy.dll " and using " using Microsoft.Crm.Sdk.Messages;" .
Code will be :
   SetStateRequest req = new SetStateRequest();
             //the entity you want to change the state of
   req.EntityMoniker = new EntityReference("new_abc", recordId);
            //what should the new state be
    req.State = new OptionSetValue(1);
           //Pick an option from the status reason picklist to specify reason for state change
    req.Status = new OptionSetValue(2);
    SetStateResponse resp = (SetStateResponse)service.Execute(req);

Fields that are not valid were specified for the entity - Importing Solution Error mscrm 2011 , mscrm 2013 , mscrm 2015

Hey , I was importing a solution today from an other Organization and got a Error new to me :  Fields that are not valid were specified for the entity , as there was no description i was little confused , but after few R&D came up with perfect resolution of the error .

Reason 

  • Organization "A" conatined attribute 'new_mscrm' that was of type "single line" ,Later  We changed that the field  to be an currency Type.
  • But in Organization "B" was containg same field 'new_mscrm' of type "Single line".
  • When we tried to import back the new solution to test environment we got this Import failure

Get field Name Using JavaScript in ms crm 2011 , ms crm 2013 , ms crm 2015 ( get dynamically field Label using JavaScript)



Hi all below you will find how to get field label name using JavaScript .

 var fieldname = executionContext.getEventSource().getName();
NOTE: Remember to pass context as perimeter while submitting function Name.



SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

Share A Record With Read Only Access Using Custom Workflow IN MS CRM 2011 , MS CRM 2013 , MS CRM 2015

Share a Record to a user without Assigning the record and with out giving Read access to that user , its a Custom Workflow to share a record with read only access , ( NOTE : You can not give read only access to owner of that record so , first we have to change the owner and then we can share it to created by user with read only access )



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Portal;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Workflow;
using System.Activities;
using Microsoft.Crm.Sdk.Messages;


namespace Readonlyaccess_sharerecord
{
    public class Class1 : CodeActivity
    {
        #region input parameter

Get all the Teams of User belong to using JavaScript (xml ) in ms crm 2011 , ms crm 2013 , ms crm 2015



Get all the Teams User belongs to.


var xml = "" +
 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
 GenerateAuthenticationHeader() +
 " <soap:Body>" +
 " <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
 " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">" +
 " <q1:EntityName>team</q1:EntityName>" +
 " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
 " <q1:Attributes>" +

Get Schema Names of the field ( Attribute ) using JavaScript in ms crm


To get the Schema Names of all the attributes or fields in given entity. 

function getSchemaNamesList(entityName) {
 var request = "<Request xsi:type='RetrieveEntityRequest'>" +
               "<MetadataId>00000000-0000-0000-0000-000000000000</MetadataId>" +
               "<EntityItems>IncludeAttributes</EntityItems>" +
               "<LogicalName>" + entityName + "</LogicalName>" +
               "<IsCustomizable>1</IsCustomizable>" +
               "<RetrieveAsIfPublished>true</RetrieveAsIfPublished>" +
               "</Request>";

New JavaScript function for ms crm 2011 , ms crm 2013 and ms crm 2015 , useful JavaScript method for Microsoft dynamics crm


        Below are the few useful properties, commands in ms crm 2011 ms crm 2013 and ms crm 2015 Javascript. You can work with them on form event say OnLoad.

Click on the item below to go through the description about that.
  • Get the string value of a Text field
  • Set the string value of a Text field
  • Retrieve Optionset Value/Text
  • Get the label name of the field
  • Get Lookup field name(value)
  • Get Lookup field ID
  • Get current entity name
  • Get Type Code of lookup
  • Get reference entity name of lookup
  • Set Lookup field
  • Get Event generated field value
  • Get Organization Name
  • Get Organization Language Code
  • Get Server URL
  • Check for Dirty
  • Get GUID of current record
  • Whether the field is disabled or not
  • Get form type
  • Get required fields in the form
  • Save the current record
  • Save the current record
  • Set focus on the field
  • Hide a field on the form
  • Disable(Read only) and Enable a field
  • Close opened window
  • Open Browser Window
  • Get Logged-in User ID
  • Attach Event to control
  • Set Description field in E-mail entity
  • Set IFrame URL
  • Get Schema Names of the Attributes
  • Get Teams of User
  • Filtered Lookup
  • Trigger the Workflow
  • Set field value using query string parameter
  • Change the Status and Status Reason of the record
  • Get the current form name
  • Refresh the form
  • Hide left navigation item
  • Set field requirement level in run time
  • Get Organization URL


NEW JAVASCRIP METHOD FOR MS CRM 2013 AND MS CRM 2015


THERE ARE SOME NEW JAVA SCRIPT METHOD WITH MS CRM 2013 AND 2015 , SOME THEM ARE BELOW :


• Xrm.Page.context.client.getClient() – Returns client type i.e. outlook, web or mobile.
• Xrm.Page.context.client.getClientState() – Returns client state i.e. online or offline.
• Xrm.Page.data.refresh() – This is one interesting as it refreshes the data on the form without even reloading the page. This also enables developers to pass a callback method.
• Xrm.Page.data.save() – Save the form

PREVENT , STOP SAVE FORM OPERATION USING JAVASCRIPT IN MS CRM 2013 (prevent form from save ms crm)

WHEN YOU WANT TO ABORT AN SAVE OPERATION IN MS CRM , WE CAN USE THIS JAVASCRIPT TO STOP SAVE OPERATION IN MS CRM

   context.getEventArgs().preventDefault();

1. FIRST ADD A WEB-RESOURCE PASSING PARAMETER .

function checkbox(context) {

    var innerhtmls = Xrm.Page.ui.tabs.get("{cab6696b-b74a-47a4-b278-fc07fe780565}" ).sections.get( "Sec_IdProof").$1l_0.innerHTML;
    var checkedis = innerhtmls.match( /defaultvalue="1"/g );

Get all types of all input tags from a section using javascript in ms crm 2011, ms crm 2013 , ms crm 2015 ( no of checkbox checked in an section)

This is an Example for checking no of checkbox checked in an section not using jquery ( as jquery will not work in mobile version of ms crm)



function
 checkboxcheck() {   
    var innerhtmls = Xrm.Page.ui.tabs.get("tabname" ).sections.get( "Sectionname").$1l_0.innerHTML;
        // defaultvalue="1" = checked and defaultvalue="0" unchecked 
     var checkedis = innerhtmls.match( /defaultvalue="1"/g );