Thursday, December 30, 2010

Locking Down Opportunity Customer Lookup to Accounts Only

By default, customer fields are open to accounts, contacts, and sometime leads. A common request is to lock down a customer field to a particular entity type or set of entity types.  For example, you may want to lock down the customer field on opportunity to only accounts (not a contact).  There is a simple fix to handle this.  Simply add this line to only allow accounts to be selected (entity type code of 1).
crmForm.all.customerid.setAttribute("lookuptypes", "1");

The problem is that users can get around this by converting an activity such as a phone call to an opportunity.  If you create your phone call from a contact then it will set the customer to the contact.  The fix is to add code to OnLoad that verifies the customer field.   If a contact is selected then it will reset the customer field to the contact’s parent account.  If they don’t have a parent account then I blank out the field.  Since this field is a required field on opportunity, the user is required to specify a valid account in the customer field before saving.

Default the address on a new contact to an address for their parent account

The below example is used to default the address on a new contact to an address for their parent account.  It pulls the first address (ordering by address number) where the address line 1 is not null (not null check).
try {
    if (crmForm.all.parentaccountid.DataValue != null) {
        // Create object passing in the entity you are selecting from     
        var crmService = new CrmService("customeraddress", LOGICAL_OPERATOR_AND);
        crmService.AddColumn("name");
        crmService.AddColumn("line1");
        crmService.AddColumn("line2");
        crmService.AddColumn("line3");
        crmService.AddColumn("city");
        crmService.AddColumn("stateorprovince");
        crmService.AddColumn("postalcode");
        crmService.AddColumn("country");
       
        // Order by address number ascending
        crmService.AddOrder("addressnumber", "Ascending");

        // Add filter conditions  (note:  the "AND" logical operator was specified in constructor)
        crmService.AddFilterCondition("parentid", crmForm.all.parentaccountid.DataValue[0].id, CONDITION_OPERATOR_EQUAL);
       
        // Where line1 is not null
        crmService.AddFilterCondition("line1", "", "NotNull");

        // Retrieve the result object
        var result = crmService.RetrieveMultiple();
        // Loop through rows and select values (they return strings)
        if (result.Rows.length > 0) {
            var row = result.Rows[0];
            // Get Column By Name
            crmForm.all.address1_name.DataValue = row.GetValue("name");
            crmForm.all.address1_line1.DataValue = row.GetValue("line1");
            crmForm.all.address1_line2.DataValue = row.GetValue("line2");
            crmForm.all.address1_line3.DataValue = row.GetValue("line3");
            crmForm.all.address1_city.DataValue = row.GetValue("city");
            crmForm.all.address1_stateorprovince.DataValue = row.GetValue("stateorprovince");
            crmForm.all.address1_postalcode.DataValue = row.GetValue("postalcode");
            crmForm.all.address1_country.DataValue = row.GetValue("country");
        }
    }
}
catch (e) {
    alert(e.message);
}

Wednesday, December 29, 2010

Error running reports from Outlook Client Grid on IFD Implementation

Microsoft Dynamics CRM 4.0
Error running reports from Outlook Client Grid on IFD Implementation

Overview

All reports will run fine in the web client.  When running the Outlook Client the reports run fine from everywhere except the Report Button on the Grid.  This is a custom report for Impact Orders

Version

Microsoft Dynamics CRM 4.0 Roll Up 7 (4.0.7333.2138)

Error Message

The error is the standard report error, "An error has occurred."  The error log on the CRM Server shows the following:

-
System


-
Provider

[ Name]
ASP.NET 2.0.50727.0


-
EventID
1309

[ Qualifiers]
32768


Level
3


Task
3


Keywords
0x80000000000000


-
TimeCreated

[ SystemTime]
2010-12-29T16:20:34.000Z


EventRecordID
104047


Channel
Application


Computer
HOST-CRM2.host.local



Security

-
EventData



3005


An unhandled exception has occurred.


12/29/2010 9:20:34 AM


12/29/2010 4:20:34 PM


c04a46fbd7f44653bab86c26e46c1cc5


29073


95



0


/LM/W3SVC/1/ROOT-1-129380494173512587


Full


/



C:\inetpub\wwwroot\



HOST-CRM2






2196



w3wp.exe



NT AUTHORITY\NETWORK SERVICE



NullReferenceException



Object reference not set to an instance of an object.



http://speeddev.alwayson-crm.com/crmreports/viewer/viewer.aspx?action=run&id=%7b25A64DCA-0E5E-DF11-8C42-000C29E81AD5%7d&helpID=Speedpro%20Quote.rdl&context=records&recordstype=10004



/crmreports/viewer/viewer.aspx



70.166.206.94



{3bd54000-3b0d-e011-a011-000c29e81ad5}



True



CrmPostAuthentication



NT AUTHORITY\NETWORK SERVICE



8



NT AUTHORITY\NETWORK SERVICE



False



at Microsoft.Crm.Web.Reporting.ReportUtil.BuildRecordsFetch(EntityMetadata entityMeta, String records) at Microsoft.Crm.Web.Reporting.SRSViewer.ModifyFilterWithContext(ReportContext contextInfo, XmlDocument& defaultFilterDoc) at Microsoft.Crm.Web.Reporting.SRSViewer.ConfigurePage() at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Thursday, December 23, 2010

Convergence 2011–Submit Topics Today

SONOMA PARTNERS MICROSOFT CRM BLOG | NOVEMBER 11, 2010
http://pulsene.ws/zy0V


<http://sonomapartners.typepad.com/.a/6a00d8341e71de53ef0133f5c33297970b-pi>
Microsoft is preparing for Convergence 2011 in Atlanta, GA, from April
10-13. You can help in that planning by submitting ... Read more
<http://pulsene.ws/zy0V>

--
Want to read news on the go? Get Pulse
<http://pulsene.ws?src=email_ipad>, an awesome news reader for iPad,
iPhone and Android. Its Free!

<http://via.pulsene.ws/email/pixel.gif?src=email_open_ipad>

Sent from my iPad

XRM Snoop developer tool for writing Microsoft Dynamics CRM plug-ins

XRM Snoop is Sonoma Partners' proprietary application to help developers troubleshoot and debug plug-ins for Microsoft Dynamics CRM. The tools provides a graphical user interface to help developers:

Understand the different values and parameters associated with the various plug-ins
Understand the different types of plug-in registration methods
Understand how a specific plug-in interacts within the overall event processing pipeline.
When using XRM Snoop, you connect to a Microsoft Dynamics CRM system, configure with entities you want to track, and then it registers a plug-in that "listens" to the specific target entities. When events fire within the Microsoft Dynamics CRM system, the XRM Snoop application will display all of the various plug-in data related to target entities.

XRM Snoop provides a significant benefit to developers to working with plug-ins versus reading the Microsoft Dynamics CRM Software Development Kit because XRM Snoop allows you capture plug-in behavior specific to the entities you're tracking all within an easy-to-use graphical interface. It also allows you to actually click through the system as an end user to test your plug-ins and then XRM Snoop displays data about how your plug-ins are functioning.

Sonoma Partners’ customers benefit from XRM Snoop because our development team uses this tool to help write custom code more quickly and efficiently!

XRM Snoop Screenshots