Wednesday 12 August 2015

subgrid rows color change in crm 2015

hi

this is for how we will retrieve subgrid data..

first create one entity and place it as subgrid in another entity

take the name of it.here "voter"

use the following code in main form onload.

function getVoterEligibility() {
    debugger;
    // var grid = document.getElementById("voter");
    var grid = Xrm.Page.getControl("voter").getGrid();
    if (grid == null) {
        setTimeout(function () { getVoterEligibility(); }, 2000); //if the grid hasn’t loaded run this again when it has
        return;
    }

    var totalCount = grid.getTotalRecordCount();
    if (typeof totalCount == "number" && totalCount == 0) {
        setTimeout(getVoterEligibility, 1000, "voter");
        return;
    }
    else if (totalCount > 0) {
        grid.getRows().forEach(function (row, index) {

            var rowData = row.getData();
            // $(rowData).css("background-color", "green")
            if (rowData != null) {

                var rowDataRef = rowData.getEntity().getEntityReference();
                var id = rowDataRef.id;
                var name = rowDataRef.name;
                //  alert(name);
                var entityType = rowDataRef.entityType; //contact
                //get entity
                var entity = rowData.getEntity();

                if (entity != null) {
                    //get primary attribute value
                    var entityPrimaryAttrValue = entity.getPrimaryAttributeValue();
                    //get subgrid record entity name
                    var entityName = entity.getEntityName();
                    //get entity Id
                    var entityId = entity.getId();
                    //get attributes displayed on subgrid row
                    var entityAttrbs = entity.getAttributes();
                    //   var agevalue = entityAttrbs.get(1).getValue();

                    if (entityAttrbs.get(1).getValue() <= 20) {



                        $(grid.$3_1._element).find("tr[oid='" + id + "']").each(function () {
                            $(this).css("background-color", "green");

                        });



                    }

                    else {


                        $(grid.$3_1._element).find("tr[oid='" + id + "']").each(function () {
                            $(this).css("background-color", "Yellow");

                        });

                    }
                    //get entity reference
                    var entityRef = entity.getEntityReference();
                }

            }
        });
    }

}

Tuesday 5 May 2015

Colors of data based on the values in Dashboard crm 2013


here we want to show the font colors based on the values.. Low , High, Medium .. like..




for this:
step 1 : need to create one HTML web resource..
and add it to here.

before creating the HTML need to check the dependent files are there or not..


download and add the .js files as webresources..

then use the below code.

follow the exact order of referenced files:

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>
    <meta charset="utf-8">
    <title></title>

