Using Nintex rich text editor (RTE) control in a Nintex custom workflow action

In this post I will list the steps required to use Nintex rich text editor in a custom workflow activity. Because most of the steps are the same as when using a SingleLineInput control I will focus only on the difference. The difference is in the custom action’s configuration dialog application page. For the rest of the steps (creating the custom activity class, DependencyProperties, adapter class, etc.) you can check the Nintex Workflow SDK where there is also a sample project CustomWorkflowAction.

Steps to use RTE control in the configuration dialog page of a custom Nintex Action:

  1. In your project add reference to Nintex.Workflow.ApplicationPages.dll

  2. In your aspx page add

    <%@ Register TagPrefix=”Nintex” TagName=”RTE” Src=”~/_layouts/15/NINTEXWORKFLOW/RTE.ascx” %>

  3. Add the control

    <Nintex:ConfigurationProperty ID=”ConfigurationProperty8″ runat=”server” FieldTitle=”YourFieldTitle” RequiredField=”True”>

    <TemplateControlArea>

    <Nintex:RTE runat=”server” ID=”RTEControl1″ ApproverContext=”true” HideModeChooser=”True” height=”140″ >

    </Nintex:RTE>

    </TemplateControlArea>

    </Nintex:ConfigurationProperty>

  4. To read the value from the saved configuratioin and fill the control when the form is loaded use this javascript code in the function TPARetrieveConfig():

    setRTEValue(<%= RTEControl1.RTEClientId %>, configXml.selectSingleNode(“/NWActionConfig/Parameters/Parameter[@Name=RTEControl1]/PrimitiveValue/@Value”).text);

  5. To save the value of the control when the form is submitted use this code in the function TPAWriteConfig():

    configXml.selectSingleNode(“/NWActionConfig/Parameters/Parameter[@Name=’RTEControl1‘]/PrimitiveValue/@Value”).text = getRTEValue(<%=RTEControl1.RTEClientId %>);

  6. In the code behind of the page declare the control

    Nintex.Workflow.ApplicationPages.RTE RTEControl1;

The last step is important otherwise Visual studio will declare it automatically in the partial class (YourDialogPage.aspx.design.cs) but it will declare it as System.Web.UI.UserControl.

Because RTE control inherits from UserControl the project can be build and deployed without errors but the javascript code for reading and saving the control’s value will fail in runtime and the following Compilation Error would be thrown:

Error: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1061: ‘System.Web.UI.UserControl’ does not contain a definition for ‘RTEClientId’ and no extension method ‘RTEClientId’ accepting a first argument of type ‘System.Web.UI.UserControl’ could be found (are you missing a using directive or an assembly reference?) Source Error: setRTEValue(<%= RTEControl1.RTEClientId %>, configXml.selectSingleNode(“/NWActionConfig/Parameters/Parameter[@Name=’RTEControl1′]/PrimitiveValue/@Value”).text);

 

%d bloggers like this: