Wednesday, 29 July 2015

Sample code for creating contact record through web service.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk;
using System.ServiceModel.Description;

namespace crmtovswebservice
{
    /// <summary>
    /// Summary description for WebService1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {

        [WebMethod]
        public void run(string a, string b)
        {

            try
            {
           
                ClientCredentials cre = new ClientCredentials();
                cre.UserName.UserName = "username";
                cre.UserName.Password = "password";


                Uri serviceUri = new Uri("your server name");

           OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);
                proxy.EnableProxyTypes();
                IOrganizationService service = (IOrganizationService)proxy;


                Entity ent = new Entity("contact");// creation of entity
                ent["firstname"] = a;
                ent["lastname"] = b;
                service.Create(ent);

             
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException();
            }


        }
    }
}

Thursday, 23 July 2015

Sample code for retreiving data Through Odata in crm

function player()
 {

   var id = Xrm.Page.data.entity.attributes.get("ccs_playername2").getValue();
   alert(id[0].name);
   var serverUrl = "http://"+window.location.host+"/" + Xrm.Page.context.getOrgUniqueName();
   if(id!=null)
   {
     var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
     var retrieveReq = new XMLHttpRequest();
     //replace with your odata query
     var Odata = ODataPath + "/ccs_informationSet?$select=ccs_jersey&$filter=ccs_informationId eq guid'" + id[0].id + "'";
     retrieveReq.open("GET", Odata, true);
     retrieveReq.setRequestHeader("Accept", "application/json");
     retrieveReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
     retrieveReq.onreadystatechange = function () { retrieveReqCallBack(this); };
     retrieveReq.send();
   }
 }
 function retrieveReqCallBack(retrieveReq) {
       if (retrieveReq.readyState == 4) { 

  var retrieved =this.parent.JSON.parse(retrieveReq.responseText).d;     
  //for (i = 0; i < retrieved.results.length; i++) {
 // statecode = retrieved.results[i].ccs_jersey;
  //alert(statecode);
  //}
          
            var statecode = retrieved.results[0].ccs_jersey;
             alert(statecode);
             Xrm.Page.data.entity.attributes.get("ccs_jerseyno").setValue(statecode);
           }        
 }

Sample Code For creating Plugins For sending Email in crm

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;
namespace Plugins
{
    public class Folloeplugins:IPlugin
    {
        public void Execute(IServiceProvider serviceProvider)
        {
            //Extract the tracing service for use in debugging sandboxed plug-ins.
            ITracingService tracingService =
                (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            // Obtain the execution context from the service provider.
            IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));
            if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
            {
                // Obtain the target entity from the input parameters.
                Entity entity = (Entity)context.InputParameters["Target"];

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                try
                {
                   
                  
                        Entity email = new Entity("email");
                        Entity fromparty=new Entity("activityparty");
                        Entity toparty=new Entity("activityparty");
                        toparty["partyid"] = new EntityReference("systemuser", context.UserId);
                        fromparty["partyid"] = new EntityReference("systemuser", context.UserId);
                        email["from"] = new Entity[] { fromparty };
                        email["to"] = new Entity[] { toparty };
                        email["subject"] = "email subject - " + DateTime.Now.ToString();
                        email["description"] = "email description";


                        email["regardingobjectid"] = new EntityReference("account", entity.Id);
                       
                      
                        Guid emailid=  service.Create(email);
                        SendEmailRequest sendEmailreq = new SendEmailRequest
                        {
                            EmailId = emailid,
                            TrackingToken = "",
                            IssueSend = true
                        };
                        SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreq);
                     
                   
                }
                catch (FaultException<OrganizationServiceFault> ex)
                {
                    throw new InvalidPluginExecutionException("An error occurred in the FollupupPlugin plug-in.", ex);
                }
                   
                }
            }

        }
    }
 

Tuesday, 14 July 2015

Sample code for creating a record in visual studio and updating it in crm

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using System.ServiceModel.Description;
using System.Web.Services.Protocols;

namespace sample_code2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ClientCredentials cre = new ClientCredentials();
                cre.UserName.UserName = "username";// enter your user name
                cre.UserName.Password = "password";// enter your password
                Uri serviceUri = new Uri("login address");//give the url of your crm organization.You will                                                                                                                     find it in developer resource.

            OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);
                proxy.EnableProxyTypes();
                IOrganizationService service = (IOrganizationService)proxy;


                Entity ent = new Entity("contact");// creation of entity
                ent["firstname"] = textBox1.Text;
                ent["lastname"] = textBox2.Text;
                service.Create(ent);


            }
            catch (SoapException ex)
            {
                throw new InvalidOperationException();
            }
         

        }

    }
}

Thursday, 9 July 2015

Creation of simple plugin in crm

using System;
using System.ServiceModel;

// Microsoft Dynamics CRM namespace(s)
using Microsoft.Xrm.Sdk;

namespace Microsoft.Crm.Sdk.Samples
{
  public class FollowupPlugin: IPlugin
 {
  /// <summary>
        /// A plug-in that creates a follow-up task activity when a new account is created.
  /// </summary>
        /// <remarks>Register this plug-in on the Create message, account entity,
        /// and asynchronous mode.
        /// </remarks>
        public void Execute(IServiceProvider serviceProvider)
  {
            //Extract the tracing service for use in debugging sandboxed plug-ins.
            ITracingService tracingService =
                (ITracingService)serviceProvider.GetService(typeof(ITracingService));

            // Obtain the execution context from the service provider.
            IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));

            // The InputParameters collection contains all the data passed in the message request.
            if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
            {
                // Obtain the target entity from the input parameters.
                Entity entity = (Entity)context.InputParameters["Target"];

                // Verify that the target entity represents an account.
                // If not, this plug-in was not registered correctly.
                if (entity.LogicalName != "account")
                    return;

                try
                {
                    // Create a task activity to follow up with the account customer in 7 days. 
                    Entity followup = new Entity("task");

                    followup["subject"] = "Send e-mail to the new customer.";
                    followup["description"] =
                        "Follow up with the customer. Check if there are any new issues that need resolution.";
                    followup["scheduledstart"] = DateTime.Now.AddDays(7);
                    followup["scheduledend"] = DateTime.Now.AddDays(7);
                    followup["category"] = context.PrimaryEntityName;

                    // Refer to the account in the task activity.
                    if (context.OutputParameters.Contains("id"))
                    {
                        Guid regardingobjectid = new Guid(context.OutputParameters["id"].T
String());
                        string regardingobjectidType = "account";

                        followup["regardingobjectid"] =
                        new EntityReference(regardingobjectidType, regardingobjectid);
                    }

                    // Obtain the organization service reference.
                    IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

                    // Create the task in Microsoft Dynamics CRM.
                    tracingService.Trace("FollowupPlugin: Creating the task activity.");
                    service.Create(followup);
                }
                catch (FaultException<OrganizationServiceFault> ex)
                {
                    throw new InvalidPluginExecutionException("An error occurred in the FollupupPlugin plug-in.", ex);
                }

                catch (Exception ex)
                {
                    tracingService.Trace("FollowupPlugin: {0}", ex.ToString());
                    throw;
                }
            }
        }
    }
}

Thursday, 2 July 2015

Java script program for Validating Email and Phone Number in crm

function phonenumber()
{
var a=Xrm.Page.getAttribute( "ccs_phoneno").getValue();
var reg = /^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$/;
   var K = reg.exec(a);
       if (!K)
                 alert("phone number is  valid");
            else

             alert("phone number is not valid");

         var email = Xrm.Page.getAttribute( "ccs_email_id").getValue();
var reg = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        var OK = reg.exec(email);
       if (!OK)

    alert("Email Address isn't  valid");

        else
         alert("Email Address  is  valid");

   }  

Monday, 11 May 2015

Program to find the number of vowels in a string using Java


public class Vowels {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        String str[]={"a,e,i,o,u"};
         int j=0;
        System.out.println("enter the string");
        Scanner sc=new Scanner(System.in);
        String str1=sc.nextLine();
        for(int i=0;i<str1.length();i++)
        {
           char ch=str1.charAt(i);
           String temp=Character.toString(ch);
            
            if(temp.equalsIgnoreCase("a" )|| temp.equalsIgnoreCase("e")||temp.equalsIgnoreCase("i")||temp.equalsIgnoreCase("o")||temp.equalsIgnoreCase("u"))
            {
                    
                j++;
            }
                
        }
                    
        System.out.println("No of vowels is"+j);
           
           
        
    }
}
        
      
        
    

Saturday, 9 May 2015

String Comparison using compareToIgnorecase

Simple Java Program For Comparing Two Strings Using                                   CompareToIgnoreCase




import java.util.Scanner;

