Friday 2 November 2012

Click To Enable Gridview & Future plans

Well, hello there "Internet".

It's been a while since I've blogged, I currently have 6 unpublished articles that I just cant seem to get out due to time constraints.  However, this is one of those "quick wins" that I haven't seen anywhere else that I wanted to share.  Going forward, I'm likely to dispose of the "written" form of blogging, and focus on live demonstrations and training, I've set up a YouTube channel here, and I'll be linking these back to the main blog.  Now, On the the little thing I'd like to share.

The senario is as follows...
A user creates a new entity or activity, and fills out  the fields they need.  The form for this entity also has a gridview of related records, and as we all know this gridview control are disabled until the parent entity is committed to the database.  The result being, a user completes all fields required on a form and the saves the record.  This will allow them to click the grid, and use the ribbon control to "add new record"

OK, this will sound "petty" to most of you, because you're a developer, and as such, this isn't an issue. But imagine you're using the system day in, day out, saving and adding lines, all day long.  It's only one extra click, and it's standard functionality after all? but we need to push ourselves past this to ensure that the end user is getting the best value of the product and you will be surprised how much positive feedback you get when you introduce "the little things". So here's one of my "little things", that really enhance the users experience   A few simple lines of JavaScript, that one implemented allow the user to "flow" through the CRM form much better.  I call it, saveOnClick (aptly)
/*********************************************************************
On click event for pre-save disabled grid views
for new entities. Save on click, to reduce user steps.
saveOnClick(ctrl) - Pass in control ID on form
*********************************************************************/

function saveOnClick(ctrl) //ensure control passed is "Quoted"
{
    var control = document.getElementById(ctrl);
    if (control != null) 
    {
        control.attachEvent("onclick", doSave);

        function doSave() 
        {
            Xrm.Page.data.entity.save();
        }
    }
}
Applying this simple function to an onLoad event, while passing in the grid view control ID, enable a user to click the grid and auto-save the record.