Use Embeddables in a custom content type

I have a custom IContentType and want to be able to use embeddables within it.  What do I need to do to enable my custom content type to use embeddables?

  • You'll want to implement IContentEmbeddableContentType, which provides a reference to IContentEmbeddableContentTypeController to call Updated when content that may contain embeddables is created or updated. (Also Deleted for when it is deleted). The basic setup is similar to that shown in the IFileEmbeddable training, though the method signatures and usages obviously differ.

  • I have this wokring on the backend...but in order for the embeddable to render do I need to run my HTML content through some sort of rendering engine?   

  • It appears I'm getting this exception when calling the update method:

    UnknownException: An error occurred while rendering the 'save.vm' script from the 'FCC - Lesson Edit' widget (56dbcbb8-e06d-48d0-8af1-0def3dc81a4a). (An error occurred while trying to render a widget. Details of the issue were logged for review by the administrator.) ---> NVelocity.Exception.MethodInvocationException: Invocation of method 'Update' in  HearingFirst.LearningExperience.Widget.LessonExtension+LessonExtensionObject threw exception System.InvalidCastException : Object must implement IConvertible. ---> System.InvalidCastException: Object must implement IConvertible.
       at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
       at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming)
       --- End of inner exception stack trace ---
       at NVelocity.Runtime.Parser.Node.ASTMethod.Execute(Object o, IInternalContextAdapter context)
       at NVelocity.Runtime.Parser.Node.ASTReference.Execute(Object o, IInternalContextAdapter context)
       at NVelocity.Runtime.Parser.Node.ASTSetDirective.Render(IInternalContextAdapter context, TextWriter writer)
       at NVelocity.Runtime.Parser.Node.ASTBlock.Render(IInternalContextAdapter context, TextWriter writer)
       at NVelocity.Runtime.Parser.Node.SimpleNode.Render(IInternalContextAdapter context, TextWriter writer)
       at NVelocity.Runtime.Parser.Node.ASTIfStatement.Render(IInternalContextAdapter context, TextWriter writer)
       at NVelocity.Runtime.Parser.Node.SimpleNode.Render(IInternalContextAdapter context, TextWriter writer)
       at NVelocity.Template.Merge(IContext context, TextWriter writer)
       at Telligent.Evolution.Platform.Scripting.Implementations.ScriptedExtensionExecutionService.<>c__DisplayClass28_1.<ExecuteScriptFile>b__0()
       at Telligent.Evolution.Platform.Scripting.Implementations.ScriptedExtensionOutputCachingService.Get(ScriptedExtension extension, String cacheKey, Boolean cacheable, Func`1 getRenderedOutput)
       at Telligent.Evolution.Platform.Scripting.Implementations.ScriptedExtensionExecutionService.ExecuteScriptFile(ScriptedExtension extension, ScriptedFileType fileType, String fileName, ScriptExecutionExceptionHandling exceptionHandling)
       --- End of inner exception stack trace ---
       at Telligent.Evolution.Platform.Scripting.Implementations.ScriptedExtensionExecutionService.HandleExecutionException(Exception ex, ScriptExecutionExceptionHandling exceptionHandling, ScriptedExtension extension, String scriptName, IRenderedScript& renderedScript)
       at Telligent.Evolution.Platform.Scripting.Implementations.ScriptedExtensionExecutionService.ExecuteScriptFile(ScriptedExtension extension, ScriptedFileType fileType, String fileName, ScriptExecutionExceptionHandling exceptionHandling)
       at Telligent.Evolution.Platform.Scripting.Implementations.ScriptedExtensionFileExecutionService.ExecuteInternal(ScriptedExtension scriptedExtension, ScriptedFileType fileType, String fileName, NameValueCollection parameters, TextWriter writer)
       at Telligent.Evolution.Platform.Scripting.Implementations.ScriptedExtensionFileExecutionService.HandleRequest()
  • if (_embeddedController != null)
    {
        _embeddedController.Updated(e.Lesson.ContentId, e.Lesson.ContentTypeId, (updater) =>
        {
            e.Lesson.Description = updater.Update(e.Lesson.Description);
        });
    }

  • Try passing null for the second parameter -- this is not supposed to be the ContentTypeId but instead a unique ID to represent embeddables for a non-default purpose. If the second parameter is the issue, we can log and resolve that. I don't think the intention is to version the embeddables here. 

    The exception itself, if its coming from Velocity, may be an issue with the data type being passed to your widget extension. There is a bit of a disconnect in the stack trace, however, which makes this appear to be a SQL data type conversion issue vs. a parameter type issue (which is what I get from the top-most exception).

  • I changed the code to as follows, and still get the error.  When I remove the code from my DLL, it works fine.

    if (_embeddedController != null)
    {
    _embeddedController.Updated(e.Lesson.ContentId, null, (updater) =>
    {
    var testString = updater.Update("");
    });
    }

  • Are there any other exceptions logged when this issue occurs that could provide more detail/context?

  • I believe I found the issue in a very old stored procedure - the SQL Data Type conversion issue helped me find it.