Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Need help using SDK.Rest.retrieveRecord not obtaining guid record data. Error 404 "Resource not found for the segment "accountset"

Posted on by 507

Hi, Need assistance using SDK.Rest. retrieveRecord trying to add the primary contact from the Account form to the Lead form when the existing customer type is account .They do not want existing customer leads put in as opportunities right away as there is a high percentage of "maybe i will buy", so Out of box CRM process does not work. Don't want to use a calculated field to map from account in order to allow primary contact ability to be changed in the lead entity. 

I have added SDK.REST.js to the form library.  Receiving "Error 404 Resource not found for the segment "accountset".

I have checked the GUID ID that is passed to the SDK.REST.retrieveRecord and it matches the account guid.

Here is the code:

function UpdateLeadInfo(){

var customer=Xrm.Page.getAttribute("customerid").getValue()[0].id;
var accountname=Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].name;
if(customer != null){
var custype=Xrm.Page.getAttribute("customerid").getValue()[0].entityType;
if(custype=="contact"){
var ContactName=Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].name;
var mysplit=ContactName.split(" ");
var fname=mysplit[0];
var lname=mysplit[1];
Xrm.Page.data.entity.attributes.get("firstname").setValue(fname);
Xrm.Page.data.entity.attributes.get("lastname").setValue(lname);
} else if (custype == "account") {
var accountname = Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].name;
alert("name is" + accountname);
var customera = Xrm.Page.getAttribute("customerid").getValue()[0].id;
alert("id is" + customera);
Xrm.Page.data.entity.attributes.get("companyname").setValue(accountname);
var columns = "name, primarycontactid";
SDK.REST.retrieveRecord(customera, "account", columns, null,
function (result) {
UpdatePcontact(result);
}, function (error) {
alert(error.message);
}
);
}
}
}
function UpdatePcontact(result){
var pcontact=result.primarycontactid;
if(null !=pcontact){
Xrm.Page.getAttribute("newbtss_primarycontact").setValue([{ id: pcontact.Id, name: pcontact.Name, entityType: pcontact.LogicalName }]);
}
}

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Need help using SDK.Rest.retrieveRecord not obtaining guid record data. Error 404 "Resource not found for the segment "accountset"

    Ok try to open in chrome browser please.

  • Carol J Kelly Profile Picture
    Carol J Kelly 507 on at
    RE: Need help using SDK.Rest.retrieveRecord not obtaining guid record data. Error 404 "Resource not found for the segment "accountset"

    Hi Goutam,

    I added in the CRM Rest builder but it took forever to load the entities. Very large solution, in fact it stalled. Ended up doing it using C# plugin. the old way :(

    Thanks :)

  • Carol J Kelly Profile Picture
    Carol J Kelly 507 on at
    RE: Need help using SDK.Rest.retrieveRecord not obtaining guid record data. Error 404 "Resource not found for the segment "accountset"

    Thanks .. Will give it a try in the AM!!

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Need help using SDK.Rest.retrieveRecord not obtaining guid record data. Error 404 "Resource not found for the segment "accountset"

    Hi Carol ,

    Please have a look below thread -

    community.dynamics.com/.../221480

    In addition I would suggest download CRMRESTBuilder and import the solution to your instance, you can easily generate code to retrieve data using CRM API.

    github.com/.../releases

  • Suggested answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: Need help using SDK.Rest.retrieveRecord not obtaining guid record data. Error 404 "Resource not found for the segment "accountset"

    The SDK.Rest Javascript library is old and from memory the person who wrote it no longer supports it. It also uses the old CRM 2011 Soap API which is deprecated and may be removed in the next April release.

    github.com/.../CRMRESTBuilder is a tool that will generate the code you want using the new web APIs...

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans