Hi community, I am having the following problem. It happens that I implement a filter with javascript to show me only certain data.
The code is the following:
$(document).ready(function () {
var list = $("#crd4f_clavearticuo_lookupmodal").find(".entity-lookup").find(".entity-grid").eq(0);
list.on("loaded", function () {
var IdListaPrecio = "{{user.crd4f_listaprecios}}";
console.log("IdListaPrecio: " + IdListaPrecio);
if (IdListaPrecio == IdListaPrecio) {
list.find("table tbody > tr").each(function (index, value) {
var tr = $(this);
var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("data-value");
if (tipos != IdListaPrecio) {
console.log("Tipos: " + tipos);
$(tr).remove();
}
});
}
});
});
However, when performing this procedure it shows me the result of the filter between all the pages. For example, the first page does not show me any data:
In this example, the results of my filter start to appear until page number 3:
Is there a way to remove a blank page through javascript?. Or is there some way to solve this?
Can anybody help me out here please?
Cheers folks
Hi @MartinVargas ,
no answer, but could it be, that this is the mobile view and the data is split up intop several single "pages"?
When you remove the pagecontent i would assume, that the pagenavigation is not removed. So, i assume that you also have to remove the corresponding buttons when you remove a specific entry which you do not want to see.
If the attribute you are filtering on is a lookup, there is an easier way to filter the stuff: just place the lookup on the form, too and choose in the lookup you want to filter "only related records" and choose the right relation. Then only related records are shown. (you may hide the lookup on the form by js)
Ah, you are filtering over a user attribute. When the user should only see valid entries for hers/his user you might conider an entitytablepermission for that. Just create one in contact scope for the targettable which only selects entities which are allowed and assigned it to an appropiate role.
Just a couple of ideas, may be it helps.
Have fun,
Christian
my suggestion is to use Add pre-search on relevant look up filed to filter data displayed in look up view...
Refer following example article for this..
https://www.inogic.com/blog/2015/08/apply-custom-filter-on-lookup-field-in-dynamic-crm-using-script/
Hi,
try below code
What is the data type of this crd4f_idlistaprecios?
$(document).ready(function () {
var list = $("#crd4f_clavearticuo_lookupmodal")..find(".entity-lookup").find(".entity-grid").eq(0);
list.on("loaded", function () {
var IdListaPrecio = "{{user.crd4f_listaprecios}}";
console.log("IdListaPrecio: " + IdListaPrecio);
list.find("table tbody > tr").each(function () {
var tr = $(this);
var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("data-value");
if (tipos != IdListaPrecio) {
console.log("Tipos: " + tipos);
$(tr).remove();
}
});
});
});
Hi @Soundharya.
The data type "$(tr).find('td[data-attribute="crd4f_idlistprices"]').attr("data-value");" is Text.
Here: "types != PriceListId" I am comparing all the list types in the crd4f_priceidlist column against the list type associated with the user.
Both are text fields right then above code should work can you try once, i have modified few
Hi @Soundharya, By implementing the following code:
$(document).ready(function () {
var list = $("#crd4f_clavearticuo_lookupmodal")..find(".entity-lookup").find(".entity-grid").eq(0);
list.on("loaded", function () {
var IdListaPrecio = "{{user.crd4f_listaprecios}}";
console.log("IdListaPrecio: " + IdListaPrecio);
list.find("table tbody > tr").each(function () {
var tr = $(this);
var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("aria-label");
if (tipos != IdListaPrecio) {
console.log("Tipos: " + tipos);
$(tr).remove();
}
});
});
});
It keeps showing me blank pages:
first line there was mistake 2 dots
var list = $("#crd4f_clavearticuo_lookupmodal").find(".entity-lookup").find(".entity-grid").eq(0);
we are trying to remove the row there is no way it will get added, is there any other code on this?
can you paste full code?
i have done the same it is working for me
Hi @Soundharya. This is literally all the code.
$(document).ready(function () {
var list = $("#crd4f_clavearticuo_lookupmodal").find(".entity-lookup").find(".entity-grid").eq(0);
list.on("loaded", function () {
var IdListaPrecio = "{{user.crd4f_listaprecios}}";
console.log("IdListaPrecio: " + IdListaPrecio);
list.find("table tbody > tr").each(function () {
var tr = $(this);
var tipos = $(tr).find('td[data-attribute="crd4f_idlistaprecios"]').attr("aria-label");
if (tipos != IdListaPrecio) {
console.log("Tipos: " + tipos);
$(tr).remove();
}
});
});
});
I got it based on Oliver Rodrigues's exercise: https://oliverrodrigues365.com/2021/01/24/power-apps-portals-custom-lookup-filter/
Ya even i tried this , unfortunately this code runs on each page not on all records may be you don't have the data or check on next pages for matching data
i have one record matching in 1st page and other in 2nd page
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |