Share via

Xrm.WebApi.retrieveMultipleRecords

Anonymous
2024-06-21T09:21:41+00:00

Hello,

How can it be possible that the function rm.WebApi.retrieveMultipleRecords("teammembership", query) no longer works and throws an error when executed.

Execution in Forms Model Driven APP.

The function previously worked without any problems.


function hideTabBasedOnTeams(executionContext, tabName, teamIds) { var formContext = executionContext.getFormContext();var userId = Xrm.Utility.getGlobalContext().userSettings.userId.replace(/[{}]/g, ''); // Remove braces from userId

// Split the comma-separated list of team IDs into an arrayvar teamIdArray = teamIds.split(',');

// Define a filter query for checking membership in any of the specified teamsvar filterQuery = teamIdArray.map(teamId => teamid eq ${teamId.trim()}).join(' or ');

// Define the query to check team membershipvar query = /teammemberships?$filter=systemuserid eq ${userId} and (${filterQuery});

// Retrieve records to check if the user is in any of the specified teamsXrm.WebApi.retrieveMultipleRecords("teammembership", query).then(function success(result) {if (result.entities.length === 0) {// Hide the tab if the user is not in any of the allowed teamsformContext.ui.tabs.get(tabName).setVisible(false);} else {// Show the tab if the user is in at least one of the allowed teamsformContext.ui.tabs.get(tabName).setVisible(true);}},function error(error) {console.error("Error checking team membership: " + error.message);

// Optional: Display an alert to the userXrm.Navigation.openAlertDialog({text: "An error occurred while checking team membership. Please contact your system administrator.",title: "Error"}).then(function () {// Hide the tab as a fallback if the check failsformContext.ui.tabs.get(tabName).setVisible(false);});});}

Thanks for the help.

Microsoft 365 and Office | Install, redeem, activate | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-06-21T10:03:29+00:00

    Hello MK2023_Bass,

    Thank you for reaching out to the Microsoft community team regarding your inquiry about "Xrm.WebApi.retrieveMultipleRecords."

    However, please note that as a community team, our resources are limited in terms of reviewing and providing guidance on specific code implementations. To ensure you receive the most accurate and comprehensive support for your query, we recommend contacting the Office Development - Microsoft Q&A platform.

    The Office Development - Microsoft Q&A platform is designed specifically for developers seeking detailed technical guidance and assistance on Microsoft technologies, including Dynamics 365 and related APIs such as Xrm.WebApi.retrieveMultipleRecords. You can post your question there to get expert advice and support from the Developer Community and product teams. Here is the link to Office Development - Microsoft Q&A: Office Development - Microsoft Q&A

    Feel free to ask your question there, and the Microsoft Developer Community experts will be able to provide you with a proper guideline tailored to your specific needs.

    Thank you for your understanding, and we look forward to your continued participation in our community.

    Sincerely,

    Nafis Iqbal Shuvo

    Was this answer helpful?

    4 people found this answer helpful.
    0 comments No comments