web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    RE: Return value is coming as Undefined in in webapi in JS

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 235

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 177

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 156 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans