Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

ReferenceError: SetOrgType_RO is not defined

$
0
0

I set this script to fire OnLoad in the Form Properties.  When it fires it is throwing the error: ReferenceError: SetOrgType_RO is not defined.

Does anyone see the problem in the Code below?

function SetOrgType_RO(){
    setTimeout(function(){
        var currentUserRoles = Xrm.Page.context.getUserRoles();
        for (var i = 0; i < currentUserRoles.length; i++) {
            var userRoleId = currentUserRoles[i];
            var userRoleName = GetRoleName(userRoleId);
            If (userRoleName == "OrgTypeUpdate") {
                // Xrm.Page.ui.controls.get("new_organizationtype").setDisabled(false);
                alert("Ok, Lannie");
                return true;
            }
        }
        return false;
        
        function GetRoleName(userRoleId) {
            var selectQuery = "RoleSet?$top=1&$filter=RoleId eq guid'" + userRoleId + "'&$select=Name";
            var odataSelect = GetServerUrl() + selectQuery;
            alert(odataSelect);
            var roleName = null;
            $.ajax({
                type: "GET",
                async: false,
                contentType: "application/json; charset=utf-8",
                datatype: "json",
                url: odataSelect,
                beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
                success: function (data, textStatus, XmlHttpRequest) {
                    var result = data.d;
                    if (!!result) {
                        roleName = result.results[0].Name;
                    }
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    alert('OData Select Failed: ' + odataSelect);
                }
            });
            return roleName;
        }
    }, 2000);
}


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images