Integrations and APIs for Service

Get Involved. Join the Conversation.


    ServerConfigProperty not working properly
    Topic posted February 6, 2011 by bill.shipman Blue Ribbon: 750+ Points, last edited April 14, 2012 
    4569 Views, 40 Comments
    ServerConfigProperty not working properly

    I'm trying to write a Nov 2010 add-in that pulls data from a Server Side Config property. I followed the instructions at the link below and it's not working.

    I'm trying to access the parameter in the RecordContext.DataLoaded() event and it's coming back empty. A block of my code is below. I've also attached a screenshot of my Add-in Manager screen.

    Can someone please take a look to see what I'm doing incorrectly?

    Code Snippet:


    • Ryan McCullough

      Bill, is that ServerConfigProperty inside of a class that has the AddIn attribute?

    • bill.shipman

      Yes, Please see the attached screenshot.

    • Chris Omland

      It's a subtle thing Bill, IWorkspaceComponent2 is not an add-in, the IWorkspaceComponentFactory2 is where the server config needs to live.

    • Ryan McCullough

      And actually you will want to remove the '[AddIn("AddIn Name", Version = "")]' from that class as well. It will cause an error to be logged when the add-in framework tries to load this class as an add-in when it isn't.

    • Ryan McCullough

      Personal preference, but you can also shorten that property to something like this:

      [ServerConfigProperty(DefaultValue = "value")]
      public string CreateOrderURL { get; set; }

      That is a kind of short-hand for basically what you have in your code. Note that this also supports a private get or set in a public property using this syntax:

      public string CreateOrderURL { get; private set; }

    • bill.shipman


      then how do i got about accessing it via my IWorkspaceComponent2 class? that's where all my code is for the add-in.

    • Chris Omland

      In the factory CreateWorkspaceComponent method you probably instantiate an instance of your class that implements the IWorkspaceComponent2 interface. You can pass the config value to that class when you instantiate it. Does that make sense?

    • bill.shipman

      I don't have one of those methods, though I'm not sure why. I do have CreateControl(). See below. Would i do it there and pass it to the constructor?

      public IWorkspaceComponent2 CreateControl(bool inDesignMode, IRecordContext context)
          return new SAPPortalWebBrowserAddIn(inDesignMode, context, _globalContext);

    • Chris Omland

      Oh yeah, sorry I got the method name wrong (I didn't pull up the API docs), sorry about that. You are correct, you want to do it in the CreateControl method.

    • bill.shipman

      the use of these two different classes, IWorkspaceComponentFactory2 and IWorkspaceComponent2, inside a single project/addin is quite confusing to me, especially when i have them both tagged as [AddIn(...". i know Ryan told me to remove that line from the one, but do you have anything that describes how these two things work together and the right way to set it up in Nov 2010?

    • Chris Omland

      Hi Bill,

      The IWorkspaceComponentFactory2 is the add-in that is instantiated when the agent desktop loads, all add-ins are instantiated when the agent desktop starts up. When a workspace is loaded that contains an add-in, the factory CreateControl method is invoked and that method is responsible for returning an instance of IWorkspaceComponent2, this is just an interface that you have to implement. That's all that is really going on, here is a snippet from the docs:

      When creating a workspace add-in, a minimum of two interfaces must be implemented. These interfaces are IWorkspaceComponent2 and IWorkspaceComponentFactory2. It is recommended these interfaces are implemented by two different classes. The implementation of IWorkspaceComponentFactory2 is what will actually create and return the implementation of IWorkspaceComponent2, which is done through the CreateControl method. The implementation ofIWorkspaceComponent2 is responsible for creating the actual add-in control that will be added to the workspace. This control is usually a panel or user control.


      It is important to note that a workspace add-in is instantiated both when the workspace designer is loaded and when the workspace is loaded. For this reason, it is often valuable to pass the design mode Boolean from IWorkspaceComponentFactory2to the constructor of the IWorkspaceComponent2. This is valuable when the IWorkspaceComponent2 may be registering event listeners, such as DataLoaded, which will only have a valid reference when the workspace is loaded and not when the add-in is being added to the workspace in design mode.

      Does this help?

    • Rick Crow


      I work with Bill Shipman and I have been trying to get these server side properties to work.  What I am finding is that in all cases the default value is being returned.  At first I thought that there was a problem with the way that I was implementing them because I'm using a singleton to pass the value to another control but when I bypassed the singleton and moved the value to a local variable so that I could put a debug stop at the set statement the result was the same.  It never uses the value defined when the Add In is configured.

      We are working in the Nov. 2010 version.  Is this a bug or am I missing something?  The only thing that is different is that we're uploading the Add In in a .ZIP file because we are using Telerik controls.

    • Chris Omland

      I think this may be a problem in your code. I just confirmed on a November 2010 site that I can use the server config properties and the values are reflected correctly. Here is how I did this:


       [ServerConfigProperty("Mail Operations")]       
       public String LabelText { get; set; }

      public String MailToAddress { get; set; }


      public IWorkspaceComponent2 CreateControl(bool inDesignMode, IRecordContext RecordContext)       


                  return new MailToWorkspace(inDesignMode, RecordContext, LabelText, MailToAddress);       


    • Rick Crow

      Thank you.  I went back through my code and found that I had not commented out the [AddIn("...")] line.  Once I did that it returned the correct values.

    • Rick Crow

       I have run into a problem with deploying these add ins and I'm not sure how to proceed.  There was an earlier recommendation to comment out/remove the "[AddIn...]" line.  This seemed to work, however I was in debug mode and the actual version of the Add In wasn't uploaded to Right Now.  Once I uploaded the final versions I could no longer deploy them since they no longer show up in the list of controls.

      This appears to be a catch 22.  The server side values won't work with that line in the code, but they can't be deployed if that line isn't there.

      What am I doing wrong?