Hello All,
I created a custom Add-In with number of groups and buttons.
I want to activate this add-in with all groups and buttons only if I am logged in to ArcGIS Pro using ArcGIS Enterprise credentials.
Please support,
Thank you.
Solved! Go to Solution.
You can use states and conditions.
In DAML, create this condition:
...
<conditions>
<insertCondition id="my_condition_Online">
<and>
<state id="esri_core_isSignedIn" />
</and>
</insertCondition>
</conditions>
</ArcGIS>
Then, add this condition to your control. Like this in config.daml
<tab id="EsriCommunity_Tab1" caption="New Tab" condition="my_condition_Online">
You can use states and conditions.
In DAML, create this condition:
...
<conditions>
<insertCondition id="my_condition_Online">
<and>
<state id="esri_core_isSignedIn" />
</and>
</insertCondition>
</conditions>
</ArcGIS>
Then, add this condition to your control. Like this in config.daml
<tab id="EsriCommunity_Tab1" caption="New Tab" condition="my_condition_Online">
Thank you for your support.
This worked, the tab is already visible while Pro is signed in.
What if I want to customize this signed in state to be only for Enterprise (not for public account or even Online Organization) ??
public class SignInChecker
{
public static bool CheckSignInArcGISOnline()
{
bool signIn = false;
signIn = QueuedTask.Run(() =>
{
// Get the active portal
var activePortal = ArcGISPortalManager.Current.GetActivePortal();
// Check if the active portal is ArcGIS Online or ArcGIS Enterprise
if (activePortal != null)
{
var user = activePortal.GetSignOnUsername();
if (string.IsNullOrEmpty(user))
{
Console.WriteLine("User is not signed in.");
return false;
}
else
{
var portalUri = activePortal.Uri;
if (portalUri.Host.Contains("arcgis.com"))
{
Console.WriteLine($"User is signed in to ArcGIS Online as: {user}");
return true;
}
else
{
Console.WriteLine($"User is signed in to ArcGIS Enterprise as: {user}");
return false;
}
}
}
else
{
Console.WriteLine("No active portal found.");
}
});
return signIn;
}
}
Hi @MuhammadElbagoury ,
You can implement your own state/condition and use a function like this to determine if user is logged on to ArcGIS Online or Enterprise.
We have some Framework Concepts which can help you understand the concepts behind states and conditions:
https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#conditions-and-state
Here is a tutorial which can help you guide how you can implement: