Kids, don't try this at home!

Tips & Tricks for C#, ASP.NET and CRM

Dynamics CRM 4 - Progress Bar

I was browsing the dynamics forums the other day and saw a post asking about the progress bar in CRM, we created one awhile back, here it is for anyone else that's looking for something similar.

Click here to download a working sample.

Dynamics CRM 4 - Progress Bar

What you'll need

crmprogressbar.js

function
crmProgressBar(id) {
    this.bar = $("#" + id);

    this.bar.css({
        'height': '23px',
        'width': '357px',
        'background': 'transparent url(img/statusbar.gif) no-repeat'
    });

    this.bar.find("div").css({
        'height': '19px',
        'width': '1px',
        'background': 'transparent url(img/step.gif) repeat-x',
        'position': 'relative',
        'top': '2px',
        'left': '3px'
    });

    this.step = function(percentage) {
        var width = parseInt((percentage / 100) * 351);
        if (width > 351) { width = 351; }

        this.bar.find("div").css({ 'width': width + 'px' });
    }
}

Example

  1. Create a new html file
  2. Create a new javascript file and copy the above code into it
  3. Include a reference to the jQuery javascript library
  4. Include a reference to the javascript in your html file
  5. Add a "div" tag to the html file and give it an "id"
  6. Add another "div" tag inside the "div" you created in step 4. and put a blank space
  7. To initialize the progress bar; create a new variable to hold the progress bar, then create a new instance of the progress bar by specifying the "id" of the div you created in step 4.
    eg: var progressBar1 = new crmProgressBar("id-of-div");
  8. To step/increment the progress bar use the step() instance method
    eg: progressBar1.step(10); // will increment to 10%;

<div id="p1">
    <div>
        &nbsp;</div>
</div>

<script type="text/javascript">
    var i = 5;
    var cpb = null;

    $(document).ready(function() {
        cpb = new crmProgressBar("p1");
        increment();
    });

    function increment() {
        if (i <= 100) {
            i += 5;
            cpb.step(i);
            setTimeout(increment, 1000);
        }
    }
    
</script>

Comments

Tom said:

Hi,

Thanks for posting this. Just another favour, how do call this function and I increment this from an aspx page server side code based on a long running action. Sorry...I don't have much knowledge with javascript.

Thanks

Tom Vinod

# May 5, 2009 8:05 PM

coocle said:

Hi

   I am a new developer for MS CRM,and now I have a similar question

   can the progress bar intregated with file upload module of crm4?

   or how to do it

   thanks

# May 8, 2009 3:18 AM

gperera said:

RE: Tom

Please see my reply on the forum

RE: coocle

I assume you're wanting to use this progress bar with the fileupload control? To do it from scratch would take a lot of time, I would recommend taking a look at krystalware.com/.../SlickUpload it's lightweight, allows you to skin the progress bar part of it so you can replace the default one with the one above.

# May 9, 2009 1:21 AM

Twitter Trackbacks for Dynamics CRM 4 - Progress Bar - Kids, don't try this at home! [asp.net] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Dynamics CRM 4 - Progress Bar - Kids, don't try this at home!         [asp.net]        on Topsy.com

# January 13, 2010 11:49 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)