Friday, July 9, 2010

Retrieve CRM Entity's Picklist using MetadataService

This method returns a NameValueCollection of picklist items. CrmHelper is similar to the SDK utility sample.




public NameValueCollection GetAgencyRelationshipTypePicklist()
{
CrmHelper helper = new CrmHelper();

NameValueCollection picklist = new NameValueCollection();

RetrieveAttributeRequest attribReq = new RetrieveAttributeRequest();
attribReq.EntityLogicalName = "new_agencycontact";
attribReq.LogicalName = "new_agencycontacttype";
attribReq.RetrieveAsIfPublished = true;

MetadataService service = helper.GetMetadataService();

RetrieveAttributeResponse attribResp = service.Execute(attribReq) as RetrieveAttributeResponse;

PicklistAttributeMetadata listData = attribResp.AttributeMetadata as PicklistAttributeMetadata;

foreach (Option item in listData.Options)
{
picklist.Add(item.Value.formattedvalue, item.Label.UserLocLabel.Label);
}

return picklist;
}

Use JavaScript to hide an ASP.Net Button

To be 508 compliant, my page must allow users to select items from a drop-down list with JavaScript disabled, so I added a “select” button (called btnAgSelect) next to the list.  When JS is enabled, I do not want the button to be visible, so I used this in my Page.Load() event:

 

ScriptManager.RegisterStartupScript(

  this ,this.GetType(),

  "", "document.getElementById('" +

  btnAgSelect.ClientID + "').style.visibility='hidden';",

  true);

Saturday, July 3, 2010

Windows XP Standby Wakes Up

I got a new work laptop that I typically left on Standby, but it kept waking up in the middle of the night and draining the battery.  I assumed it was the NIC’s Wake-On-LAN setting so I disabled the following setting (note the OS warning that someone had obviously ignored) using Hardware Manager (System – Hardware tab):

 

 

 

 

Friday, June 11, 2010

Finding CRM 4.0 Entities with Attachments by Querying annotationBase Table

I needed to find all of the inactive records for an entity that had documents attached:

 

SELECT COUNT(*)
FROM   new_myEntityBase t
       JOIN annotationBase ab
         ON t.myentityid = ab.objectid
WHERE  statecode = 1 

Tuesday, May 11, 2010

Move Flex Alert.show on the screen

I have a tall Flex application that uses Alert.show( ) to display error messages.  This created problems when the error messages were centered on the screen, but not visible when the screen was at an extreme scroll position (top or bottom).  To solve this, I capture the MouseEvent and use it to set the Alert’s “Y” position.  Note this code did not work UNTIL I used the PopUpManager.centerPopUp prior to moving:

 

var errorMsg:Alert = Alert.show(errmsg,"Error", Alert.OK, this);

PopUpManager.centerPopUp(errorMsg);

 

var mousePt:Point = new Point(event.localX, event.localY);

mousePt = event.target.localToGlobal(mousePt);

errorMsg.move(errorMsg.x, mousePt.y - 50); // try to vertical center it at button

Tuesday, May 4, 2010

Compiling the CRM SDK CrmServiceUtility Class without Web References

According to Shan’s Blog post Using CRM SDK Instead of Web References, it is often preferable to use the SDK classes instead of the proxy classes generated when you add web references. Using the CrmServiceUtility class found in the 4.0 SDK in the \server\reference\cs folder is a perfect case in point. The way the code is written, you can compile it without a web reference simply by adding references to Microsoft.Crm.Sdk.dll, Microsoft.Crm.SdkTypeProxy.dll, and System.Web.Services and two using statements:

using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Crm.SdkTypeProxy.Metadata;

Thursday, March 11, 2010

Google Maps and Flex are beautiful together

All I can say is WOW! Working with Google Maps in ActionScript is SOOOO much easier than HTML/JavaScript. In 5 minutes I had a working map and in 20 minutes of Google examples I had this:

I am sold.