web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Minimum permissions required to run JS on one entity (CASE)

(0) ShareShare
ReportReport
Posted on by 790

Dear all

i have created a new security role to allow certain users/teams to only login to the system and resolve certain types(subjects) of cases.

the problem is that i have two CASE forms, one is the default (for most of the subjects), and one CASE form is for a certain subject (let us say SubjectXYZ), i also have a JS on form loading that checks the subject of the case and switches the form accordingly.

now the problem is : the cases with SubjectXYZ are opened on the default CASE form which is wrong, it happens because for some reason the OnLoad JS code does not run to switch to the right form.

can you please help me how to adjust the security role to allow executing this JS file in order to make the CASE form switches depending on the case subject?

thanks,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Prashant_ Profile Picture
    1,040 on at

    If your JS doing some Web API call to retrieve some data then you have change read access level of entity which you are querying using Web API but if you have given appropriate read access then you need to debug your JS then you might get idea why JS not working properly

  • Ahmad Saud Profile Picture
    790 on at

    thanks for your reply, but i am not using any WebAPIs, i am just checking the value of the subject and then decide which form to load.

    thanks,

  • Suggested answer
    Prashant_ Profile Picture
    1,040 on at

    did you debug your script ? because you didn't get any error means there must  be simple logical error in script that why your condition to load form code not  executing.

  • Ahmad Saud Profile Picture
    790 on at

    sorry, i forgot to mention that i got some errors in the debugger, please check below.

    Fetch successful for configuration data from Web API fwlink:72:25

    Load successful for configuration data in variables fwlink:75:25

    unreachable code after return statement[Learn More] ribbon.js:1:151500

    Attempt to set a forbidden header was denied: Content-Length global.ashx:6868:913032

    Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ global.ashx:6868:912701

    Attempt to set a forbidden header was denied: Content-Length global.ashx:6868:913032

    go.microsoft.com/fwlink loaded msdyn_LoadGuidedHelp.js:139:13

    go.microsoft.com/fwlink loaded msdyn_LoadNPSSurvey.js:28:13

    Fetch successful for configuration data from Web API fwlink:72:25

    Load successful for configuration data in variables fwlink:75:25

    Info: Configuration variables from MarsBootStrap.js are set correctly. marsloader.js:1:5463

    marsloader.js loaded fwlink:123:29

    crmprodnpssurvey.azureedge.net/.../NPSSurvey.js loaded fwlink:166:21

    unreachable code after return statement[Learn More] ribbon.js:1:151500

    unreachable code after return statement[Learn More] lookup.js:372:4

    Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ global.ashx:6868:589726

    crmprodnpssurvey.azureedge.net/.../NPSSurvey.css loaded NPSSurvey.js:1139:21

    crmprodnpssurvey.azureedge.net/.../applicationinsights.js loaded NPSSurvey.js:1094:21

    Attempt to set a forbidden header was denied: Content-Length global.ashx:6868:913032

    The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.

    blank.htm

    jquery-ui-1.9.2.custom.css loaded marsloader.js:1:37760

    ui.jqgrid.css loaded marsloader.js:1:37760

    Attempt to set a forbidden header was denied: Content-Length global.ashx:6868:913032

    crmprodnpssurvey.azureedge.net/.../NPSTelemetry.js loaded NPSSurvey.js:1094:21

    marsv2prodcdn.azureedge.net/.../jquery-2.1.3.min.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../jquery-ui.min.js loaded marsloader.js:1:38583

    The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.

    blank.htm

    marsv2prodcdn.azureedge.net/.../handlebars.js loaded marsloader.js:1:38583

    The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.

    blank.htm

    marsv2prodcdn.azureedge.net/.../CssWatch.js loaded marsloader.js:1:38583

    The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.

    blank.htm

    marsv2prodcdn.azureedge.net/.../jquery.jqGrid.min.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../jquery.ui.touch-punch.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../underscore.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../backbone.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../MarsUtility.js loaded marsloader.js:1:38583

    Max Session timeout started and monitoring page:  instance-sb.crm4.dynamics.com/main.aspx;id=7fa365cb-084e-e911-a834-000d3a2aa32f&histKey=284923582&newWindow=true&pagetype=entityrecord#729859363 maxsessionmonitor.js:517:9

    Attempt to set a forbidden header was denied: Content-Length

    global.ashx:6868:913032

    marsv2prodcdn.azureedge.net/.../locale.js loaded marsloader.js:1:38583

    The character encoding declaration of the framed HTML document was not found when prescanning the first 1024 bytes of the file. When viewed without the document framing it, the page will reload automatically. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.

    new_HTML_Button_for_Case:82

    marsv2prodcdn.azureedge.net/.../DesignerActions.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../MarsContextResolution.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../RuntimeActions.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../Crossdomain.js loaded marsloader.js:1:38583

    Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ ClientApiWrapper.aspx:254

    Info: Configuration variables from MarsBootStrap.js are set correctly. marsloader.js:1:5463

    marsv2prodcdn.azureedge.net/.../jquery-2.1.3.min.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../jquery-ui.min.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../handlebars.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../CssWatch.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../jquery.jqGrid.min.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../jquery.ui.touch-punch.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../underscore.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../backbone.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../MarsUtility.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../locale.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../MarsContextResolution.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../DesignerActions.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../RuntimeActions.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../Crossdomain.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../MarsCustomScripts.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../MarsValidator.js already loaded marsloader.js:1:38342

    jquery-ui-1.9.2.custom.css already loaded marsloader.js:1:37514

    ui.jqgrid.css already loaded marsloader.js:1:37514

    marsv2prodcdn.azureedge.net/.../MarsCustomScripts.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../MarsEncodeDecode.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../ServiceProxy.js already loaded marsloader.js:1:38342

    Learning Path Load Script callback error: TypeError: Loader.ServiceProxy is undefined marsloader.js:1:38194

    marsv2prodcdn.azureedge.net/.../MarsValidator.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../MarsEncodeDecode.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../LpDynamicContextLib.js already loaded marsloader.js:1:38342

    marsv2prodcdn.azureedge.net/.../ServiceProxy.js loaded marsloader.js:1:38583

    marsv2prodcdn.azureedge.net/.../LpDynamicContextLib.js loaded marsloader.js:1:38583

    Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ MarsIframe.js:441:28

    Script error. in marsv2prodcdn.azureedge.net/.../MarsUtility.js at 0:0  null JsProvider.ashx:35:9496

    AI: CannotSerializeObjectNonSerializable message:"Attempting to serialize an object which does not implement ISerializable" props:"{name:baseData}" Logging.ts:203:20

    TypeError: n.Client.Loader.logger is undefined[Learn More] MarsUtility.js:1:80197

    Source map error: request failed with status 404

    Resource URL: instance-sb.crm4.dynamics.com/.../JsProvider.ashx;ver=846317206

    Source Map URL: bootstrapper.js.map;[Learn More]

  • Suggested answer
    Prashant_ Profile Picture
    1,040 on at

    Can you share your code ? and in debug session where it threw exception in code?

  • Ahmad Saud Profile Picture
    790 on at

    please find my code,and it starts throwing the errors from loading time onward until loading completes.

    function OnLoadFormSelector() {

       var formtype = Xrm.Page.ui.getFormType();

       if ((Xrm.Page.ui.getFormType() == 2) || (Xrm.Page.ui.getFormType() == 4)) { // This will trigger only when Update form

           var lblForm;

           var Subject = GetText("subjectid");

           switch (Subject) {

               case "Menu Upload":

                   lblForm = "Menu-Upload Case Form"; // Replace Form name based on optionset value

                   break;

               default:

                   lblForm = "Case";

               //alert("default form selected");

           }

           var formLabel = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();

           if (Xrm.Page.ui.formSelector.getCurrentItem().getLabel() != lblForm) {

               var items = Xrm.Page.ui.formSelector.items.get();

               for (var i in items) {

                   var item = items[i];

                   var itemId = item.getId();

                   var itemLabel = item.getLabel()

                   if (itemLabel == lblForm) {

                       if (itemLabel != formLabel) {

                           item.navigate();

                       }

                   }

               }

           }

       }

    }

  • Verified answer
    Prashant_ Profile Picture
    1,040 on at

    1.remove (Xrm.Page.ui.getFormType() == 4) from condition

    2.I assume var Subject = GetText("subjectid");  you treating subject field as lookup and reading its value as a lookup and Subject variable contains text value rather that lookup value

    3.cross check  text value assigned to lblForm variable.

    In debuggin session check values above variable during comparison and where your code is throwing  

  • Ahmad Saud Profile Picture
    790 on at

    Hi Prashant

    the code does not need any modification, it works fine.

    but as i mentioned, it does not work only for the new security role which i mentioned in my first post, so i think some permissions are missing to allow running this script.

    thanks

  • Suggested answer
    Prashant_ Profile Picture
    1,040 on at

    You don't need to change security role unless you are doing WEB API call .Try to debug script you will get problem where your code not working.

    Following blog help you to debug script.

    debajmecrm.com/.../dynamics-crm-debug-web-resources

  • Ahmad Saud Profile Picture
    790 on at

    thanks, i will try and update you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans