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;