Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » CodeFirst items break on template (9.7.1)

CodeFirst items break on template (9.7.1)

Jesse Bakker
Reply

Hi,

Since 9.7 we can't use codefirst item in frontend. Templates crash when getting the item as codefirst objects like:

var exampleItem = Services.Items.GetItemById<ExampleItem>("1"); 

It throws an exception because Dad is not happy...

Is there a fix for this? Because we use codefirst items on most of our templates.

System.Exception: Translate.Translate or Translate.JsTranslate was called from the frontend. Dad is not happy.... Just remove the call in that context. UI needs to be translated in Admin - not in the API
   at Dynamicweb.SystemTools.Translate.GetWord(String key, Boolean isJavaScript)
   at Dynamicweb.SystemTools.Translate.Translate(String key)
   at Dynamicweb.Content.Items.Activation.CodeFirstActivationWorkflow.GetPropertiesGroupInfo(IEnumerable`1 properties, Dictionary`2 groupFields)
   at Dynamicweb.Content.Items.Activation.CodeFirstActivationWorkflow.SelectLayout(IEnumerable`1 properties, FieldMetadataCollection fieldsMetadata)
   at Dynamicweb.Content.Items.Activation.CodeFirstActivationWorkflow.SelectItem(Type t)
   at Dynamicweb.Content.Items.ItemManager.GetSystemName(Type itemType)
   at Dynamicweb.Content.Items.Queries.StorageManager.Open[T]()
   at Dynamicweb.Content.Items.Queries.StorageManager.GetById[T](String id)
   at CompiledRazorTemplates.Dynamic.RazorEngine_8f0162f016e343e69eb53d45582916bc.Execute() 
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Jesse

That is an internal exception that should not have been released.

I have just removed it from the next hotfix of 9.7

Sorry about the inconvenience.

BR Nicolai

Votes for this answer: 1
 
Jesse Bakker
Reply

Hi Nicolai, 

Thanks for the quick fix. Will this be in the 9.7.2 planned for this week?

 
Nicolai Pedersen
Reply

Yes!

 

You must be logged in to post in the forum