dotnetnuke-module2sxc

2sxc : Prefill value for multiple entity type


I have entity field "Tags" that allow multiple values and If I create default value for this field that way:

[{entity1-guid},{entity2-guid}] everything is OK when I create new object with this field.

But If I want to use prefill for new object and not use default value, becouse it depend on some other logic, like this:

@Edit.Toolbar(actions: "new", contentType: "Doc", prefill: new { Tags = Content.Tags[0].EntityGuid } )

Also work OK, but if I want multiple prefill values there is a problem.

When try this way:

@Edit.Toolbar(actions: "new", contentType: "Doc", prefill: new { Tags = [{Content.Tags[0].EntityGuid},{Content.Tags[1].EntityGuid]} } )

I get error:

Error: System.Web.HttpCompileException (0x80004005): c:\DevFolder\DNN\dev.dnn.temp\httpdocs\Portals\0\2sxc\nn-doc\_DocList.cshtml(9): error CS1525: Invalid expression term '[' at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath) at ToSic.SexyContent.Engines.RazorEngine.CreateWebPageInstance() in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\2Sexy Content Razor\RazorEngine.cs:line 81 at ToSic.SexyContent.Engines.RazorEngine.InitWebpage() in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\2Sexy Content Razor\RazorEngine.cs:line 110 at ToSic.SexyContent.Engines.RazorEngine.Init() in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\2Sexy Content Razor\RazorEngine.cs:line 27 at ToSic.SexyContent.Engines.EngineBase.Init(Template template, App app, ModuleInfo hostingModule, IDataSource dataSource, InstancePurposes instancePurposes, SxcInstance sexy) in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\SexyContent\Engines\EngineBase.cs:line 60 at ToSic.SexyContent.SxcInstance.GetRenderingEngine(InstancePurposes renderingPurpose) in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\SexyContent\SxcInstance.cs:line 244 at ToSic.SexyContent.SxcInstance.Render() in C:\Projects\2SexyContent\Web\DesktopModules\ToSIC_SexyContent\SexyContent\SxcInstance.cs:line 200

Is this a real bug, or what I am doing wrong?


Solution

  • I reviewed your case and found out that it is already supported. I think you just did something wrong with building the string-array in the tag. Here's a solution that works:

    @Edit.Toolbar(actions: "new", 
    contentType: "BlogPost", 
    prefill: new { Tags = new string[] {
        "08387a10-1aac-494a-9eb5-1383e31490eb",
        "b498a694-047a-4e51-a285-50f9a64edda1"
    } })