Skip to main content

Notifications

Announcements

No record found.

Customer Service forum
Suggested answer

Script Error - Form or Security Role

Posted on by 8
Hello, 
 
I have many uses within the Customer Service Hub that are encountering a script error (screenshot attached).
It typically appears when a user attempts to access a Case Record.
I believe we narrowed the root cause to the associated email record and the form used to generate the case. 
It appears that 'Enhanced Email, Enhanced Email v.2' are causing the script errors, because when I toggle the form back to just 'Email', the errors seem to go away. 
 
On another forum, a user said that I have to raise the security roles of the users encountering the error. 
My question is, how do I know which role/level to raise it to?
 
I also used developer tools during the error and pulled this code:
 

quiv="Content-Type" content="text/html; charset=utf-8"> 

        <meta http-equiv="X-UA-Compatible" content="IE=Edge"> 

        <link rel="modulepreload" href="https://content.powerapps.com/resource/uci-infra-bus/scripts/app.0a9b425c781fa96d170937732606a67f.js"> 

        <link rel="preconnect" href="https://apps.powerapps.com"> 

        <script type="text/javascript" nomodule src="https://content.powerapps.com/resource/uci-infra-bus/scripts/es6-shim.min.6a3051ef3d8ddcd84c7a6dfd99a75d47.js" crossorigin></script> 

        <script type="text/javascript" nomodule src="https://content.powerapps.com/resource/uci-infra-bus/scripts/es7-shim.min.4997d84316d6302b9bcccaba4e949853.js" crossorigin></script> 

        <script type="text/javascript" nomodule src="https://content.powerapps.com/resource/uci-infra-bus/scripts/fetch.umd.d7bb06d7d3c0b7621c719298d85e319a.js" crossorigin></script> 

        <script type="text/javascript"> 

            var __public_path__ = "https://content.powerapps.com/resource/uci-infra-bus/"; 

 

            // Load pointer polyfill if necessary 

            if (!window.PointerEvent) { 

                var pep = document.createElement("script"); 

                pep.async = false; 

                pep.src = "https://content.powerapps.com/resource/uci-infra-bus/scripts/pep.4851d435ad48a3082a2c3f628fe0f861.js"; 

                pep.crossOrigin = "anonymous"; 

                document.head.appendChild(pep); 

            } 

        </script> 

        <script defer src="/uclient/scripts/cdnEndpointCheck.js?v=1.4.8733-2405.2"></script> 

        <style data-fela-type="RULE" type="text/css"></style> 

        <title>Microsoft Dynamics 365</title> 

        <meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, viewport-fit=cover"> 

        <meta name="apple-mobile-web-app-status-bar-style" content="default"> 

        <meta name="apple-mobile-web-app-capable" content="yes"> 

        <script type="text/javascript"> 

            /* Preload parameters injected at runtime */ 

            var __preload = { 

                "org": "orgb1b9e828", 

                "orgId": "34f034c7-1db3-4010-9f9c-77a2bf6081bf", 

                "serverRequestId": "08a5c47b-3e9e-47a4-8b5b-2f5cc0efd5d6", 

                "serverVersion": "9.2.24052.212", 

                "userId": "06d7298d-0dad-e611-80f6-5065f38a2991", 

                "aadObjectId": "cbefebc3-3f10-4e9d-87a8-3f3cabd6e2a6", 

                "aadTenantId": "c10ab93c-3306-487c-b557-dfe8dab6c90e", 

                "aadLoginHint": "RDowd@valin.com", 

                "isExternalUser": false, 

                "isLiveId": true, 

                "isReliableOfflineTelemetryEnabled": true, 

                "isSkipNavigatorOnlineCheckEnabled": false, 

                "isDelayTelemetryEnabled": false, 

                "isSkipStackTraceOnWarnTelemetryEnabled": true, 

                "isWorkerThreadTelemetryOptimizationEnabled": false, 

                "isPreserveWebViewStateEnabled": true, 

                "isPersistReduxStoreEnabled": false, 

                "isRTL": false, 

                "localizedStrings": { 

                    "labels": { 

                        "errorWaitingMessage": "We are experiencing some errors while trying to load the application...", 

                        "errorFailedMessage": "Application failed to load", 

                        "errorDetailsLabel": "Show details", 

                        "errorCode": "Error Code", 

                        "sessionId": "Session Id", 

                        "activityId": "Activity Id", 

                        "requestId": "Request Id", 

                        "timestamp": "Timestamp", 

                        "Button_Label_OK": "OK", 

                        "loading": "Loading..." 

                    }, 

                    "errors": { 

                        "UnknownError": { 

                            "errorTitle": "Error", 

                            "errorMessage": "Something has gone wrong. Check technical details for more details." 

                        }, 

                        "Status404": { 

                            "errorTitle": "Not Found", 

                            "errorMessage": "The requested resource does not exist on the server." 

                        }, 

                        "Status500": { 

                            "errorTitle": "Internal Server Error", 

                            "errorMessage": "An error has occurred on the server." 

                        } 

                    } 

                } 

            }; 

            /* Preload calls */ 

            /* Earlier retrieve form data */ 

            !function() { 

                function e(e, t) { 

                    if (window.URL) 

                        return new URL(e).searchParams.get(t); 

                    var n = e.indexOf(t + "="); 

                    if (n > -1) { 

                        var a = t.length + 1 

                          , r = e.indexOf("&", n) 

                          , i = e.indexOf("#", n); 

                        r = r > -1 ? r : e.length, 

                        i = i > -1 ? i : e.length; 

                        var o = Math.min(r, i); 

                        return e.substring(n + a, o) 

                    } 

                    return null 

                } 

                function t() { 

                    return window.location.hostname 

                } 

                var n; 

                function a(e, t) { 

                    return new Promise((function(n, a) { 

                        var r = new XMLHttpRequest; 

                        r.open("GET", e), 

                        window.__preload && (window.__preload.aadObjectId && r.setRequestHeader("x-ms-sw-objectid", window.__preload.aadObjectId), 

                        window.__preload.aadTenantId && r.setRequestHeader("x-ms-sw-tenantid", window.__preload.aadTenantId), 

                        r.setRequestHeader("x-ms-correlation-id", window.__preload.initialActivityId)), 

                        t && t.forEach((function(e, t) { 

                            r.setRequestHeader(t, e) 

                        } 

                        )), 

                        r.onreadystatechange = function() { 

                            if (4 === r.readyState) { 

                                var t = function() { 

                                    return Promise.resolve(JSON.parse(r.responseText)) 

                                } 

                                  , a = 200 === r.status; 

                                n({ 

                                    ok: a, 

                                    status: r.status, 

                                    statusText: r.statusText, 

                                    json: t, 

                                    text: t, 

                                    url: e 

                                }) 

                            } 

                        } 

                        , 

                        r.send() 

                    } 

                    )) 

                } 

                /** 

 * @license Copyright (c) Microsoft Corporation. All rights reserved. 

 */ 

                window.ApplicationCodeExecuteStart = performance && performance.now && performance.now(), 

                window.__preload.initialActivityId = function() { 

                    for (var e = "", t = 0; t < 36; t++) 

                        if (14 === t) 

                            e += "4"; 

                        else if (8 === t || 13 === t || 18 === t || 23 === t) 

                            e += "-"; 

                        else if (19 === t) { 

                            var n = Math.floor(16 * Math.random()); 

                            e += "0123456789abcdef".substr(3 & n | 8, 1) 

                        } else 

                            e += "0123456789abcdef".substr(Math.floor(16 * Math.random()), 1); 

                    return e 

                }(), 

                function(e) { 

                    e[e.Browser = 1] = "Browser", 

                    e[e.MobileApplication = 2] = "MobileApplication", 

                    e[e.MailApp = 3] = "MailApp" 

                }(n || (n = {})), 

                window.clientApiGlobalStoreManager = void 0; 

                var r = window.location.href 

                  , i = e(r, "appid") 

                  , o = function(e) { 

                    var t = parseInt(e, 10); 

                    if (!isNaN(t)) 

                        switch (t) { 

                        case n.Browser: 

                            return "Browser"; 

                        case n.MobileApplication: 

                            return "MobileApplication"; 

                        case n.MailApp: 

                            return "MailApp" 

                        } 

                    return "" 

                }(e(r, "clienthost")) 

                  , s = t().substr(t().indexOf(".")) 

                  , c = new Date; 

                c.setTime(c.getTime() - 864e5), 

                document.cookie = "CrmNativeAuth=;domain=" + s + ";expires=" + c + ";path=/"; 

                var d = [{ 

                    etn: "account", 

                    entitySetName: "accounts" 

                }, { 

                    etn: "contact", 

                    entitySetName: "contacts" 

                }, { 

                    etn: "incident", 

                    entitySetName: "incidents" 

                }, { 

                    etn: "lead", 

                    entitySetName: "leads" 

                }, { 

                    etn: "opportunity", 

                    entitySetName: "opportunities" 

                }]; 

                var l = window; 

                function u(e, t, n, a) { 

                    void 0 === a && (a = !0); 

                    var r = t; 

                    fetch(e, function(e) { 

                        return void 0 === e && (e = !0), 

                        { 

                            headers: { 

                                "Content-Type": "application/json", 

                                Prefer: 'odata.include-annotations="*"', 

                                "x-ms-sw-skipcache": "1", 

                                "MSCRM.ReturnNotifications": e ? "true" : "false" 

                            } 

                        } 

                    }(a)).then((function(e) { 

                        200 === e.status && (l.__Prefetched_formData[r][n] = e) 

                    } 

                    )) 

                } 

                if (i && "null" !== i) { 

                    var p = e(r, "org") || window.__preload && window.__preload.org 

                      , f = (!!e(r, "liveid") || !(!window.__preload || !window.__preload.isLiveId) ? function(e) { 

                        var t = e.split("/"); 

                        return t.length >= 2 ? t[0] + "//" + t[2] : null 

                    }(r) : "/" + p) + "/api/data/v9.0/" 

                      , w = function() { 

                        var e = "GetClientMetadata(ClientMetadataQuery=@ClientMetadataQuery)?@ClientMetadataQuery={%22MetadataType%22:null,%22MetadataSubtype%22:null,%22EntityLogicalName%22:null,%22MetadataId%22:null,%22MetadataNames%22:[],%22GetDefault%22:false,%22DependencyDepth%22:%22UserContext%22,%22ChangedAfter%22:null,%22Exclude%22:[],%22AppId%22:%22".concat(i, "%22}"); 

                        return a(f + e, new Map([["ClientHost", o], ["x-ms-metadatareductionlevel", "2"]])) 

                    } 

                      , m = function() { 

                        try { 

                            if (!(window.caches && window.URL && performance && performance.now)) 

                                return; 

                            var e = new URL(r); 

                            if (!function(e) { 

                                var t = function(e, t, n) { 

                                    var a = e.searchParams.get("flags"); 

                                    if (a) 

                                        for (var r = a.split(","), i = 0; i < r.length; i++) { 

                                            var o = r[i].split("="); 

                                            if (2 === o.length && o[0] && o[1]) 

                                                if (o[0] === "FCB." + t) 

                                                    return o[1].toLowerCase() === (n ? "true" : "false") 

                                        } 

                                    return 

                                }(e, "PersistReduxStore", !0); 

                                if (t || !1 === t) 

                                    return t; 

                                return window.__preload && window.__preload.isPersistReduxStoreEnabled 

                            }(e)) 

                                return; 

                            var t = JSON.parse(localStorage.getItem("uci-state-hint")) 

                              , n = t && t[i]; 

                            if (window.__uciPersistedState = { 

                                isSupportedApp: n ? n.isSupportedApp : void 0 

                            }, 

                            "entityrecord" !== e.searchParams.get("pagetype") || !n || !n.isSupportedApp || !n.persistedForms) 

                                return; 

                            var a = e.searchParams.get("etn") 

                              , o = e.searchParams.get("formid") || n.formDefaults && n.formDefaults[a]; 

                            if (!n.persistedForms.some((function(e) { 

                                return e.entityName === a && e.formId === o 

                            } 

                            ))) 

                                return; 

                            var s = "https://uci-state/" 

                              , c = new URL(n.cachedByFormId ? s + i + "/" + o : s + i + "/") 

                              , d = performance.now() 

                              , l = window.caches.open(s).then((function(e) { 

                                return e.match(c) 

                            } 

                            )).then((function(e) { 

                                return e && e.ok ? e.json() : null 

                            } 

                            )).catch((function() { 

                                return null 

                            } 

                            )); 

                            return window.__uciPersistedState = { 

                                promise: l, 

                                startTime: d, 

                                isSupportedApp: !0, 

                                controlCdnVersion: n.controlCdnVersion 

                            }, 

                            l 

                        } catch (e) {} 

                    }() 

                      , v = m ? m.then((function(e) { 

                        return e && e.userContext ? { 

                            isPersistedUserContext: !0, 

                            userContext: e.userContext 

                        } : w() 

                    } 

                    )) : w() 

                      , h = a(f + "EntityDefinitions?$select=IsActivity,IsVisibleInMobileClient,ObjectTypeCode,LogicalName,DisplayName,DisplayCollectionName,ActivityTypeMask&$filter=IsActivity%20eq%20true"); 

                    window.__uciServerPreload = { 

                        userContext: v, 

                        activityFlags: h 

                    }, 

                    function(e) { 

                        var t = !1; 

                        try { 

                            t = "true" === localStorage.getItem("RetrieveFormDataEarlyEnabled") 

                        } catch (e) {} 

                        if (l.fetch && l.URL && t) { 

                            var n = new URL(r); 

                            if ("entityrecord" === n.searchParams.get("pagetype")) { 

                                var a = void 0; 

                                l.__preload && (a = l.__preload.userId); 

                                var i = n.searchParams.get("etn") 

                                  , o = n.searchParams.get("id") 

                                  , s = void 0; 

                                if (i) 

                                    for (var c = 0; c < d.length; c++) 

                                        if (d[c].etn === i) { 

                                            s = d[c].entitySetName; 

                                            break 

                                        } 

                                if (i && o && s && a) { 

                                    var p = "".concat(i, "_").concat(o) 

                                      , f = "".concat(s, "(").concat(o, ")"); 

                                    l.__Prefetched_formData = {}, 

                                    l.__Prefetched_formData[p] = [], 

                                    u("".concat(e).concat(f), p, 0), 

                                    u(e + "systemusers(" + a + ')/Microsoft.Dynamics.CRM.RetrievePrincipalAccess(Target=@Target)?@Target={"@odata.id":"' + f + '"}', p, 1), 

                                    u(e + 'RetrieveProcessControlData(Target=@Target,ProcessId=@ProcessId,ProcessInstanceId=@ProcessInstanceId)?@Target={"@odata.id":"' + f + '"}&@ProcessId=null&@ProcessInstanceId=null', p, 2) 

                                } 

                            } 

                        } 

                    }(f) 

                } 

                window.onerror || (window.onerror = function(e, t, n, a, r) { 

                    if (t && -1 !== t.indexOf("content.powerapps.com")) { 

                        var i = window.location.search; 

                        window.location.search = (i ? i + "&" : "?") + "useSecondaryCdnEndpoint=true" 

                    } 

                } 

                ) 

            }(); 

        </script> 

        <!-- css --> 

        <link href="https://content.powerapps.com/resource/uci-infra-bus/resources/styles/Styles.4ce9d3bfee43ec16c3b2083b2978d769.css" rel="stylesheet" type="text/css"/> 

    </head> 

    <body> 

        <div id="error-app-loading-indicator"> 

            <div id="app-loading-indicator" class="indeterminateProgressRing"> 

                <div class="progressDot"></div> 

                <div class="progressDot"></div> 

                <div class="progressDot"></div> 

                <div class="progressDot"></div> 

                <div class="progressDot"></div> 

            </div> 

            <div id="errorPopup-container"></div> 

            <div id="errorLoadingMessage" style="opacity: 0"></div> 

        </div> 

        <script type="text/javascript" nomodule src="https://content.powerapps.com/resource/uci-infra-bus/scripts/es5/vendor.352f9100366ad185f622749032516b9f.js" crossorigin></script> 

        <script type="module" src="https://content.powerapps.com/resource/uci-infra-bus/scripts/vendor.b54aaac5970db3c5ddc08c86967e8257.js" crossorigin></script> 

        <script type="text/javascript" nomodule src="https://content.powerapps.com/resource/uci-infra-bus/scripts/es5/corejs.6e29577f11f70c538cb3bc79d6007f3f.js" crossorigin></script> 

        <script type="module" src="https://content.powerapps.com/resource/uci-infra-bus/scripts/corejs.a849e3fa711970f5a9783ca64301a97d.js" crossorigin></script> 

        <script id="errorPopup-template" type="text/template"> 

             

