Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Office Anywhere and Automatically Resetting Home Extension

    We created a script that resets phones to their assigned user. This script runs on our Shoreware Director server each night and works great. This script makes it easier for our employees who move around between offices on a frequent basis. If they forget to reassign their extension, it just goes back to their "home" phone.

    However, we ran into a snag. One of our users likes to use the Office Anywhere. Since Office Anywhere resets his phone to "Anonymous", it gets reset each night and breaks Office Anywhere.

    To work around this, I'm going to exempt his extension. However, if more people want to use Office Anywhere, this could become hard to manage and difficult for employees who want to use Office Anywhere sometimes and just reassign their extension at other times.

    So I'm wondering if there is a way to check, in the script, if a person has Office Anywhere turned on? (I'm not much of a script writer - I basically hacked an existing script for our purposes). Does anyone else have other ideas?

  • #2
    This information should be available in Users table of the configuration database. Connecting to this database may be a little challenging, however. what language is your script written in?

    Comment


    • #3
      Script

      The script is in javascript. Here's the code:

      var g_scriptHlpr;

      function CSIS_SendUserHome(lDN)
      {
      try
      {
      return g_scriptHlpr.sendUserHome(lDN);
      }
      catch(err)
      {
      wscript.echo("Not a valid extension")
      }
      }

      function CSIS_Connect()
      {
      var bRet = 0;
      try
      {
      g_scriptHlpr = new ActiveXObject("Shoreline.ScriptHlp.CScriptHlp.1");
      bRet = g_scriptHlpr.initialize();
      }
      catch(e)
      {
      WScript.echo(e.description);
      bRet = e.error;
      }
      return bRet;
      }

      //intialize the connection
      CSIS_Connect()

      for (var i=1000; i<=1117; i++)
      {
      try
      {
      //WScript.echo(i);
      CSIS_SendUserHome(i);
      }
      catch(err)
      {
      //ignore errors - which are usually bad extension numbers
      }
      }

      Comment


      • #4
        This is ShoreTel 8.0 and later only.

        Code:
        var g_scriptHlpr;
        var g_mysql;
        
        function CSIS_SendUserHome(lDN)
        {
        	try
        	{
        		return g_scriptHlpr.sendUserHome(lDN);
        	}
        	catch(err)
        	{
        		wscript.echo(lDN + ": Not a valid extension")
        	}
        }
        
        function IsExternallyAssigned(lDN)
        {
        	var result = g_mysql.execute("SELECT * FROM csisusercurrentphonetype WHERE UserDN='" + lDN + "'");
        	var ret = result.EOF; // No record means extension is not assigned to an IP phone
        	result.close();
        	return ret;
        }
        
        function CSIS_Connect()
        {
        	try
        	{
        		g_scriptHlpr = new ActiveXObject("Shoreline.ScriptHlp.CScriptHlp.1");
        		g_scriptHlpr.initialize();
        		
        		g_mysql = WScript.CreateObject("adodb.connection");
        		g_mysql.open("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=shoreware;User=root;Password=shorewaredba;Option=3;");
        	}
        	catch(e)
        	{
        		WScript.echo(e.description);
        	}
        }
        
        //intialize the connection
        CSIS_Connect()
        
        for (var i=1000; i<=1117; i++)
        {
        	if(!IsExternallyAssigned(i))
        		CSIS_SendUserHome(i);
        }
        
        g_mysql.close();

        Comment


        • #5
          That worked perfectly. Thank you for the insight and quick response.

          Comment

          Working...
          X