Notifications
Announcements
No record found.
Hi All,
I have one form of account entity.
on account record i have sub grid of contact entity.
i need to retrieve the most recently created contact .
can i do this using javascript in CRM 365 9.0?
Are you trying to retrieve most recently created contact in general OR most recently created contact for that particular account (which is already listed in sub-grid)?
In either of the cases, you can retrieve this using javascript api
i am Retrieving most recently created contact for that particular account and that i am populating on another form after clicking on one button on ribbon.
can you share link or code for reference?
Have you already written code and facing any issues?
Or
Are you looking for fresh code
No i have not written any code i dont know which approach to go for
Hi Mona,
Try following code (and run it on your ribbon button) to get most created contact record under current account in Account form:
var currentAccount = Xrm.Page.data.entity.getId().replace('{','').replace('}',''); Xrm.WebApi.retrieveMultipleRecords("contact", "?$select=fullname,createdon&$top=1&$filter=_parentcustomerid_value eq '" currentAccount "'&$orderby=createdon desc").then( function success(result) { for (var i = 0; i < result.entities.length; i ) { // console.log(result.entities[i]); // result.entities[i]["fullname"]; } }, function (error) { console.log(error.message); } );
My code is based on client API: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrievemultiplerecords
You can also generate CRUD code automatically with CRMRestBuilder:
https://github.com/jlattimer/CRMRESTBuilder(an icon will appear in settings > customization after you've imported the solution)
You could take article below as reference for how to add a ribbon button:
https://dynamicscrmtips.com/button-dynamics-crm-ribbon-workbench/
Regards,
Clofly
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 49 Most Valuable Professional
André Arnaud de Cal... 38 Super User 2025 Season 2
#ManoVerse 31