Select to view content in your preferred language

Activate / Deactivate custom Add-In for Enterprise Credentials in ArcGIS Pro.

220
3
Jump to solution
3 weeks ago
MuhammadElbagoury
New Contributor II

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.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

You can use states and conditions.

  • Pro has an internal state defined by this id: esri_core_isSignedIn
  • You can create your own custom condition using this state. New conditions are defined in daml.
  • Then add this condition to your controls.

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">

View solution in original post

3 Replies
UmaHarano
Esri Regular Contributor

You can use states and conditions.

  • Pro has an internal state defined by this id: esri_core_isSignedIn
  • You can create your own custom condition using this state. New conditions are defined in daml.
  • Then add this condition to your controls.

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">
MuhammadElbagoury
New Contributor II

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) ??

0 Kudos
VedantBajaj
Esri Contributor
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: 

https://developers.arcgis.com/documentation/arcgis-pro-sdk/tutorials/manage-the-pro-ui-with-conditio...

 

 

0 Kudos