</head><body>
        
      <!--  <script type="text/javascript" src="usmc_solutions/jquery.js"></script>
    <script type="text/javascript" src="usmc_solutions/XrmServiceToolkit.js"></script>
    <script type="text/javascript" src="usmc_solutions/json2.js"></script>-->
    
    <script type="text/javascript" src="hp_/Scripts/json2.js"></script>
    <script type="text/javascript" src="hppscm_/Scripts/JQueryLibrary.js"></script>
    <script type="text/javascript" src="hppscm_/Scripts/XrmServiceToolkitSOAP.js"></script>
    
      <style>
        .signout a:link {
            font-weight:normal;
            color:red;
        }

        .signin a:link {
            font-weight:bold;
            color:green;
        }
    </style>
       
    <table style="width: 100%;" id="myTable">
     
    </table>
  
        
    <script type="text/javascript">
        debugger;
        var varray = "";
        retireveSystemParameters();
       

        function retireveSystemParameters() {
            //retrieve records from system parameters.
            var _fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
                "<entity name='usmc_alert'>" +
                "<attribute name='usmc_alertid' />" +
                "<attribute name='usmc_priority' />" +
                "<attribute name='usmc_name' />" +
                "<attribute name='createdon' />" +
                "<order attribute='usmc_name' descending='false' />" +
                "</entity>" +
                "</fetch>";


            var FetchData = XrmServiceToolkit.Soap.Fetch(_fetchXML);
           
            var strURL = XrmServiceToolkit.Soap.GetServerURL();

            var entityname = "usmc_alert";

            if (FetchData != null) {

                var table = document.getElementById("myTable");

                var row = table.insertRow(0);
                var cell1 = row.insertCell(0);
                var cell2 = row.insertCell(1);
                cell1.innerHTML = "Name";

                cell2.innerHTML = "Priority";




                for (var i = 0; i < FetchData.length; i++) {

                    //  var table = document.getElementById("myTable");
                    row = table.insertRow(i + 1);
                    cell1 = row.insertCell(0);
                    cell2 = row.insertCell(1);
                    var names = FetchData[i].attributes.usmc_name.value;
                    var alertGuid = FetchData[i].attributes.usmc_alertid.value;
                    var Priority = FetchData[i].attributes.usmc_priority.formattedValue;
                    //  var urllink = "http://win-qctbmlihah0:5555/newtest/userdefined/edit.aspx?etc=10009&id=%7b"+alertGuid+"%7d";
                    //   var urllink = strURL + "/userdefined/edit.aspx?etc=10009&id=%7b" + alertGuid + "%7d";

                    var urllink = strURL + "/main.aspx?etc=10009&extraqs=%3f_gridType%3d10009%26etc%3d10009%26id%3d%257b" + alertGuid + "%257d%26rskey%3d%257b426407F0-4582-44F9-8D96-6EAF20E2F5BE%257d&pagemode=iframe&pagetype=entityrecord&rskey=%7b426407F0-4582-44F9-8D96-6EAF20E2F5BE%7d";
                    //  var urllink = strURL + "/main.aspx?etc=10086&extraqs=%3f_gridType%3d10086%26etc%3d10086%26id%3d%257b" + alertGuid + "%257d%26rskey%3d%257b426407F0-4582-44F9-8D96-6EAF20E2F5BE%257d&pagemode=iframe&pagetype=entityrecord&rskey=%7b426407F0-4582-44F9-8D96-6EAF20E2F5BE%7d"; 

                    //   cell1.innerHTML = '<a id="nv" href ="' + urllink + '" style="text-decoration:none;" style="color:red" name="link">' + names + '</a>';
                    cell2.innerHTML = Priority;
                    //  table.cell1.href = "http://www.google.com";
                    if (cell2.innerHTML == 'High') {

                        document.getElementById("myTable").rows[i + 1].style.color = "#ffd700";
                        cell1.innerHTML = '<a id="nv" href ="' + urllink + '" style="color:#ffd700;text-decoration:none;" name="link">' + names + '</a>';
                        //  document.getElementById("myTable").rows[i + 1].style.backgroundColor = "#FFCC99";
                        //document.getElementById("nv").link.style.color = "red";
                    }
                    if (cell2.innerHTML == 'Low') {

                        cell1.innerHTML = '<a id="nv" href ="' + urllink + '" style="color:green;text-decoration:none;" name="link">' + names + '</a>';
                        //   document.getElementById("myTable").rows[i + 1].style.backgroundColor = "#99FF99";
                        document.getElementById("myTable").rows[i + 1].style.color = "green";

                    }
                    if (cell2.innerHTML == 'Critical') {

                        cell1.innerHTML = '<a id="nv" href ="' + urllink + '" style="color:red;text-decoration:none;" name="link">' + names + '</a>';
                        // document.getElementById("myTable").rows[i + 1].style.backgroundColor = "#FFFFCC";
                        document.getElementById("myTable").rows[i + 1].style.color = "red";
                    }
                    if (cell2.innerHTML == 'Informational') {

                        cell1.innerHTML = '<a id="nv" href ="' + urllink + '" style="color:bule;text-decoration:none;" name="link">' + names + '</a>';
                        // document.getElementById("myTable").rows[i + 1].style.backgroundColor = "#99CCFF";
                        document.getElementById("myTable").rows[i + 1].style.color = "bule";
                    }

                }


            }

        }
        function GetObjectTypeCode(entityName) {
            try {
                var lookupService = new RemoteCommand("LookupService", "RetrieveTypeCode");
                lookupService.SetParameter("entityName", entityName);
                var result = lookupService.Execute();

                if (result.Success && typeof result.ReturnValue == "number") {
                    return result.ReturnValue;
                }
                else {
                    return null;
                }
            }
            catch (ex) {
                throw ex;
            }
        }

        </script>

    
</body></html>


step 2: add this webresource to the Dashboard

changes : check the URL for redirect.

Wednesday 18 March 2015

SSRS Dates

hi

if we want to change the DateTime to Short date.. we will get null value as 01/01/0001
this is default value of Date.

need to use IIF condition for this.

=iif(isnothing(Fields!Confirmed_Check_In_Date.Value),"",FormatDateTime(Fields!Confirmed_Check_In_Date.Value, DateFormat.ShortDate))

Thursday 12 March 2015

simple plug-in in crm 2013

for the simple plugin..

just open the class library:

add the required references

add the below code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using  Microsoft.Xrm.Sdk;
using  Microsoft.Xrm.Client;
using  Microsoft.Crm.Sdk.Messages;

namespace NamePlugin
{
    public class Class1 : IPlugin
    {
        public IOrganizationService service;
        public IPluginExecutionContext context;

        public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)
            serviceProvider.GetService(typeof(IPluginExecutionContext));

            Entity entity;

            // Check if the input parameters property bag contains a target
            // of the create operation and that target is of type Entity.
            if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
            {

                // Obtain the target business entity from the input parameters.
                entity = (Entity) context.InputParameters["Target"];

                string firstname = entity.Attributes["new_name"].ToString();
                string secondname = entity.Attributes["new_name1"].ToString();
                string fullname = firstname + " " + secondname;
                entity.Attributes["new_name2"] = fullname;
            }

        }
    }
}

this is simple and register it in per-operation



Wednesday 11 March 2015

Enable trace in CRM

how to enable trace services in Dynamic CRM

first

in run .. regedit


then navigate to the