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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error: Refused to set unsafe header "Content-Length"

(0) ShareShare
ReportReport
Posted on by 306

Hi Everyone,

I am trying to run a simple JavaScript for DEACTIVATE button in Action bar of Account entity, DEACTIVATE should be visible to only owner of record.

JavaScript Used:

function controlvisibility()
{
var username = Xrm.Page.context.getUserName();
var userid = Xrm.Page.context.getUserId();
var ownerlookup = Xrm.Page.getAttribute("ownerid").getValue();
var recordownerID = ownerlookup [0].id;
var recordownerName = ownerlookup [0].name;
if(userid == recordownerID)
return true;
else
return false;
}

Any Help will be appreciated.

Regards,

Aman Anvaria

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Error: Refused to set unsafe header "Content-Length"

    Hi Aman,

    Are you experiencing this error in both chrome and IE?

    kindly confirm.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Error: Refused to set unsafe header "Content-Length"

    Hi,

    first of all I would remove what you don't use, i.e. remove

    var username = Xrm.Page.context.getUserName();

    var recordownerName = ownerlookup [0].name;

    then befor accesing the ownerlookup object, you should 1st check if it contains anything and 2nd before compairing value you should also check none are null or empty and put some curly brackets it won't kill you

    here is some code

    if (ownerlookup){

    var recordownerID = ownerlookup [0].id;

    if(userid && userid == recordownerID){

    return true;

    }else{

    return false;

    }

    }

    }

  • Aman Anvaria Profile Picture
    306 on at
    RE: Error: Refused to set unsafe header "Content-Length"

    Hi Rawish,

    Yes, experiencing this for both.

    Chrome: Version 59.0.3071.109

    IE : Version 11

  • Community Member Profile Picture
    on at
    RE: Error: Refused to set unsafe header "Content-Length"

    Could you please post screenshots of the error?

  • Aman Anvaria Profile Picture
    306 on at
    RE: Error: Refused to set unsafe header "Content-Length"

    Hi Guillaume,

    Script doesn't throw any error, but when i debug it following error is encountered.


    Regards,

    Aman Anvaria

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans