CRM 2013 Javacript Validate Integer

0 comments


Script:

function CheckInteger(Field) {
    var Result = Xrm.Page.getAttribute(Field).getValue();

    if (isInt(Result)) {
        Xrm.Page.getAttribute(Field).setValue(Result);
    }
    else {
        alert("Input is not numeric")
        Xrm.Page.getAttribute(Field).setValue(null);
    }
}

function isInt(value) {
    return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10));

}

CRM 2013 Javascript Validate Symbol

0 comments


Script:

function validateSymbol(Field) {
    var TCode = Xrm.Page.getAttribute(Field).getValue();

    if (/[^a-zA-Z0-9\-\/]/.test(TCode)) {
        alert("Input is not alphanumeric");
        Xrm.Page.getAttribute(Field).setValue(null);
    }
}

CRM 2013 Remove all the subgrid add button

0 comments


Call it during On load (with certain condition) then all the sub grid add button in the form will be hidden.

Script:

var intervalId;

function makeReadOnly() {
    try {
        var subgridsLoaded = false;

        Xrm.Page.ui.controls.get().forEach(function (control, index) {
            if (control.setDisabled && Xrm.Page.ui.getFormType() != 3) {
                control.setDisabled(true);
            }
            else {
                // removeAddButtonFromSubGrid(control);
                // subgridsLoaded = true; 
            }
        });

        if ($("div[id$='_crmGridTD']").length > 0 && !subgridsLoaded) {
            intervalId = setInterval(function () {
                var subgridsArr = Xrm.Page.getControl(function (control, index) {
                    return control.getControlType() == 'subgrid';
                });
                subgridsArr.forEach(function (control, index) {
                    removeButtonsFromSubGrid(control);
                });
            }, 500);
        }
    }

    catch (e) {
        alert("makeReadOnly() Error: " + e.message);
    }
}

function removeButtonsFromSubGrid(subgridControl) {
    if (intervalId) {
        $('#' + subgridControl.getName() + '_addImageButton').css('display', 'none');
        $('#' + subgridControl.getName() + '_openAssociatedGridViewImageButton').css('display', 'none');
        clearInterval(intervalId);
    }
}

How to remove TFS lock of other user

0 comments


Problem:

Window corrupt and need to be format and install with new window with different PC name. After format notice that in Team Foundation Server (TFS) certain file is lock from editing by old PC name.

Solution:

From within Visual Studio 2012(and 2013):

File -> Source Control -> Advanced -> Workspaces...

In the dialog that came up, I checked "Show remote workspaces" and the locked workspace came up in the window. I then selected it and clicked "Remove".

The locked file is release.