Posts

Showing posts from 2014

Create WCF service and use it to retreive data from Dynamics CRM

Image
1. Open Visual Studio and Select WCF service application.



2. Open IService1.cs and add following code::

namespace WcfServiceCRM
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        Account[] getAccountDetails();

        // TODO: Add your service operations here
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class Account
    {
        string fullname;
        string companyname;
        string telephone;

        [DataMember]
        public string FullName
        {
            get { return fullname; }
            set { fullname = value; }
        }

        [DataMember]
        public string CompanyName
        {
            get { return companyname; }
            set { …

Manipulate date fields by adding or subtacting days to a DateTime fields in Microsoft Dynamics CRM using workflow activity

Image
Source: ManipulationLibrary

In this blog I am going to explain how to manipulate a date field in Dynamics CRM 2013 using plugin workflow activity.

This workflow allows days to be added/ subtracted to date field in CRM.






1. For creating this Workflow activity using plugin Open Visual studio and just proceed similarly as you do for creating any plugin i.e add necessary references, etc.

2. Now add a class file for and name it accordingly and add below code for Adding days to date::

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;

namespace AddSubtractDate
{
    public sealed class AddDays : CodeActivity
    {
        protected override void Execute(CodeActivityContext executionContext)
        {
            var result = new DateTime();
            var start = StartDate.Get<DateTime>(executionContext);

            if (start != DateTim…

Create Nested Gridview with Expand and Collapse features in ASP.Net

Image
In this blog, I am going to show how we could create a nested gridview i.e gridview inside another gridview. The feature of this nested group is that the sub-grid will be hidden by default and when user clicks on "+" sign provided in Main gridview the subgrid will be shown to the user and "+" sign gets converted to "-" sign and again if user click "-" sign the subgrid gets hidden. The motive behind this is to show the detailed specification of particular record on click of button instead showing all records in a single grid.

Additionally a small javascript has been used inside this code for attractive warning message, you may ignore that portion.


First of all, add the below code inside the .aspx code window::

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NestedGridview.aspx.cs" Inherits="NestedGridview" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:…

ConditionExpression operators and aggregation used in FetchXML while using c# for Microsoft Dynamics CRM 2013

This blog contains the whole list of COndition operators used in FetchXMl and the aggregation used in FetchXML while using C#

Source: MSDN

Here is a list of all ConditionalOPerator and the second table contains the list of aggregation used in FetchXML::

ConditionOperatorFetchXML OperatorDescriptionBeginsWithlikeThe string occurs at the beginning of another string.BetweenbetweenThe value is between two values.ContainslikeThe string contains another string.DoesNotBeginWithnot-likeThe string does not begin with another string.DoesNotContainnot-likeThe string does not contain another string.DoesNotEndWithnot-likeThe string does not end with another string.EndsWithlikeThe string ends with another string.EqualeqThe values are compared for equality.EqualBusinessIdeq-businessidThe value is equal to the specified business ID.EqualUserIdeq-useridThe value is equal to the specified user ID.EqualUserTeamseq-userteamsThe record is owned by teams that the user is a member of.GreaterEqualgeThe value…

ShowModalDialog of javascript is not closing from ASP Code behind and opens a new pop up of same page

Introduction: What is and why to use SHowModalDialog : 

In Many application, many of popups are implemented using window.showmodaldialog which restricts user to finish work on popup before changing focus to any other part of application.  For exaple just try to shut down your Smartphone and you will be prompt with a message that will force you to confirm your decision which probably uses ModalPopUp. It freezes everything in backgrund and without getting any input from your side it doesn't allow you to change something in background page.
Issue :
Generally an issue comes that while using ShowModalDialog of javascript doesn't closes from ASP Code behind and opens a new pop up of same page. To solve this issue just add <base target="_self"/> in <head> tag. Below I have shown an example how to use a ShowModalDialog and close it.
<headrunat="server"> <basetarget="_self"/> <title></title> </head>
protectedvoid ButtonC…

Send Email(With Image) from Plugin on Post Operation of an entity in Microsoft Dynamics CRM

Image
In this blog I am going to explain how to send Email to User in CRM from Plugin.

1. Add image url properly if you want to add image inside mail body like below::
     string crmModule = "<html> <img  src='http://1.bp.blogspot.com/-OZdI4vK6hT4/U8-uNZYO99I/AAAAAAAAAro/ehRveHHRgt0/s1600/1032510.png'  width='150' height='150'></html>";

   Or,

  Alternatively, You can also Display Image Which are Created in CRM as Web Resource. Upload your image as Web resource in Crm and Copy paste the URl available in webresource string as I did below.
     string webresource = "<html> <img  src='~/WebResources/new_Crm'  width='205' height='150'></html>";

2. Add necessary referances to your solution.

3. Now, add code like below for sending Email on Post Creation of new Lead

4. Don't forgot to register your plugin message: Create

5. Primary Entity: Lead (Or select whatever you want. Here i have us…

Secure Connection String when using data source control i.e Encrypt/ Decrypt the connection string in Web.config file.

Image
In this blog, i am going to explain how to encrypt/ decrypt the Connection Strings in web.config file in Asp.Net

Encrypt connectionString
Step 1:: Goto Visual Studio Developer Command Prompt
 Goto --> C:\Windows\System32\cmd.exe
 Then type--> cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
Step 2:: Now type following command ::

       aspnet_regiis -pef connectionStrings "e:\aayush singh\CRM2013reportsext\CRMwebPortal" -prov DataProtectionConfigurationProvider

Here –pef indicates that the application is built as File System website. Second argument connectionStrings indicates that name of the configuration section needs to be encrypted. The Third argument is the physical path of the folder where the web.config file is located.

Step 3:: After enter the command click enter if everything goes well you get a success message like “Encrypting configuration section… Succeeded!” [See below the screenshot]




Step 4:: Now, goto your solution check your connectionString in web.con…

Connect to Microsoft Dynamics CRM 2013 online using C#

In this blog, I am going to explain how to create connection with Online Microsoft Dynamics CRM and how to fetch data of CRM using C#.

Fetch records from online crm entity using c#. First of all add required references and add few important namespaces :

using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Client.Services;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk.Messages;

Now, for creating connection with Online dynamics CRM 2013, add below code inside your class with your URL, UserName and Password of your Online Dynamics CRM .

OrganizationService _orgservice = new OrganizationService(CrmConnection.Parse("Url=https://YourURLname.crmX.dynamics.com; Username=user.name@YourSolName.onmicrosoft.com; Password=YourPassword;"));

Now, for retrieving records from your online CRM for any entity get the fetchXML by using AdvancedFind and use that fetchXML here f…

SSRS total pages number error. (Adds a Question mark(?) after total page number in SSRS report)

Image
Paging Issue in SSRS Report adds a question mark instead of display the total number of pages

In this blog i am going to give the solution how to solve this problem. Generally the problem could be like below:

Suppose we have one report deployed on ssrs 2008, it shows on view report
1 of 2? or 2 of 3? and so on... as shown below in image.



So if you can see the screenshot there is a question mark after 3(Encircled in red) .we have a total of 50 pages in the report
but instead of displaying the last page it is showing a question mark and we cannot show question mark as it was client request.
When press to show next page, it shows
2 of 3?,
after 3 of 4?. And in that mode till the end of the report.



So, we could easily solve this error. Just place a textbox in footer or header and goto the Expression of that textbox. Now goto Built-In Fileds and select OverallTotalPages(or type in query box:: =Globals!OverallTotalPages)
i.e. Place Textbox in Header/ Footer-> Goto Expression-> Select…

StateCode and StatusCode Values for mostly used entities in Microsoft Dynamics CRM 2013

In this blog I have given a list of all StateCode and StatusCode of useful entities. Please refer MSDN for more details for any doubt if you have regarding any thing. I also have collected this through MSDN
The following table shows default Microsoft CRM values for StateCode and StatusCode. Each StateCode has its own default StatusCode value. For example, if a Product StateCode is 0 (Active), the default StatusCode is 1 (Active(default)). If the Product StateCode is 1 (InActive), the default StatusCode is 2 (Inactive(default)). Microsoft CRM only accepts StatusCodes that are valid for a particular StateCode.



Entity
Status (statecode)
Status Reason
(statuscode)

Account (account)
0
Active
1
Active
1
Inactive
2
Inactive
Activity (activitypointer)
0
Open
1
Open
1
Completed
2
Completed
2
Canceled
3
Canceled
go to top image