ext

Status
Not open for further replies.

pat71

Joined
Mar 17, 2016
Messages
40
Reaction score
0
Hi,
is there way to change presence using API, or even the status of the extension.
any one did this please.
 
Re: Changing extension to busy using API

Hi,
Thank you for the reply,

I am trying to do that, but it just do not work. can you please give me sample code to make extension busy or not ring using code c#.

Your help is much appreciate.
 
Re: Changing extension to busy using API

Hi there,
Here's a c# sample I had ready which changes the current profile of an extension, thus the forwarding rules of the new profile will apply when dialing ext.

Code:
	//retrieve profiles list of ext
	FwdProfile[] fps = ex.FwdProfiles;
	// Available, Custom 1, CustomHours, Exceptions, Custom 2, Away, Out of office (random order)

	//change profile
	if (fps.Length > 0)
	{
		string newprofile = "";
		switch (changeto)
		{
			case "avail": newprofile = "Available"; break;
			case "away": newprofile = "Away"; break;
			case "oof": newprofile = "Out of office"; break;
			case "custom1": newprofile = "Custom 1"; break;
			case "custom2": newprofile = "Custom 2"; break;
		}

		if (newprofile.Length > 0)
			for (int i = 0; i < fps.Length; i++)
			{
				if (fps[i].Name == newprofile)
				{
					ex.CurrentProfile = fps[i];
					ex.Save();

					//reload to display last state
					ex = ps.GetDNByNumber(extension.ToString()) as Extension;
					break;
				}
			}
	}
 
Re: Changing extension to busy using API

Thank you,
I just need to understand this line please.

ex = ps.GetDNByNumber(extension.ToString()) as Extension;
break;
why are we using ex = , can you explain.

many thanks
 
Re: Changing extension to busy using API

pj3cx said:
Hi there,
Here's a c# sample I had ready which changes the current profile of an extension, thus the forwarding rules of the new profile will apply when dialing ext.

Code:
	//retrieve profiles list of ext
	FwdProfile[] fps = ex.FwdProfiles;
	// Available, Custom 1, CustomHours, Exceptions, Custom 2, Away, Out of office (random order)

	//change profile
	if (fps.Length > 0)
	{
		string newprofile = "";
		switch (changeto)
		{
			case "avail": newprofile = "Available"; break;
			case "away": newprofile = "Away"; break;
			case "oof": newprofile = "Out of office"; break;
			case "custom1": newprofile = "Custom 1"; break;
			case "custom2": newprofile = "Custom 2"; break;
		}

		if (newprofile.Length > 0)
			for (int i = 0; i < fps.Length; i++)
			{
				if (fps[i].Name == newprofile)
				{
					ex.CurrentProfile = fps[i];
					ex.Save();

					//reload to display last state
					ex = ps.GetDNByNumber(extension.ToString()) as Extension;
					break;
				}
			}
	}


Thanks it work like charm.
 
Hi,
One more question?

Can we change the status from Custom 1 to any message we like.
 
The name of the Custom 1 and 2 Profiles can actually be changed from within the Management Console -> Settings -> PBX (V14).
 
Status
Not open for further replies.