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 / Questions about exclud...
Power Pages
Unanswered

Questions about excluding options of existing records

(0) ShareShare
ReportReport
Posted on by 134

Hi everyone,

 

I want to use Javascript to exclude options of existing records in powerapps portal.

 

The option consists of 2 parts: Prefix number and option set number.

Eg: 801, 802, 803.....   (8 is Prefix and 01,02,03 is option number)

Now I have created 3 records with option 801,802,803.  When creating the 4th one, I hope that  I can't select 01,02,03 for option set number.

 

Now I faced 2 issues.

1. I used Fetch xml to retrieve the existing records.  But failed to set multiple AND filters.

   I want to get records whose status are "Active" and license key matched, but the below didn't work.

   Both Active and Inactive records were retrieved.

{% fetchxml demoData %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
 <entity name="callflow_numberconfig">
 <attribute name="licensekey" />
 <attribute name="autoannounce_number" />
 <attribute name="autoannounce_prefix" />
 <attribute name="statuscode" />
 <filter type="and"> 
 <condition attribute="statuscode" operator="eq" value="0" />
 <condition attribute="licensekey" operator="eq" value="{{request.params['licensekey']}}" />

 </filter>
 </entity>
</fetch>
{% endfetchxml %}
{% if demoData.results.entities.size > 0 %}
{
 "results": [
 {% for item in demoData.results.entities %}
 {
 "License": "{{ item.licensekey }}",
 "Autoannouncenumber": "{{ item.autoannounce_number }}",
 "Prefix": "{{ item.autoannounce_prefix }}"
 }
 {% unless forloop.last %},{% endunless %}
 {% endfor -%}
 ]
}
{% else %}

No data found.

{% endif %}

 

2. How to exclude the existing option set number?  I succeeded to get the existing option set value array.

   But when using the array variable to hide or show option set, it failed.

  

function getexistingop(URL2) {
 var selectLicense = $("#licensekey").val();
 var URL2 = "/fetcharray/?licensekey=" + selectLicense + "";
 {
 $.ajax({
 type: "GET",
 url: URL2,
 dataType: "json",
 async: false
 }).done(function (json) {
 const results = json.results
 const atnum= results.map(result => result.Autoannouncenumber);
 for (i = 0; i < atnum.length; i++) {
 var numaf = atnum[i];
 var atop = numaf.slice( -2 ) ;
 var exceptop = parseInt(atop) + 912129999;
 console.log(exceptop);
 $("#numberselection option[value="+exceptop+"]").hide();
 $("#numberselection option[value!="+exceptop+"]").show();
 };
 });
 }
};

 

Console.log(exceptop)  Output Screenshot:

Audreyma_0-1629280777069.png

 

Categories:
  • NN-05020459-0 Profile Picture
    Microsoft Employee on at

    For issue 1: 

    • Instead of using self-closing tag "<a attr/>", try to use explicit closing tag (like "<a attr></a>"). Sometime autoformatting changes the code and it can cause this issue. Pease confirm if this solves the issue. 

    For Issue 2: 

    • Code looks good, i can only suspect this code might be executing before form loads. Try to use "debugger;"  statement to check if elements are selected correctly. 
    • If thats the case you can included code inside "$( document ).ready". 

    Code example 

    $( document ).ready(function() {
    $("#myselect option[value="+3+"]").hide();
    });

     

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
M Bilal Khan Profile Picture

M Bilal Khan 139

#2
Mohsin Ali Profile Picture

Mohsin Ali 41

#3
11manish Profile Picture

11manish 19 Super User 2026 Season 2

Last 30 days Overall leaderboard