Hello World Workspace Component

Tags: 

This article will walk you through the basic steps to create a workspace component project and deploy it on your site

  1. Create a Project
    1. C#
    2. Class Library (DLL)
    3. .NET 4.0
    4. Name your project and pick a folder for it to go in
  2. Add required References
    1. System.AddIn
    2. Browse to where RightNow is installed on your system (C:\Users\<you>\AppData\Roaming\RightNow_Technologies\<site>\<version>\AddInPipeline\AddInViews) and copy both the DLL and the XML to a dictory in your project. I usually call this RNT DLLS for simplicity. Add the DLL as a reference in your project.
  3. Configure Build Events
    1. Add the follow as a Post-Build event. This will copy your project output to the RightNow developer mode folder (and create the folder if needed)
    2. Dev mode is enabled by checking the box in the profile settings

  4. Update Project Files
    1. By default your project will have been created with a file called Class1.cs, rename this to Launcher.cs
    2. Add a UserControl named WorkspaceControl.cs
  5. Create the Launcher
    1. The launcher is responsible for creating your add-in and communicating with the add-in framework.
    2. Add the following using statements
    3. Update Launcher.cs to include two classes Factory and Component. Factory should implement IWorkspaceComponentFactory2 and Component should implement IWorkspaceComponent2
    4. Your full Launcher.cs file should now look like this:
  6. Complete the Launcher
    1. Implement each method and property in the two interfaces. I pass the inDesignMode parameter to my Component which in turn passes it on to my WorkspaceControl. The variable won't be used in this example, but provides a handy level of control that will be explored later.
    2. You will also need to add an overloaded constructor to your WorkspaceComponent.cs file to handle the updated Launcher file
    3. The final step to Launcher is to add the add-in decorator to the Factory class: [AddIn("Hello World", Version="1.0.0.0")]
  7. Create the UI
    1. Add a simple label to your control using the Designer
      • AutoSize: False
      • Dock: Fill
      • TextAlign: MiddleCenter
      • Text: Hello World
  8. Build the Project
    1. Output should appear in: C:\Users\<you>\RightNowDev\AddIns\HelloWorld_WorkspaceComponent
  9. Launch CX
    1. The new add-in should appear on any workspace designer

    2. Add the add-in to the workspace and create a new record of that type

  10. To be able to share the add-in with other people on the site you need to upload it
    1. Open the add-in Manager (Configuration -> Site Configuration -> Add-In Manager)
    2. Create a zip (optional)
      1. You can either use the DLL produced by compiling your project or you can add the DLL and any associated files to a ZIP file with the same name as the primary DLL. For example the Application Menu Add-In could be uploaded as a Zip named HelloWorld_ApplicationMenu.zip or using the HelloWorld_ApplicationMenu.dll file. Personally I prefer to always use zip files because many of my projects contain secondary DLLs, but either approach will work.
      2. The easiest place to create this file is in your Dev Mode directory that is created by the post-build event: %USERPROFILE%\RightNowDev
    3. Create a new add-in
      1. Select the Zip or DLL file created in the previous step
  11. Enable the add-in for appropriate profiles
    1. Select the Add-In
    2. Select 'Profile Access' from the ribbon
    3. Select the profile
    4. Enable the profile for the specified interface
  12. Save
  13. The next time a user with the appropriate profile signs into the site the add-in will be automatically downloaded

Comments

Hi Jack,

I have used this setup for a couple of test addins I created and so far so good. However now I am trying to use the WorkspaceConfigProperty to allow admins to change variables for the addin. I have placed this in the control class, as is shown in the documentation sample. The variables shows up nicely in the Workspace editor, however when I save en reopen the workspace the value is back to the default value.

When I tested around I found out that when I changed the GetControl() function form return control to return this the values where nicely saved.

However now my control is not showing up anymore as it is not returned. I tried to add the variable to my control but that did not work for the workspace designer. A colleague of mine always uses return this and then draws the user control onto the control class, but that seems like a strange thing to do.

Do you have any idea what would be a good approach for this?

thanks,
Bastiaan

