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>";