Check if extension is online via CFD

JoshuaM

Platinum Partner
Advanced Certified
Joined
Jan 20, 2021
Messages
75
Reaction score
13
Hello!

I am trying to create a CFD that checks if an extension is currently online. As in, has a connected device. The current profile of the extension doesn't really matter, just if it has a connected device (basically what a queue does). Is this possible?
With GetExtensionStatus i only get profile and if the user is in a call, so not sure if there is an alternative. Any ideas?
 
Hello JoshuaM,

You could be looking at the 'phones', not the 'extentions'.
However this does not cover every phone, meaning it wil display hard-phones and Web-Clients, but for example not the gsm Smart-phones.
Would you only be checking the hard-phones, or just general.. this would be a problem.

Paulo
 
  • Like
Reactions: Evolute IT
Hey @paulodagraca,

in this case there are only the windows softphones from the microsoft store. And I need to check via CFD if this destination can receive a call.
You mentioned I can be looking at phones.. how is this doable via the cfd? I'm assuming there is no integrated component for this?
 
Hello JoshuaM,

The CFD does not have any component to list the phones, that is correct.
You would be able to do this, with a part C# code.

C#:
string result = "";
bool firstItem = true;

try
{
    // Get all extensions
    Extension[] extensions = PhoneSystem.Root.GetExtensions();

    foreach (Extension ext in extensions)
    {
        // Check if extension exists, is enabled, and has a registered phone
        if (ext != null && ext.Enabled && ext.IsRegistered)
        {
            string extNumber = ext.Number ?? "Unknown";
           
            if (!firstItem)
            {
                result += Environment.NewLine;
            }
           
            result += extNumber;
            firstItem = false;
        }
    }
   
    if (result == "")
    {
        return "No registered phones found.";
    }
   
    return result;
}

catch (Exception ex)
{
    return $"Error retrieving data: {ex.Message}";
}


I have been testing this myself, but the result are not great or not clear to me.
You could try it, see if this works for the application you want to use.
Or some other member could try to improve it.

Paulo
 
Hello JoshuaM,

The CFD does not have any component to list the phones, that is correct.
You would be able to do this, with a part C# code.

C#:
string result = "";
bool firstItem = true;

try
{
    // Get all extensions
    Extension[] extensions = PhoneSystem.Root.GetExtensions();

    foreach (Extension ext in extensions)
    {
        // Check if extension exists, is enabled, and has a registered phone
        if (ext != null && ext.Enabled && ext.IsRegistered)
        {
            string extNumber = ext.Number ?? "Unknown";
          
            if (!firstItem)
            {
                result += Environment.NewLine;
            }
          
            result += extNumber;
            firstItem = false;
        }
    }
  
    if (result == "")
    {
        return "No registered phones found.";
    }
  
    return result;
}

catch (Exception ex)
{
    return $"Error retrieving data: {ex.Message}";
}


I have been testing this myself, but the result are not great or not clear to me.
You could try it, see if this works for the application you want to use.
Or some other member could try to improve it.

Paulo
Hey @paulodagraca,

in this case there are only the windows softphones from the microsoft store. And I need to check via CFD if this destination can receive a call.
You mentioned I can be looking at phones.. how is this doable via the cfd? I'm assuming there is no integrated component for this?
A C# block with this line would be just fine:

C#:
var ext = PhoneSystem.Root.GetDNByNumber(extNumberToCheck);
if (ext != null && ext.IsRegistered) { }
 
Sometimes the answer is in front of you, and you just cant see... Thany you ConceptsWeb.
 
A C# block with this line would be just fine:

C#:
var ext = PhoneSystem.Root.GetDNByNumber(extNumberToCheck);
if (ext != null && ext.IsRegistered) { }
This is the simplest way, no need to iterate all the extensions.