public class Stringcomparrison {

 
    public static void main(String[] args) {
        
  
       Scanner input = new Scanner( System.in );
       System.out.print("Enter the string ");
       String str=input.nextLine();
       StringBuffer s=new StringBuffer(str);
       if(str.compareToIgnoreCase("Muthu")==0)
       
           System.out.println("equal");
           else
           System.out.println("not equal");
       
       
       
    }
}

                Java Program for converting Decimal To binary.



package decimal.to.binary;

import static java.time.Clock.system;
import java.util.Scanner;

public class DecimalToBinary {
    
    
    public static void main(String[] args) {
       
        Scanner s=new Scanner(System.in);
        System.out.println("enter the decimal no");
        int decimal=s.nextInt();
         int i=0;
         int r[]=new int[decimal];
        while( decimal >0)
        {
           
           
            r[i++]=decimal%2;
             decimal=decimal/2;
         
        }
      
         for(int j=i-1;j>0;j--)    
         {
             System.out.println(r[j]);
         }
        
    }
    
}

Sunday, 15 February 2015

                      Greatest Rivalry Of Cricket:Resolved

Rivalry of cricket ,obviously it means IND vs PAK. What a match!!! India have done a great job in a high pressure game.Though the thoughts of critics and likes of fans were jaded on India retaining their crown before the start of mega Tournament,but now they have brought the momentum back by winning the open Encounter.The Sunday game was totally immensive and it also recorded some records.

First,the Tickets were sold out in less than 15 min this itself a great milestone were fans from various countries went to watch out the match.But there was a huge disappointment for Pakistan fans as their same story continues from 5-0 to 6-0.But on the other hand India have started their on positive note.This is the exact start that Dhoni want from his co...So lets hope for the best and India should continue with this same positive note.......

Sunday, 18 January 2015

Greatest Ironies of India  PETER ENGLAND belongs to INDIA 
HINDUSTAN UNILEVER doesn't belongs to INDIA..

Tuesday, 25 November 2014

                                  Satisfaction

Social Networking Giant Facebook acquired whats app for 19 billion. And there is recent report saying that the company Google acquires a new company each month.But there is one thing in this world that no one can acquire it.ya obviously it is SATISFACTION.we humans never satisfy for what we have.Jealousy is one thing which destroys half the humans in this world.we always be jealous about others and think beyond our reach and it always ends in failure.
Just think about a common man's life.Once we get into school our will tune  us for getting more marks in tenth.once we complete tenth then they pressure us for making good score in twelve. After completing twelveth we may think pressure is over  and now we can be independent and lead our life on own.But the answer is wrong the real life starts here we now enter into a pressure cooker life  .ya our parents force us to join in Engineering even though we are not interested.After completing our degree they again start nudging us for getting a job.Once we get a job we have to go abroad and earn money .So this is the actual life of many of us.so be satisfied and enjoy the life given to you.Life will be joyful once we are satisfied..


        PLEASE POST YOUR VIEWS ABOUT THIS ARTICLE THROUGH COMMENTS

Wednesday, 19 November 2014

BRAIN-DRAIN

                                             BRAIN-DRAIN


The word seems to be very oblique and catchy,but the actual 

meaning humiliates and  our younger generation has to think

about this in their furious minds.What is Brain-drain? This

is the question which will be buzzling now in your heart.

Studying in one country and using their brain's for the another

country is the actual meaning of the word.

Why I am mentioning this word here is ,it happens only in

India.Almost all the MNC's are running in the brain of Indian

people,but still India is a developing country.This is a worst

stat for country like India.The Mother Country  produces

about 2 lakh engineers per year,but the worst case is that,

the supreme  Country USA just produces nearly 1 lakh engineers

per year so it is half than what we produce.So we have  great

manpower,resource and everything for country development but what

we lack is skilled people.

But we cannot blame the people alone because we are all poor middle class people

who run drastically for money.And one more thing is,Underestimation

and not recognizing their work is the other reason

why these people prefer abroad than working for their country.

Another major isuue is our government policies and politicians who rule our country

has forced these people to work outside their own country.so these

cannot be changed in a day or week it may take years.But if

younger generation works whole heartedly i am damn sure that India

will be in the list of developed country in few more years...


**********Post your views about this article through comments*********







My first app

   THIS S MY FIRST ANDROID APP
click the below link to download.The app is all about flame game.Match your name with your budyy name.

        https://app.box.com/s/ychomir1kjaxdx0qiyx3

Saturday, 5 January 2013

This is my new blog which is going to inspire all young INDIAN TALENTS...............