Monday, May 2, 2016

Bulk Create in MSCRM 2015 Plugins

Hi All,

Please find the below Script to Bulk Update Records. In My Scinario am having Entity1 and Entity2 entities.
If i update Entity1 Status Entity2 Status also should get update with the same Status.

Code:

 ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest()
                    {                    
                        Settings = new ExecuteMultipleSettings()
                        {
                            ContinueOnError = true,
                            ReturnResponses = true
                        },
                        Requests = new OrganizationRequestCollection()
                    };

QueryExpression qe = new QueryExpression(Entity2);
qe.ColumnSet = new ColumnSet(true);
qe.Criteria.AddCondition(new ConditionExpression("Entity1id", ConditionOperator.Equal, {GUID OF Entity1} ));
EntityCollection collectAllValues = service.RetrieveMultiple(qe);

 foreach (Entity loopCollectedValues in collectAllValues.Entities)
            {
                Entity getAllrecords = new Entity("Entity2");

                getAllrecords.Id = Entity2.Id;

               getAllrecords.Attributes["new_status"] = new OptionSetValue(((Microsoft.Xrm.Sdk.OptionSetValue)((postImageEntity.Attributes["new_status"]))).Value);

                CreateRequest createRequest = new CreateRequest { Target = getAllrecords  };

                requestWithResults.Requests.Add(createRequest);
            }

ExecuteMultipleResponse responseWithResults =
(ExecuteMultipleResponse)_service.Execute(requestWithResults);
if (responseWithResults.IsFaulted)
                        {
foreach (var responseItem in responseWithResults.Responses)
                            {
                                if (responseItem.Response != null) { }
                                if (responseItem.Fault != null) { }                        
                            }
                        }

Bulk Update Records in CRM 2015

Hi All,

Please find the below Script to Bulk Update Records. In My Scinario am having Entity1 and Entity2 entities.
If i update Entity1 Status Entity2 Status also should get update with the same Status.

Code:

 ExecuteMultipleRequest requestWithResults = new ExecuteMultipleRequest()
                    {                      
                        Settings = new ExecuteMultipleSettings()
                        {
                            ContinueOnError = true,
                            ReturnResponses = true
                        },
                        Requests = new OrganizationRequestCollection()
                    };

QueryExpression qe = new QueryExpression(Entity2);
qe.ColumnSet = new ColumnSet(true);
qe.Criteria.AddCondition(new ConditionExpression("Entity1id", ConditionOperator.Equal, {GUID OF Entity1} ));
EntityCollection collectAllValues = service.RetrieveMultiple(qe);

 foreach (Entity loopCollectedValues in collectAllValues.Entities)
            {
                Entity getAllrecords = new Entity("Entity2");

                getAllrecords.Id = Entity2.Id;

               getAllrecords.Attributes["new_status"] = new OptionSetValue(((Microsoft.Xrm.Sdk.OptionSetValue)((postImageEntity.Attributes["new_status"]))).Value);

                UpdateRequest updateRequest = new UpdateRequest { Target = getAllrecords };

                requestWithResults.Requests.Add(updateRequest);
            }

ExecuteMultipleResponse responseWithResults =
(ExecuteMultipleResponse)_service.Execute(requestWithResults);
if (responseWithResults.IsFaulted)
                        {
foreach (var responseItem in responseWithResults.Responses)
                            {
                                if (responseItem.Response != null) { }
                                if (responseItem.Fault != null) { }                        
                            }
                        }

Wednesday, April 27, 2016

Dependencies of Managed Solution MSCRM

Hi,

Please find the below link to find out the dependencies of CRM Managed Solutions

http://{Your Server Name}/{Your Organization name}/tools/dependency/dependencyviewdialog.aspx?objectid={Solution Guid }&objecttype=7100&operationtype=dependenciesforuninstall#

Tuesday, April 12, 2016

Get all User's from Team MSCRM CRM 2013

Hi All,

Please find the below Fetch XML code to fetch all the users from team

function onload()
{
var getUserJS = Xrm.Page.context.getUserId();
getUserJS = getUserJS.replace(/[{}]/g, "");
getUserJS = getUserJS.toLowerCase();
var getusesfromTeam = getUsers(pass Team Id);
if (getusesfromTeam.length > 0) {
for (var getOwningUsers = 0; getOwningUsers < getusesfromTeam.length; getOwningUsers++) {
if (getOwningTeamusers[getOwningUsers].attributes.systemuserid.value == getUserJS) {
return true
         }
     }
   }
}

function getUsers(teamid) {
    var GetUsers = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>" +
  "<entity name='systemuser'>" +
    "<attribute name='fullname' />" +
    "<attribute name='businessunitid' />" +
    "<attribute name='title' />" +
    "<attribute name='mobilephone' />" +
    "<attribute name='systemuserid' />" +
    "<attribute name='positionid' />" +
    "<order attribute='fullname' descending='false' />" +
    "<link-entity name='teammembership' from='systemuserid' to='systemuserid' visible='false' intersect='true'>" +
      "<link-entity name='team' from='teamid' to='teamid' alias='ac'>" +
        "<filter type='and'>" +
          "<condition attribute='teamid' operator='eq' value='" + teamid + "' />" +
        "</filter>" +
      "</link-entity>" +
    "</link-entity>" +
  "</entity>" +
"</fetch>";

    var OwningUsers = XrmServiceToolkit.Soap.Fetch(GetUsers);
    return OwningUsers;
}

Monday, April 11, 2016

RoleService:VerifyCallerPrivileges failed. PrivilegeName: prvMerge error in CRM 2015

Hi All,

I was getting the below error when I was trying to import a team. while importing am getting am error like  "RoleService::VerifyCallerPrivileges failed. User: , PrivilegeName: prvMerge, PrivilegeId: , Depth: Global, BusinessUnitId: "

Fix:

Provide access to the "Merge" entity to the security role whom the current user belongs to


Friday, April 8, 2016

How to restore Button's in MSCRM

Hi All,

Please find the below steps to restore all the Entity Ribbon in Custom or OOB entity


    1. Create a solution that just includes the entity with the button that isn’t working correctly and export from CRM.
    2.Extract the customization zip file.
    3.Open the customization.xml file in the editor of your choice.
    4.Search for RibbonDiff.
    5.Replace the entire <RibbonDiff> section with the following:

<RibbonDiffXml>
  <CustomActions />
  <Templates>
    <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
  </Templates>
  <CommandDefinitions />
  <RuleDefinitions>
    <TabDisplayRules />
    <DisplayRules />
    <EnableRules />
  </RuleDefinitions>
  <LocLabels />
</RibbonDiffXml>

      6.Then Save it.
      7.Compress the Folder and import it to the Organization.
      8.Publish all Customization.

Friday, April 1, 2016

Hide Subgrid + Button For Attachment in Email Entity Etc

Hi all,

I have got a requirement to hide + new button for Attachment in Sub-Grid. Please find the code to achieve the same

Javascript:

        setTimeout(function () {
            if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("attachmentsGrid") != null && Xrm.Page.getControl("attachmentsGrid") != undefined) {
                document.getElementById("attachmentsGrid_contextualButtonsContainer").style.display = "none";
            }
        }, 500);

We can use the above code to hide all the Subgrid + Button. You need to replace "attachmentsGrid" as your Subgrid name to achieve the same.

How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...