Server Side API to get connection string or URL

From the Server side API, how do I get the connection string (i.e. Server, SQL Database)?  I need it to execute custom SQL code that joins data from another database.

From the Client Side, I can use 

var url = aras.getServerBaseURL();
var base = aras.getBaseURL();

But these functions are not available from the Sever Side API

I feel I am on the right right track with

dim scb as object = inn.getConnection

dim oInnDatabase as object = scb.CCO.DB.InnDatabase '.databaseName

dim fooDatabaseServerName as object = oInnDatabase.DatabaseServerName 'Works: Gives SBIWS457

Examining the properties in Visual Studio Watch, I found the exact place I want to be, but am unable to access the properties

olnnDatabase.ActiveInteractor.CurrentConnection.ConnectionString '(Failes)

This seems like it should be simple, but I can't seem to find any reference to functions that call back to the initiating server from the Server Side API.

Kent

Parents
  • Hi Kent

    You can try below C# code

    Innovator innovator = this.getInnovator();
    IServerConnection connection = innovator.getConnection();
    string dbName = connection.GetDatabaseName(); //Database Name
    string protocol = HttpContext.Current.Request.Url.Scheme; // HTTP or HTTPS
    string serverName = HttpContext.Current.Request.Url.Host; // Server Name
    string appName = HttpContext.Current.Request.Url.Segments[1]; // Application Name
    string appURL = protocol + "://" + serverName + "/" + appName; // Application URL
    return this;

    Thank You

    Gopikrishnan R

  • It works great except for one thing.

    I have a server-side c# method attached to OnAfterAdd event of "Activity2 Comment" ItemType. This method should send emails to all active activity assigne if someone adds new comment to activity. Method inserts links to activity and project into message body and thus I need server hostname to generate these links. I'm using CCO.Request.Url.Host to get server hostname. AFAIK it same as HttpContext.Current.Url.Host.

    All works fine until user attaches the file to comment in "Activity Completion Worksheet" form. In this case Url.Host for some reason becomes "localhost" and all my links becomes broken.

    Can anyone explain why this is happening and how to fix it?

    You can easy reproduce it. Just create server-side method with one line code:

    return this.getInnovator().newError(HttpContext.Current.Request.Url.Host);

    attach it to onAfterAdd server event to "Activity2 Comment" itemtype, open Activity Completion Worksheet, add comment, attach file to it and save activity. You'll see popup with "localhost" instead of server hostname.

Reply
  • It works great except for one thing.

    I have a server-side c# method attached to OnAfterAdd event of "Activity2 Comment" ItemType. This method should send emails to all active activity assigne if someone adds new comment to activity. Method inserts links to activity and project into message body and thus I need server hostname to generate these links. I'm using CCO.Request.Url.Host to get server hostname. AFAIK it same as HttpContext.Current.Url.Host.

    All works fine until user attaches the file to comment in "Activity Completion Worksheet" form. In this case Url.Host for some reason becomes "localhost" and all my links becomes broken.

    Can anyone explain why this is happening and how to fix it?

    You can easy reproduce it. Just create server-side method with one line code:

    return this.getInnovator().newError(HttpContext.Current.Request.Url.Host);

    attach it to onAfterAdd server event to "Activity2 Comment" itemtype, open Activity Completion Worksheet, add comment, attach file to it and save activity. You'll see popup with "localhost" instead of server hostname.

Children
No Data