Try out this article and see if it doesn't fix the problem you're seeing: http://cxdeveloper.com/article/addins-fragile-nature-workspace-configura...

Hi Jack,

I have a question like when an email address is saved in Incident workspace from external web service then how to get that incident deatails and call outbound to pass these incident details.

Hi can i link an html webform created in visual studio to the rightnow agent desktop interface? just like how we displayed hello world in the workspace

if you host the form somewhere (even just dropbox would probably work) then you could add it to your workspace using a standard/ootb browser control

I created a addin. On saving the standard object record. I need to do some validation.
code:
public CertRevisionNumber(bool inDesignMode, IRecordContext context, IGlobalContext gc)
: this()
{
this._recordContext = context;
this.inDesignMode = inDesignMode;
this._IGlobalContext = gc;
if (!inDesignMode && _recordContext != null)
{
_recordContext.Saving += new CancelEventHandler(_recordContext_Saving);

}
}

private void _recordContext_Saving(object sender, CancelEventArgs e)
{
try
{
IGenericObject genObj = (IGenericObject)_recordContext.GetWorkspaceRecord("Asset");

}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
throw ex;
}
}

in the above code ASSET is the standard object. how to access that one

you need to include your namespace for the CBO in your method, something like "CO$Asset"

Even I tried by giving package

I have implemented the add-in (Asset workspace:to validate a set of fields on a Asset while saving the record) .
I am accessing in recordcontext save event like below

var recordcontext = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Asset) as IAsset ;

there is no Asset in Workspacerecordtype(RightNow.AddIns.Common)
How to access this ??

the recordContext saving() and saved() events are generic to the workspace, you don't have to access them through any data context

you were loading the data properly before (you're correct, there is no IAsset object since that's just a generic object you've created). you just need to add the namespace, something like:
IGenericObject genObj = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$Asset"); //assuming your namespace is CO

or if you know that your add-in is always going to exist on the appropriate workspace you can simply do:
IGenericObject genObj = (IGenericObject)_recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName);

we do provide formal training (both onsite and remote) for add-in development if you're interested in more in depth instruction

Thanks Its Worked.
yes I m interested for addin development training. Plz mail me the details

Hi jack

it is working when I am doing like
var obj = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName)
I got complete object details in obj . But unable to retrieve custom attributes from obj.

I got the ID from object obj like
int assetid = (int)recordcontext.GetType().GetProperty("ID").GetValue(recordcontext); -- working

GenericField[] genObj = (GenericField[])recordcontext.GetType().GetProperty("CustomAttributes").GetValue(recordcontext); -- some cast error.

getting cast error while accessing with Igeneric field
Unable to cast object of type 'RightNow.AddIns.AddInSideAdapters.AssetContractToViewAdapter' to type 'RightNow.AddIns.AddInViews.IGenericObject

Please help me to retrieve custom attributes from

you're use of var is resulting in obj being represented as the interface instead of the concrete implementation. instead of:

var obj = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName);

use

IGenericObject obj = _recordContext.GetWorkspaceRecord(_recordContext.WorkspaceTypeName) as IGenericObject;

now to access your attributes you can use LINQ and:

obj.CustomAttributes.SingleOrDefault(o => o.GenericField.Name == "namespace$fieldName");

** Sorry for not getting back to you about the training. I'm trying to put together a few options, do you know how long of a course you'd be interested in? 1 to 5 days is pretty standard. How many people? Interactive or just lecture (I recommend interactive if you can ensure that everyone has access to a development machine)? Onsite or remote?

The method or operation is not implemented.

I followed your instructions step by step, and get that error when I try to drag and drop the add into the workspace.
Any ideas?

MC

Check and see if you've got a line like this:

throw new NotImplementedException()

the RuleAction and RuleCondition methods aren't called during initialization, but nearly everything else is. you can also just hook up a debugger and figure out what line is throwing the exception

Thanks, it worked. I was missing

public Control GetControl()
{
return control;
}

MC

Can I access the parent Incident from a button in the WorkspaceControl?

MC

sure can. please see: http://cxdeveloper.com/article/working-workspace-records

Zircon - This is a contributing Drupal Theme
Design by WeebPal.