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 / Exclude an option in e...
Power Pages
Unanswered

Exclude an option in edit page if it has been selected in other records

(0) ShareShare
ReportReport
Posted on by 134

Hi everyone,

 

I have an option set field in edit page.

 

Now I hope that when entering the edit page, I can only select options which hasn't been select in other records (my current option should be selectable ).

However, with the below code, when opening the edit page, my current option will be deselected and will be hided with other selected options.

Audreyma_1-1630554524959.png

 

Audreyma_2-1630554577660.png

 

Below is the code I'm using, any advice about it?

I use fetchxml to retrieve all options selected in existing records(including the current option ), the final results are saved in "oparr" array.

curoption is the option which I selected in current edit page.  "exop" is the array which I excluded curoption from "oparr" array.

function getexistingop(URL2) {
 var selectLicense = $("#licensekey").val();
 var URL2 = "/fetcharray/?licensekey=" + selectLicense + "";
 {
 $.ajax({
 type: "GET",
 url: URL2,
 dataType: "json",
 async: false
 }).done(function (json) {
 var curoption = parseInt($("#numberselection").val());
 const results = json.results
 const atnum= results.map(result => result.Autoannouncenumber);
 const newarr = atnum.map(arr => arr.slice(-2));
 const oparr = newarr.map(exop=> Number(exop) + 912129999);
 const exop = oparr.filter(val => val !== curoption);
 for(var i=0; i < exop.length; i++){
 $("#numberselection option[value="+exop[i]+"]").hide();
 };
 }).fail(function(jqXHR, textStatus, errorThrown){
 $("#numberselection option").show(); 
 }); 
 }
};

$(document).ready(function () {
 $("#licensekey").change(function () { getexistingop(); });
 $("#licensekey").change()
});

 

Categories:

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 18

#2
11manish Profile Picture

11manish 16 Super User 2026 Season 2

#3
anirudhev Profile Picture

anirudhev 4

Last 30 days Overall leaderboard