I have a simple asynchronous function to get the current enviorment variable .I am trying to use this function marked in red in another sync function but getting value as promise pending. I know I am making an error calling this function. Can I get the idea how to call it and utilize it?
// Asysc to get enviornment variable
GetEnvironmentVariableValue function(name){let results =await Xrm.WebApi.retrieveMultipleRecords("environmentvariabledefinition",`?$filter=schemaname eq '${name}'&$select=environmentvariabledefinitionid&$expand=environmentvariabledefinition_environmentvariablevalue($select=value)`);if(!results ||!results.entities || results.entities.length <1)returnnull;let variable = results.entities[0];if(!variable.environmentvariabledefinition_environmentvariablevalue || variable.environmentvariabledefinition_environmentvariablevalue.length <1)returnnull;return variable.environmentvariabledefinition_environmentvariablevalue[0].value;// returning the value that I want. current value of env varibale}
//Calling it to another function and getting value as promise pending
UseCurrentValue :function (e) {
//var formContext= e.getFormContext();
varalertStrings = { confirmButtonLabel:"Ok", text:"Please wait for it to open an new form.", title:"INFORMATION:" };
varalertOptions = { height: 300, width: 350 };
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
functionsuccess(result) {
var envURL= getEnvironmentVariable("new_variable");// Promise Pending
console.log(envURL); // promise pending
...rest od the code..no need to see..
}}







