Daren's profileDaren TurnerBlogLists Tools Help

Blog


    March 29

    Viewing a Logo in Microsoft CRM

    I'm always getting the question on how to view a logo or image in Microsoft CRM.  Well here is a quick customization you can add to your account form and view a logo.   Once you add this script on the 'OnLoad' event of the form, all you need to do is add an image called 'logo.jpg' as an attachment and everything will show up properly.   This customization will even work offline.

    Script

    var Loaded = false;

    if(crmForm.FormType ==2 || crmForm.FormType ==3 || crmForm.FormType ==4)
    {
        // get the notescontrol object
        var oNotes = document.getElementById("notescontrol");

        // attach an event so we know when the notecontrol is done loading
       oNotes.attachEvent('onreadystatechange', LoadLogo);

       // refresh the notecontrol
       oNotes.Refresh();
    }

    function LoadLogo()
    {
       if (oNotes.readyState != 'complete')
          return;

       var oDoc = (oNotes.contentWindow || oNotes.contentDocument);
       if (oDoc.document) oDoc = oDoc.document;
       // attachment use SPAN tags
       var attachments = oDoc.body.getElementsByTagName("SPAN");

       //Iterate through all the attachments.
       for (var i = 0; i < attachments.length; i++)
       {
           // let's be certain we have an attachment here
           if (attachments[i].attachmentId)
           {
                // is this an image attachment
                if (attachments[i].innerHTML.match(/.*logo\.jpg$/i) && !Loaded)
                {
                      //Get a reference to the table
                     var tr = crmForm.all.name.parentNode.parentNode.parentNode.insertRow();
                     var td = tr.insertCell();
                     td.align="right"
                     td.colSpan=4;
                     td.innerHTML = "<img src='" + attachments[i].url.concat("?AttachmentType=", attachments[i].attachmentType,                                    "&AttachmentId=", attachments[i].attachmentId) + "'/>"
                      Loaded = true;
                 }
           }
        }
    }

    When your done, your form should look like this.

    If you really want to get creative you can go a little further and build a viewer to page through all images that are attached to the record.

     

     

     

    This customization may not be supported by Microsoft and is provided as-is with no warranty.

    Comments (3)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    No namewrote:
    wow gold!All wow gold US Server 24.99$/1000G on sell! Cheap wow gold,wow gold,wow gold,Buy Cheapest/Safe/Fast WoW US EU wow gold Power leveling wow gold from the time you World of Warcraft gold ordered! wow power leveling wow power leveling power leveling wow power leveling wow powerleveling wow power levelingcheap wow power leveling wow power leveling buy wow power leveling wow power leveling buy power leveling wow power leveling cheap power leveling wow power leveling wow power leveling wow power leveling wow powerleveling wow power leveling power leveling wow power leveling wow powerleveling wow power leveling buy rolex cheap rolex wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling -199526304829288
    June 20
    Daren Turnerwrote:
    As long as you have the script on the 'OnLoad' and you wanted to automate the addition of the logo via WF rule... yea.
    Mar. 31
    Michael D.wrote:
    So, one could display a consistent logo on every form created if you were to, say, set up a "Create" WF Rule that adds the this logo in a Notes Attchment?
    Mar. 31

    Trackbacks

    The trackback URL for this entry is:
    http://dtu11.spaces.live.com/blog/cns!D01B965C27CB1CC6!141.trak
    Weblogs that reference this entry
    • None