Search

Anything in the Dynamics CRM Platform



Hello Guest  

Javascript to Format Phone Number



 

Hi ,

 

The below code helps in formatting the phone number using Javascript.

 

switch (crmForm.FormType)

{

      case CRM_FORM_TYPE_CREATE:

      case CRM_FORM_TYPE_UPDATE:

 

 

// Get the Telephone1 field :

var oField = crmForm.all.Telephone1;

 

// Validate the field information.

if (oField.DataValue != "undefined" && oField.DataValue != null)

{

// Remove any nonnumeric characters.

var sTmp = oField.DataValue.replace(/[^0-9]/g, "");

// If the number has a valid length, format the number.

switch (sTmp.length)

{

                case "4105551212".length:

                   oField.DataValue = "(" + sTmp.substr(0, 3) + ") " + sTmp.substr(3, 3) + "-" + sTmp.substr(6, 4);

                   break;

                case "5551212".length:

                   oField.DataValue = sTmp.substr(0, 3) + "-" + sTmp.substr(3, 4);

                   break;

                case "41055512121".length:

                   oField.DataValue = "(" + sTmp.substr(0,3) + ") " + sTmp.substr(3,3) + "-" + sTmp.substr(6,4) + " ext." + sTmp.substr(10,1);

                   break;

                case "410555121212".length:

                   oField.DataValue = "(" + sTmp.substr(0,3) + ") " + sTmp.substr(3,3) + "-" + sTmp.substr(6,4) + " ext." + sTmp.substr(10,2);

                   break;

                case "4105551212123".length:

                   oField.DataValue = "(" + sTmp.substr(0,3) + ") " + sTmp.substr(3,3) + "-" + sTmp.substr(6,4) + " ext." + sTmp.substr(10,3);

                   break;

                case "41055512121234".length:

                   oField.DataValue = "(" + sTmp.substr(0,3) + ") " + sTmp.substr(3,3) + "-" + sTmp.substr(6,4) + " ext." + sTmp.substr(10,4);

                   break;

                case "410555121212345".length:

                   oField.DataValue = "(" + sTmp.substr(0,3) + ") " + sTmp.substr(3,3) + "-" + sTmp.substr(6,4) + " ext." + sTmp.substr(10,5);

                   break;

                }

}

 

 

      break;

}


By   Srinivas          Published Date:  10-Nov-2009


Close opportunity and cancel apportunity



 

To Close the Opportunity and Cancel Opportunity use the following custom code.

private void CloseOpportunity(Guid opportunityId, int statusCode, string description)

{

    opportunityclose oppclose = new opportunityclose();

    oppclose.opportunityid = new Lookup();

    oppclose.opportunityid.type = EntityName.opportunity.ToString();

    oppclose.opportunityid.Value = opportunityId;

    oppclose.description = description;

    oppclose.actualend = new CrmDateTime(DateTime.Now.ToString());

 

    WinOpportunityRequest woReq = new WinOpportunityRequest();

    woReq.OpportunityClose = oppclose;

    woReq.Status = 3;   // Won;

 

    crmService.Execute(woReq);

}

 

private void CancelOpportunity(Guid opportunityId, int statusCode, string description)

{

    opportunityclose oppclose = new opportunityclose();

    oppclose.opportunityid = new Lookup();

    oppclose.opportunityid.type = EntityName.opportunity.ToString();

    oppclose.opportunityid.Value = opportunityId;

    oppclose.description = description;

    oppclose.actualend = new CrmDateTime(DateTime.Now.ToString());

 

    LoseOpportunityRequest woReq = new LoseOpportunityRequest();

    woReq.OpportunityClose = oppclose;

    woReq.Status = statusCode;

 

    crmService.Execute(woReq);

}

 


By   Srinivas          Published Date:  09-Nov-2009


Close opportunity and cancel apportunity



 

To Close the Opportunity and Cancel Opportunity use the following custom code.

private void CloseOpportunity(Guid opportunityId, int statusCode, string description)

{

    opportunityclose oppclose = new opportunityclose();

    oppclose.opportunityid = new Lookup();

    oppclose.opportunityid.type = EntityName.opportunity.ToString();

    oppclose.opportunityid.Value = opportunityId;

    oppclose.description = description;

    oppclose.actualend = new CrmDateTime(DateTime.Now.ToString());

 

    WinOpportunityRequest woReq = new WinOpportunityRequest();

    woReq.OpportunityClose = oppclose;

    woReq.Status = 3;   // Won;

 

    crmService.Execute(woReq);

}

 

private void CancelOpportunity(Guid opportunityId, int statusCode, string description)

{

    opportunityclose oppclose = new opportunityclose();

    oppclose.opportunityid = new Lookup();

    oppclose.opportunityid.type = EntityName.opportunity.ToString();

    oppclose.opportunityid.Value = opportunityId;

    oppclose.description = description;

    oppclose.actualend = new CrmDateTime(DateTime.Now.ToString());

 

    LoseOpportunityRequest woReq = new LoseOpportunityRequest();

    woReq.OpportunityClose = oppclose;

    woReq.Status = statusCode;

 

    crmService.Execute(woReq);

}

 


By   Srinivas          Published Date:  09-Nov-2009


Unable to attach a database since the log file was deleted



 

1.  Since the database was detached and the log file for the database was removed we

     had to recreate the log file.

2. We achieved the following by using the command below.

 

CREATE DATABASE Abcsolutionsdemo__MSCRM ON (FILENAME = 'E:\Program Files\

Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ Abcsolutionsdemo __MSCRM.mdf') FOR ATTACH_FORCE_REBUILD_LOG

 

3.  This command attaches the database and rebuilds the T-log when it attaches and hence the issue was resolved.

 

 


By   Satish          Published Date:  19-Oct-2009


Unable to print the reports in Dynamics CRM on Windows 2008 (64 Bit). “Unable to Load Client Print Control”



 

We are running Dynamics CRM on Win 2008(64 Bit) and SQL Server with SP1 on another machine with Win 2008(64 Bit).After installing the Microsoft Report Viewer Redistributable 2005 Service Pack 1 on the CRM machine and doing “IISRESET” resolved the issue.

Downlaod Microsoft Report Viewer Redistributable 2005 Service Pack 1 :

http://www.microsoft.com/downloads/details.aspx?familyid=82833F27-081D-4B72-83EF-2836360A904D&displaylang=en


By   Satish          Published Date:  25-Sep-2009


<< Previous  Next >>