Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Problems with "retrieveRecord"

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi guys,

I have a problem when I try to get a record using the next sentence:

SDK.REST.retrieveRecord(subscriberId,"Account", null, null, foundsubscriber, functionError);

This is executed in the onload event of the form.

The problem is sometimes enters the function "foundsubscriber" and others do not with the same "subscriberId". This is a strange behavior of CRM 2016 and I can't found a reason.

Do you have any idea?

*This post is locked for comments

  • Verified answer
    JohnAnonymous Profile Picture
    JohnAnonymous 5,241 on at
    RE: Problems with "retrieveRecord"

    And the functionError callback is not executed when it's not working?

    You could als add a debugger statement above the error line to check the values you are sending to the rest call.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Problems with "retrieveRecord"

    Hi Karan5959,

    This is the code:

    function getSubscriber(subscriberId)

    {

      if(subscriberId == null)

      {

        var subscriberRef  = Xrm.Page.getAttribute("accountsubscriptionid").getValue();

        subscriberId = subscriberRef[0].id

      }

      function foundsubscriber(sus)

      {

           subscriber = sus;

           function CorporateSubscriber(susCorpo)

           {

               subscriberCorpo = susCorpo;

               Xrm.Page.ui.refreshRibbon();

           }

           if(subscriber.ParentAccountId != null && subscriber.ParentAccountId.Id != null)

              SDK.REST.retrieveRecord(subscriber.ParentAccountId.Id,"Account", null, null, CorporativoSubscriber, functionError);

           Xrm.Page.ui.refreshRibbon();

      }

      if(subscriberId != null)

         SDK.REST.retrieveRecord(subscriberId,"Account", null, null, foundsubscriber, functionError);

    }

    The problem is in the line: <<SDK.REST.retrieveRecord(subscriberId,"Account", null, null, foundsubscriber, functionError);>>

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Problems with "retrieveRecord"

    I have an error in console but I do not think it has anything to do with the problem:

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

    But sometimes works well, this discard it a permission error.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Problems with "retrieveRecord"

    Hi HMBA,

    could you please give us some more details on your issue. Is it possible to share your code?

    Regards,

    Karan

  • Suggested answer
    JohnAnonymous Profile Picture
    JohnAnonymous 5,241 on at
    RE: Problems with "retrieveRecord"

    Do you get any errors in the browser console when it's not working? Are you sure it's not a permission error?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans