Hello,
I am having issues with a component which is supposed to call an API that fetches the user's IP to block / allow him access to the app if its IP is in between the IPs range set.
I am not sure it is the better solution for powerapp but I am still learning.
I have put the following code in the "OnStart" property of the app (the commented block is another try) :
ClearCollect(
'MyIpRanges',
{
StartIP:"xyz.abc.138.150",
EndIp:"xyz.abc.138.151"
}
);
/*ClearCollect(
'CanonIPs',
{firstIP:"a.b.177.31"},
{secondIP:"c.d.177.32"},
{backupIP:"e.f.48.206"}
)
;*/
Set(MyIp,'contoso_contoso.whitelist(00000001-0000-0000-0001-00000000009b)1'.OutPut);
If(IsBlank(MyIp) || CountRows(
Filter(
MyIpRanges,
(Value(Substitute(MyIp,".",""))) >= (Value(Substitute(StartIP,".",""))) &&
(Value(Substitute(MyIp,".",""))) <= (Value(Substitute(EndIp,".",""))))) = 0,
Navigate(RestrictedAccess),
Navigate(Screen1)
);
I am getting the following error for 'MyIpRange' variable : "This name is not valid. This identifier is not recognizable."
The 'OnStart' property is showing "Unexpected characters. Formula contains "ParenClose" when "Error" is expected.
Thanks in advance for your help !
Loïc.
Solved! Go to Solution.
@Anonymous
The existing reference is no longer valid so I would try changing it as follows:
Set(MyIp; ipWhitelistComponent1.OutPut);
@Anonymous
As it appears that you're using Power Apps in French, I would try replacing the , characters with ; like so:
ClearCollect(
'MyIpRanges';
{
StartIP:"xyz.abc.138.150";
EndIp:"xyz.abc.138.151"
}
);;
/*ClearCollect(
'CanonIPs';
{firstIP:"a.b.177.31"};
{secondIP:"c.d.177.32"};
{backupIP:"e.f.48.206"}
)
;;*/
Set(MyIp;'contoso_contoso.whitelist(00000001-0000-0000-0001-00000000009b)1'.OutPut);;
If(IsBlank(MyIp) || CountRows(
Filter(
MyIpRanges;
(Value(Substitute(MyIp;".";""))) >= (Value(Substitute(StartIP;".";""))) &&
(Value(Substitute(MyIp;".";""))) <= (Value(Substitute(EndIp;".";""))))) = 0;
Navigate(RestrictedAccess);
Navigate(Screen1)
);;
@timlThank you for your assistance, it did solve an issue and opened several others (as expected 😀)
One of them is the "Name is not valid. Identifier is not recognized" for this line :
Set(MyIp; 'dev_contoso.whitelist(00000001-0000-0000-0001-00000000009b)1'.OutPut);
Could you please assist me again ?
Regards,
Loïc.
Hi @Anonymous
I assume 'dev_contoso.whitelist(00000001-0000-0000-0001-00000000009b)1' is a reference to a custom connector. If that's missing from your app, that would return a 'Name is not valid' error.
Hi @timl ,
It is a reference to a custom component that I added :
It was imported with its solution.
Edit : I had forgotten to tag you
@Anonymous
The existing reference is no longer valid so I would try changing it as follows:
Set(MyIp; ipWhitelistComponent1.OutPut);
Thanks again for your help.
It is weird that when I import my coded component, two of them appear and the second 'whitelist' does contain the output I need as shown in this screenshot when I execute this command in my directory:
npm start run
I have tried to test it and display 'MyIp' in a label by setting the 'OnChange' property of a button with :
Set(MyIp; Text(whitelist2.OutPut))
But I get "Uncompatible type" wether I try to cast the SingleLine.Text result or not.
I figured I called this variable elsewhere in my canvas, now I have to figure how to debug my component not loading.
Thanks a lot for your help !
I figured I called this variable elsewhere in my canvas, now I have to figure how to debug my component not loading.
Thanks a lot for your help !