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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Problem in custom sear...
Power Pages
Unanswered

Problem in custom search filtering

(0) ShareShare
ReportReport
Posted on by 312

Hi comunnity, I'm having difficulty implementing Oleksandr Olashyn's example https://www.dancingwithcrm.com/custom-lookup-filtering-powerapps-portal/. Apparently the filter does not work with my example.

MartinVargas_0-1640710616925.png

 

The dependent field is "Account Name" it doesn't show me anything and it should change based on the "Relationship Type" field.

This is the web template to perform the filter through fetchxml:

MartinVargas_0-1640730454524.png

 

 

And this is the custom JavaScipt that the form has configured:

 

 

$(document).ready(function () {
 // register onPrimaryChange function to run on change of dwc_primarycategorization field
 $("#crb6a_new_relationshiptype").change(onPrimaryChange);
 $("#crb6a_new_relationshiptype").change();
 
 });

function onPrimaryChange(){
 // get id of selected primary field
 // this will work only if you render primary field as dropdown
 let primaryValue = $("#crb6a_new_relationshiptype option:selected").val();
 console.log(primaryValue);
 // remove all option from dependent field
 $("#parentcustomerid").empty();

 if(primaryValue != null && primaryValue !=""){
 // request to our custom page with id as parameter
 $.getJSON( "/pedido/getaccountjson?relationshiptype="+primaryValue, function( data ) {
 if(data.results.length>0){
 //create option for each returned entity
 data.results.forEach(element => {
 let option = document.createElement("option");
 option.value = element.Id;
 option.innerText = element.Name;

 $("#parentcustomerid").append(option); 
 console.log(option);
 });
 } 
 }
 );
 }
}

 

 

 

Can someone help me here?

 

Thanks guys.

 

Categories:
  • OOlashyn Profile Picture
    3,498 Most Valuable Professional on at

    Hi @MartinVargas ,

    My article should work in your example as well. Can you check if your user has proper table permissions to see accounts? You can open a web page that you are using to retrieve data and pass id in the URL to see what response you are getting. If the response is empty and you don't have any errors on the page the problem is with table permissions. If you receive results properly then check your code when you parse the response from the call - try to use console.log to see what results you receive. You might also look into Read Web API (https://docs.microsoft.com/en-us/powerapps/maker/portals/read-operations) as an alternative approach (although API is still in preview).

  • MartinVargas Profile Picture
    312 on at

    Hi @OOlashyn, If in fact, the page that is showing me the fetch does not find the data

     

    MartinVargas_0-1640728783509.png

    If I pass the value through the url it throws me the following error:

     

    MartinVargas_1-1640729150259.png

     

     

     

     

  • OOlashyn Profile Picture
    3,498 Most Valuable Professional on at

    @MartinVargas there is an error in your liquid or in fetchxml statement. I think the problem is with fetchxml - customertypecode is a Choice type column that accepts integer values (like 1, 2 or 100000) and you are trying to pass a string one. Make sure that you are passing correct values and that your fetchxml statement is correct (you can use Xrmtoolbox FetchxmlBuilder to build and test fetchxml and then replace hardcoded values with variables).

  • MartinVargas Profile Picture
    312 on at

    @OOlashyn thanks, fix that part, now the problem I am facing is that it sets me the dependent field as undefined.

    MartinVargas_0-1640732162101.png

     

  • OOlashyn Profile Picture
    3,498 Most Valuable Professional on at

    @MartinVargas undefined mean that instead of a proper object you receive or parse value unproperly. Please try using console log to find what data you receive back and also try to go through the code step by step in debug mode to see where you are losing data.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 35

#2
M Bilal Khan Profile Picture

M Bilal Khan 33

#3
11manish Profile Picture

11manish 21 Super User 2026 Season 2

Last 30 days Overall leaderboard