<div class="errorPopup-wrapper"> 

<div id="errorPopup-header"></div> 

<div id="errorPopup-sessionDetails"></div> 

<a href="#" id="errorPopup-detailsLink"></a> 

<div id="errorPopup-technicalDetails"></div> 

</div> 

 

        </script> 

        <script id="waiting-message-template" type="text/template"> 

             

<div id="app-waiting-message"></div> 

 

        </script> 

        <script defer type="text/javascript" src="https://content.powerapps.com/resource/uci-infra-bus/scripts/errorHandlers.8ff6c1a115aeaf7a1de631903ac38a5b.js"></script> 

        <script type="text/javascript" src="https://content.powerapps.com/resource/uci-infra-bus/scripts/MicrosoftAjax.0e42282974e6a0c11842f769c467f9c3.js" crossorigin></script> 

        <div id="shell-container" style="display: flex; overflow: hidden"></div> 

        <script type="text/javascript"> 

            /*~Uci Version Details~*/ 

            var VERSION_NUMERIC_VALUE = "1.4.8733-2405.2"; 

            var LAST_BUILD_TIME = "Wed, 12 Jun 2024 02:24:03 GMT"; 

            var SERVER_VERSION_VALUE = "9100000000" 

            var CLIENT_VERSION_VALUE = "9000000000"; 

        </script> 

        <script type="text/javascript" nomodule src="https://content.powerapps.com/resource/uci-infra-bus/scripts/es5/app.67b45a12e219a52bd6597ecd1b34a870.js" crossorigin></script> 

        <script type="module" src="https://content.powerapps.com/resource/uci-infra-bus/scripts/app.0a9b425c781fa96d170937732606a67f.js" crossorigin></script> 

        <div id="PortalRoot" role="presentation"></div> 

    </body> 

</html> 

 
 
 
 
 
  • Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    Script Error - Form or Security Role
  • CC-25061631-0 Profile Picture
    CC-25061631-0 8 on at
    Script Error - Form or Security Role
    Leah, is it possible that this part of the script is causing an issue? See below. 
    My script error keeps saying "Cannot get properties of null".
     
  • CC-25061631-0 Profile Picture
    CC-25061631-0 8 on at
    Script Error - Form or Security Role
    Hi Leah,
     
    I can confirm all impacted users have already been assigned this role Valin - Customer Service Representative. 
    I have a list of all impacted users and their assigned roles. Attached.
  • Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    Script Error - Form or Security Role
    Hi,
    Based on the code:
    The currently logged in user needs to be assigned this security role: Valin - Customer Service Representative
     
  • CC-25061631-0 Profile Picture
    CC-25061631-0 8 on at
    Script Error - Form or Security Role
    Below is the script for Web Resource Name:valin_checksecurityroles
     
    function checkSecurityRoles(executionContext){
    "use strict";
    
    //get the formContext and globalContext
    var formContext = executionContext.getFormContext(); 
    var globalContext = Xrm.Utility.getGlobalContext();
    //get the rolesArray
    var userRoles = globalContext.userSettings.roles;
    //initialize comparison values
    var roleName = "Valin - Customer Service Representative";
    //set string variables for id values
    var caseAcknowledgement = "new_caseack";
    var securityRoleField = "valin_securityrolerequirement";
    var dateCreated = formContext.getAttribute("createdon").getValue();
    
    //for each item in array
    userRoles.forEach(function hasRoleName(item, index) {
    "use strict";
    
    //Check passed in value for role[].name match and record is new
        if (item.name === roleName && dateCreated == null) {
    formContext.getAttribute(caseAcknowledgement).setValue(false);
    formContext.getAttribute(securityRoleField).setValue(true);
    }
    else{
    }
    });
    }
  • Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    Script Error - Form or Security Role
    Hi,
    Based on you screenshot:
    This web resource should be one custom resource.
    Could you share code about it?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans