My company are developing a Power Page which will act as an Admissions portal for applicants in an educational context. We have a multistep form and have been following this guide https://www.dancingwithcrm.com/custom-lookup-filtering-powerapps-portal/, to filter some lookups because old entry years / previous programmes should not be an option displayed since are outdated but must remain in the choice since removal would affect historical data.
I built the web template, web page, and added custom script to the specific step on the multistep form which appends the options to the drop down for the relevant attributes - drop downs configured with metadata. In the power page front end editor, I can see the returned data is as expected on the page which acts as an endpoint, but when I preview and go to the form page, the options list is empty for the attribute and accessing the endpoint page in the preview demonstrates its returning an empty array/dict. I will add screenshots for context. Once I noticed the discrepancy I tried using postman on the endpoint and similarly the returned data is empty. I don't understand how the front end editor can show the data but elsewhere the endpoint is not working.




$(document).ready(function() {
$.ajax({
method: "GET",
url: "/yoe-json-api/",
cache: false,
headers: {
"Content-Type": "application/json"
}
})
.done(function(data) {
console.log("API response:", data); // Log the data received from the API
// Clear any existing options
$("#ans_yearofentry").empty();
// Check if data.results is an array and has elements
if (Array.isArray(data.results) && data.results.length > 1) {
data.results.forEach(element => {
let option = document.createElement("option");
option.value = element.yearOfEntry;
option.innerText = element.yearOfEntry;
// Append the new option to the select element
$("#ans_yearofentry").append(option);
});
} else {
console.log("No results found");
}
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.error("Year of entry API call failed with status: " + textStatus);
console.error("Error: " + errorThrown);
});
});
Ultimately, I'd like to know is there a reason for the discrepancy? Also how can I achieve the intended behaviour for the lookups?
Any help is much appreciated, thanks, Kaitlyn .