umbraco7 - Umbraco 7 Custom Field Indexing issues with GetPropertyValue -


having issue custom index fields rte properties (other property types seem working fine).

version : 7.3.6

summary of issue: when trying access rte properties on onapplicationstarted appending event gatheringnodedata error thrown:

system.nullreferenceexception unhandled user code   hresult=-2147467261   message=object reference not set instance of object.   source=umbraco   stacktrace:        @ umbraco.web.templates.templateutilities.parseinternallinks(string text, boolean preview)        @ umbraco.web.propertyeditors.valueconverters.rtemacrorenderingvalueconverter.convertdatatosource(publishedpropertytype propertytype, object source, boolean preview)        @ umbraco.web.publishedcache.xmlpublishedcache.xmlpublishedproperty.<.ctor>b__0()        @ system.lazy`1.createvalue()        @ system.lazy`1.lazyinitvalue()        @ umbraco.web.publishedcache.xmlpublishedcache.xmlpublishedproperty.<.ctor>b__1()        @ system.lazy`1.createvalue()        @ system.lazy`1.lazyinitvalue()        @ creativejar.wickes.brandingportal.cms.handlers.onapplicationstart.gatheringnodedatahandler(object sender, indexingnodedataeventargs e, umbracohelper helper) in d:\codechronicles\creativejar\branding portal\trunk\code\wickes.brandingportal.cms\handlers\onapplicationstart.cs:line 64        @ creativejar.wickes.brandingportal.cms.handlers.onapplicationstart.<>c__displayclass2_0.<onapplicationstarted>b__0(object sender, indexingnodedataeventargs e) in d:\codechronicles\creativejar\branding portal\trunk\code\wickes.brandingportal.cms\handlers\onapplicationstart.cs:line 35        @ examine.providers.baseindexprovider.ongatheringnodedata(indexingnodedataeventargs e) in x:\projects\examine\examine\projects\examine\providers\baseindexprovider.cs:line 190        @ umbracoexamine.umbracocontentindexer.ongatheringnodedata(indexingnodedataeventargs e)        @ examine.luceneengine.providers.luceneindexer.getdatatoindex(xelement node, string type) in x:\projects\examine\examine\projects\examine\luceneengine\providers\luceneindexer.cs:line 1113        @ examine.luceneengine.providers.luceneindexer.processindexqueueitem(indexoperation op, indexwriter writer) in x:\projects\examine\examine\projects\examine\luceneengine\providers\luceneindexer.cs:line 1802        @ examine.luceneengine.providers.luceneindexer.processqueueitem(indexoperation item, icollection`1 indexednodes, indexwriter writer) in x:\projects\examine\examine\projects\examine\luceneengine\providers\luceneindexer.cs:line 1580        @ examine.luceneengine.providers.luceneindexer.forceprocessqueueitems(boolean block) in x:\projects\examine\examine\projects\examine\luceneengine\providers\luceneindexer.cs:line 1537   innerexception:  

hookup code:

var helper = new umbracohelper(umbracocontext.current);             examinemanager.instance.indexprovidercollection["contentindexer"].gatheringnodedata += (sender, e) => gatheringnodedatahandler(sender, e, helper); 

error being thrown here:

foreach (var prop in widgetproperties.where(prop => widget.hasproperty(prop) && widget.hasvalue(prop)))                 {                     content.append(widget.getpropertyvalue<string>(prop));                 } 

to isolate issue tried accessing rte property directly same results.

var node = helper.typedcontent(e.nodeid); var test = node.getpropertyvalue("pagesummary"); 

running hasproperty & has value returns true

looking in immediate window, can see value when doing getproperty("pagesummary") attempting access property throws same exception,

unfortunately unable step call bur stack trace seems indicate there dependency not available @ point of execution.

does know if attempting @ wrong point of execution?

i have tried ways raw value (i not concerned actual links parsing etc seems causing issue) @ moment have had no luck.

many thanks

les

this seems have been issue time: (umbracocontext not available @ calling method resulting in error) http://issues.umbraco.org/issue/u4-5953?preventredirect=true

which little weird sure had working in 7.3.4 (before updating 7.3.5 7.3.6) search functionality , indexes updating.

it didn't made mistake of assuming rte properties seems string based ones.

in end found 2 ways functionality wanted first being:

icontentservice cs = applicationcontext.current.services.contentservice;              var node1 = cs.getbyid(e.nodeid);             var widgets1 = node1.descendants().where(x => x.contenttype.alias.contains("widget"));             var content1 = new stringbuilder();              foreach (var widget in widgets1)             {                 foreach (var prop in widgetproperties.where(prop => widget.hasproperty(prop)))                 {                     content1.append(widget.getvalue(prop));                     content1.append(" ");                 }             }              var result = content1.tostring(); 

the problem method above wasn't getting descendants first level.

the next solution got results expecting due greedy nature (not found nice way of getting nodes want) fair bit slower. small site , effects content editors seems necessary evil.

 var node = new node(e.nodeid);              var widgets = node.getdescendantnodes();              var content = new stringbuilder();             foreach (var widget in widgets)             {                 foreach (var prop in widgetproperties.where(prop => widget.hasproperty(prop)))                 {                     content.append(widget.getproperty(prop));                     content.append(" ");                 }             }              e.fields.add("pagecontent", content.tostring()); 

i not sure if issue fixed time umbraco team seem pushing grid editor pretty hard (over node based components/widgets).


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -