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:

Report
All responses (
Answers (