Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

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

  • Aman Anvaria Profile Picture
    Aman Anvaria 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

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

    Could you please post screenshots of the error?

  • Aman Anvaria Profile Picture
    Aman Anvaria 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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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;

    }

    }

    }

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans