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.
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">
In the appropriate place in the above code example you would then use the .Activate and .Deactivate methods similar to FrameworkApplication.State.Activate("goodLogin_State").
You would also want to us your own state instead of esri's internal predefined state variable.
<state id="goodLogin_State" />
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 @Muhammad_Elbagoury ,
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:
https://developers.arcgis.com/documentation/arcgis-pro-sdk/tutorials/manage-the-pro-ui-with-conditions/
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) ??
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.