Wednesday, 10 October 2012

Happy Birth Day Remainders

Below links will give information about the birthday remainders:

http://social.microsoft.com/Forums/en/crmdevelopment/thread/356358fd-071c-40f6-8f35-a90e08ccdcdf

http://blogs.msdn.com/b/crm/archive/2008/01/08/part-1-happy-birthday-via-workflow-using-client-side-scripting.aspx

http://blogs.msdn.com/b/crm/archive/2008/01/11/part-2-happy-birthday-via-workflow-using-custom-workflow-activity.aspx

http://www.dynamicscrmtrickbag.com/2012/06/19/dynamics-crm-and-the-trouble-with-time-zones/

http://blogs.msdn.com/b/crm/archive/2009/02/27/creating-a-birthday-contact-list.aspx

http://blogs.msdn.com/b/crm/archive/2008/01/08/part-1-happy-birthday-via-workflow-using-client-side-scripting.aspx

Age calculations:
http://www.crmconsult.info/2012/02/calculate-age-from-date-of-birth-in.html

calculations:

http://social.microsoft.com/Forums/is/crm/thread/ed37eca2-1d0e-43c5-87d9-d220d624c344

By using java script:


function nextbirthday()
{
   
 var now = new Date();
     var birthday1 = Xrm.Page.getAttribute("new_startdate").getValue();
var result=null;
    var years = now.getYear() - birthday1.getYear();
var aditionalyear= years+1
    var months= now.getMonth() - birthday1.getMonth();

     if(months==0)

{

var days= now.getDay()-birthday1.getDay();

if(days>=1)
{
 result= new Date(birthday1);
result.setYear(result.getYear()+aditionalyear);
Xrm.Page.getAttribute("new_enddate").setValue(result);
}
else
{
result= new Date(birthday1);
result.setYear(result.getYear()+years);
Xrm.Page.getAttribute("new_enddate").setValue(result);
}


}
else
{
if(months>=1)
{

result= new Date(birthday1);
result.setYear(result.getYear()+aditionalyear);
Xrm.Page.getAttribute("new_enddate").setValue(result);

}

else
{

result= new Date(birthday1);
result.setYear(result.getYear()+years);
Xrm.Page.getAttribute("new_enddate").setValue(result);

}
}
}

Friday, 5 October 2012

javascripts in crm 2011

Option set values reading and filtering the fields


function registrationpayment()
{

var detailamt= Xrm.Page.getAttribute("new_paymentmode").getValue();

if(detailamt==null)
{

Xrm.Page.getControl("new_receivedperson").setVisible(false);
Xrm.Page.getControl("new_bankname").setVisible(false);
Xrm.Page.getControl("new_checknumber").setVisible(false);
Xrm.Page.getControl("new_demanddraftnumber").setVisible(false);
Xrm.Page.getControl("new_bankaccountnumber").setVisible(false);

}

if(detailamt==100000000)
{
Xrm.Page.getControl("new_receivedperson").setVisible(true);
Xrm.Page.getControl("new_bankname").setVisible(false);
Xrm.Page.getControl("new_checknumber").setVisible(false);
Xrm.Page.getControl("new_demanddraftnumber").setVisible(false);
Xrm.Page.getControl("new_bankaccountnumber").setVisible(false);

}


if(detailamt==100000001)
{
Xrm.Page.getControl("new_receivedperson").setVisible(false);
Xrm.Page.getControl("new_bankname").setVisible(true);
Xrm.Page.getControl("new_checknumber").setVisible(true);
Xrm.Page.getControl("new_demanddraftnumber").setVisible(false);
Xrm.Page.getControl("new_bankaccountnumber").setVisible(false);

}

if(detailamt==100000002)
{
Xrm.Page.getControl("new_receivedperson").setVisible(false);
Xrm.Page.getControl("new_bankname").setVisible(true);
Xrm.Page.getControl("new_checknumber").setVisible(false);
Xrm.Page.getControl("new_demanddraftnumber").setVisible(true);
Xrm.Page.getControl("new_bankaccountnumber").setVisible(false);

}

if(detailamt==100000003)
{
Xrm.Page.getControl("new_receivedperson").setVisible(false);
Xrm.Page.getControl("new_bankname").setVisible(true);
Xrm.Page.getControl("new_checknumber").setVisible(false);
Xrm.Page.getControl("new_demanddraftnumber").setVisible(false);
Xrm.Page.getControl("new_bankaccountnumber").setVisible(true);

}

}

hide the space (gap)

document.getElementById("new_checknumber_c").style.display = 'none';
document.getElementById("new_checknumber_d").style.display = 'none';

Hide a section:



function trainingrequired()
{
var detailamt= Xrm.Page.getAttribute("new_training").getValue();
if(detailamt==0)
{
Xrm.Page.ui.tabs.get("General").sections.get("Trainingss").setVisible(false);
}
if(detailamt==1)
{
Xrm.Page.ui.tabs.get("General").sections.get("Trainingss").setVisible(true);

}
}

Bit field

function documentforofferletter()
{
var detailamt= Xrm.Page.getAttribute("new_documentstouniversity").getValue();

if(detailamt==0)
{
Xrm.Page.ui.tabs.get("General").sections.get("Offerletter").setVisible(false);


}
if(detailamt==1)
{
Xrm.Page.ui.tabs.get("General").sections.get("Offerletter").setVisible(true);

}

}


Check Box:

function banksanction()
{
var myAttribute = "new_banksanctionletter";
var myControl = Xrm.Page.ui.controls.get(myAttribute);
var detailamt= myControl.getAttribute().getValue();
if(detailamt==true)
{
Xrm.Page.getControl("new_bank").setDisabled(false);
}
else
{
Xrm.Page.getControl("new_bank").setDisabled(true);
}
}

setting password:


function password()
{
var detailamt= Xrm.Page.data.entity.attributes.get("new_password").getValue();
var details= Xrm.Page.data.entity.attributes.get("new_typepassword").getValue();
if(detailamt == details)
{
Xrm.Page.ui.tabs.get("general").sections.get("generals").setVisible(true);
var pass = Xrm.Page.data.entity.attributes.get("new_typepassword");
pass.setValue(null);
Xrm.Page.ui.tabs.get("general").sections.get("password").setVisible(false);
}
else
{
alert("Wrong Password");
Xrm.Page.ui.tabs.get("general").sections.get("generals").setVisible(false);
}
}

function passwordonload()
{
Xrm.Page.ui.tabs.get("general").sections.get("generals").setVisible(false);
}



Wednesday, 5 September 2012

phone call with oppotunity


Query : select op.name,op.customeridname,op.createdon,op.owneridname ,fp.activitytypecodename,fp.new_callbackname,fp.subject from
FilteredOpportunity op,FilteredPhoneCall fp
where op.opportunityid=fp.regardingobjectid

function:


USE [neworg_MSCRM]
GO
/****** Object:  UserDefinedFunction [dbo].[Getopportunitycount]    Script Date: 09/06/2012 11:36:58 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
ALTER FUNCTION [dbo].[Getopportunitycount]
(
-- Add the parameters for the function here
@createdate date,
@uname varchar(50)
)
RETURNS int
AS
BEGIN
-- Declare the return variable here
DECLARE
@ResultVar int

-- Add the T-SQL statements to compute the return value here
set @ResultVar = (select count(*) from FilteredPhoneCall where  (CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, createdon))) = @createdate) and (new_callback=1) and (createdbyname = @uname ))
set @ResultVar= (select COUNT(*) from FilteredOpportunity op,FilteredPhoneCall fp where (op.opportunityid=fp.regardingobjectid) and

(op.createdbyname = @uname) and (CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, op.createdon))) = @createdate) )

-- Return the result of the function
RETURN @ResultVar

END

query :


IF OBJECT_ID('tempdb..#AllReportees') IS NOT NULL
        DROP TABLE #AllReportees
        CREATE TABLE #AllReportees
(
    createdate Date,
    uname varchar(50),
    ownids uniqueidentifier,
    phoneact varchar(50),
    statuscode varchar(50)
  
)

INSERT INTO #AllReportees
select CONVERT(VARCHAR, createdon, 106) AS date1,createdbyname,ownerid,activityid,statuscodename from FilteredPhoneCall
union
select CONVERT(VARCHAR, createdon, 106) AS date1,createdbyname,ownerid,opportunityid,statuscodename  from FilteredOpportunity



 select *
 ,dbo.Getwrongphonecallcount(dd.createdate,dd.uname) as 'Wrong Calls' ,dbo.Getnoresponsecount(dd.createdate,dd.uname) as ' No Response' , dbo.Getcallbackcount(dd.createdate,dd.uname) as 'Callback',
 dbo.Getopportunitycount( dd.createdate,dd.uname ) as 'Opportunities'
  from (
select  ss.createdate,ss.uname,
 count(distinct fp.activityid) as Phone
   from #AllReportees ss
 left OUTER JOIN FilteredSystemUser AS su  WITH (NOLOCK) ON su.systemuserid=ss.ownids
 left OUTER JOIN  FilteredPhoneCall as fp WITH (NOLOCK) ON  (fp.activityid=ss.phoneact)
 left OUTER JOIN FilteredOpportunity fl WITH (NOLOCK) ON  (fl.opportunityid=ss.phoneact)
 left OUTER JOIN FilteredAppointment AS fa WITH (NOLOCK) ON (fa.activityid=ss.phoneact)
     group by ss.createdate,uname
     ) dd order by dd.uname,dd.createdate