Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Contents tagged with ASP.NET

  • Programmatically reuse Dynamics CRM 4 icons

    The team that wrote the dynamics crm sdk help rocks!

    I wanted to display the same crm icons on our time tracking application for consistency, so I opened up the sdk help file, searched for 'icon', ignored all the sitemap/isv config entries since I know I want to get these icons programatically, about half way down the search results I see 'organizationui', sure enough that contains the 16x16 (gridicon), 32x32 (outlookshortcuticon) and 66x48 (largeentityicon) icons!

    To get all the entities, execute a retrieve multiple request.

    RetrieveMultipleRequest request = new RetrieveMultipleRequest
    {
        Query = new QueryExpression
        {
            EntityName = "organizationui",
            ColumnSet = new ColumnSet(new[] { "objecttypecode", "formxml", "gridicon" }),
        }
    };
     
    var response = sdk.Execute(request) as RetrieveMultipleResponse;

    Now you have all the entities and icons, here's the tricky part, all the custom entities in crm store the icons inside gridicon, outlookshortcuticon and largeentityicon attributes, the built-in entity icons are stored inside the /_imgs/ folder with the format of /_imgs/ico_16_xxxx.gif (gridicon), with xxxx being the entity type code. The entity type code is not stored inside an attribute of organizationui, however you can get it by looking at the formxml attribute objecttypecode xml attribute.

    response.BusinessEntityCollection.BusinessEntities.ToList()
        .Cast<organizationui>().ToList()
        .ForEach(a =>
        {
            try
            {
                // easy way to check if it's a custom entity
                if (!string.IsNullOrEmpty(a.gridicon))
                {
                    byte[] gif = Convert.FromBase64String(a.gridicon);
                }
                else
                {
                    // built-in entity
                    if (!string.IsNullOrEmpty(a.formxml))
                    {
                        int start = a.formxml.IndexOf("objecttypecode=\"") + 16;
                        int end = a.formxml.IndexOf("\"", start);
     
                        // found the entity type code
                        string code = a.formxml.Substring(start, end - start);
                        string url = string.Format("/_imgs/ico_16_{0}.gif", code);


    Enjoy!

  • Dynamics CRM 4 SDK for the iPhone via MonoTouch

    We are working on a version of the Dynamics CRM 4 SDK that will work with the iPhone via MonoTouch. Here is a preview of it creating an account in Dynamics CRM using the MonoTouch C# library. We're creating this to speed up development of xRM solutions that can leverage the power of touch based mobile devices as well as the Dynamics CRM platform.

  • Dynamics CRM Workflow - Automatically Email any Report generated in CRM as a PDF attachment

    Time for another Dynamics CRM goodie...

    Send an invoice to a customer with a pdf attached using a dynamics crm workflow

    We try to automate as many things as we can, automatically sending invoices is one of them. Workflow as you know in Dynamics CRM is very powerful, specially the ability to create custom activities and hook into the pipeline. We took advantage of this, we created a custom workflow activity that takes in any entity, Email and a Report, automatically turn it into a PDF, attach it to the email and send the email.

    Take a look at this 5 minute video to see how it works. If you're interested in using this in your organization contact me via this link.

    Under The Hood


    Report2Pdf
    This class does the heavy lifting, it has a method called Download, connects to the report server, configures the parameters and renders the report as a PDF then returns a byte array.

    public
    class Report2Pdf
    {
        public static byte[] Download(string rsUrl, string rseUrl, 
            System.Net.NetworkCredential credentials, string report, 
            Report2PdfParameter[] inputParameters, string culture)
        {


    Workflow Activity
    Straight forward, read the configuration data, makes a call to the Report2Pdf.Download method, creates an activitymimeattachment then executes a SendEmailRequest.

    byte[] data = Report2Pdf.Download(config.Url, config.ExecutionUrl,
        new NetworkCredential(config.UserName, config.Password, config.Domain),
        report.Location, rps.ToArray(), config.Culture);


    LINQ and Dynamics CRM
    Thanks to Amanda and the team at XrmLinq for giving us access to their library. This has made data access so much easier. Something that would take atleast 10-20 lines of code and a lot of effort messing around with FetchXml has now been reduced to 3 lines and LINQ!

    var
    config = (from c in xrm.ReportServerConfigurations
                  where c.ReportServerConfigurationId == report.ConfigurationId
                  select c).SingleOrDefault();

  • Web Form to Dynamics CRM 4

    We've decided to release another component we've been using internally. This little webcontrol allows you put pass data from a Web Form to Dynamics CRM 4.

    How does it work?
    Create a UserControl to layout the form.

  • Dynamics CRM 4 Visio Stencils

    We have decided to release the Visio Stencils we've been using for Dynamics CRM 4 projects, find out more about them here.

    Sneak peak of the shapes you can use on Create/Update (eg: Popup windows)



    Here is the Account screen duplicated with the stencil set. You'll notice subtle differences, but to the client it looks like the real thing.



    Enjoy

  • CRM 4 Activity Direction Indicator (experimental)

    I've been trying to change the icons under History for each entity to show the direction of the email or phone call.

    Using Fiddler I found out that areas.aspx was responsible for rendering the grid when you click on History, then when you click on the Refresh button or create a new Activity it automatically refreshes the grid, that call is made into the AppGridWebService.asmx which returns the formatted html of the grid.

    Unfortunitely I'm not sure how I can hook into the .asmx and modify the returned html.

    Leaving AppGridWebService.asmx aside for now, areas.aspx was easy to hook into, here is the result.

    1st Phone call: an outbound call which is displaying the custom outbound phonecall image.
    2nd; an inbound call, lastly the email is an outbound email with a custom icon.

    To hook into areas.aspx create a new HttpModule then on BeginRequest