web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Return value is coming as Undefined in in webapi in JS

(0) ShareShare
ReportReport
Posted on by 20

i am trying frame this below code , when i am returing value into the 1st function i am getting process as undefined , can anyone guide me how to achive it.

dnd.Webresources.Application = {
ProcessValidation : false,
SupportedApplicationReadOnly : function(executionContext) {
var formContext = executionContext.getFormContext();
var businessunitId = formContext.getAttribute("dnd_applicationrootbusinessunit").getValue()[0].id;
businessunitId = businessunitId.substring(1, businessunitId.length - 1);
// To get child record count //
var process = dnd.Webresources.Application.Process(businessunitId);
alert(process);
},

Process: function (businessunitId) {

var query = "?$expand=dnd_businessunit_dnd_process_businessunit($select=dnd_processid)";
Xrm.WebApi.online.retrieveRecord("businessunit", businessunitId, query).then(
function success(results) {
var businessunitid = results["businessunitid"];
if (results.dnd_businessunit_dnd_process_businessunit.length > 0) {
return true;
} else {
return false;
}
},
function (error) {
Xrm.Utility.alertDialog(error.message);
}
);
}
}

regards,

vinay 

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    This is due to Asynchronous call as now days most of the browser does not support (deprecated)client side Synchronous call. So try to write code in the same function instead of calling different method. And inside success method do your operation by getting the value.

    If I am not wrong seen your another post hiding ribbon button ,I have given you sample blog reference written by Andrew Butenko , which should work for you.

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/373883/i-need-to-hide-home-grid-button-based-on-return-values-in-javascript

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 98 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 72

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans