Custom Field in Products causes Return Code: 0 or itemContex

Posted by Community Admin on 05-Aug-2018 20:37

Custom Field in Products causes Return Code: 0 or itemContext is undefined

All Replies

Posted by Community Admin on 18-Mar-2011 00:00

Note: Title should read itemContext.Item is undefined
In my previous thread I asked how to enable Custom fields for a Custom module. Using some code provided by a community member I have gotten this feature "working". By "working" I mean, the dialog shows up and I can add fields as needed. The fields show up on the edit forms as expected, but it's at this point that it all stops working.
Im using the most up to date(that I'm aware of) products module that George posted yesterday.

Note: My issues occur only when a Custom Field has been added. With no custom fields the module functions as expected
On New Item View
No error is flagged. When I hit publish, an alert box pops up with the message "Return Code: 0"
The PUT Request is sent to this url (I have changed the namespace name for this post)

http://localhost:60876/Sitefinity/Services/Content/Products.svc/00000000-0000-0000-0000-000000000000/?itemType=MyNamespace.Products.Model.ProductItem&providerName=&managerType=&provider=&workflowOperation=Publish
--JSON--
"Item":"AllowComments":"true","AllowTrackBacks":null,"ApproveComments":false,"AvailableLanguages":[],"DateCreated":"\/Date(1300477168280)\/","DefaultPageId":null,"Description":"Value":"","EmailAuthor":false,"ExpirationDate":null,"LastModifiedBy":"00000000-0000-0000-0000-000000000000","OriginalContentId":"00000000-0000-0000-0000-000000000000","Owner":"3fc71dff-82ac-4e1c-9c97-224f48c470bc","PostRights":1,"PublicationDate":"\/Date(1300477172699)\/","Status":0,"Title":"Value":"Test","UIStatus":0,"UrlName":"Value":"test","Version":0,"ViewsCount":0,"Visible":false,"VotesCount":0,"VotesSum":0,"ApprovalWorkflowState":"Value":"","Content":"Value":"Test","Price":"0","QuantityInStock":"0","WhatIsInTheBox":"Value":"","Parent":null,"Colors":[],"Category":[],"Tags":[],"Test":"Test","LastModified":"\/Date(1300477190452)\/"=

On Edit Item View
All fields appear to have their default value. The following javascript error appears in the console
itemContext.Item is undefined
this is the method call that is blowing up
topWorkflowMenu.bindWorkflowVisuals(this._contentType,this._providerName,itemContext.Item.Id,itemContext.Item);
it generated from this resource
http://localhost:60876/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl01_TSM&compress=0&_TSM_CombinedScripts_=;;System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:en-US:c9d03845-da3c-45e9-ab05-79ee502af576:ea597d4b:b25378d2;Telerik.Sitefinity.Resources:en-US:78c5c361-7b1d-4fb8-8ca3-a9e273e832dd:5fd29111:7ee0bb1f:64dcfe0a:1154458f:2232f901:24e33f3:83eb063b;Telerik.Sitefinity:en-US:87977a15-4915-4f67-bcf6-275aebff508a:993d8e92:5b182b17:fa91e8b7:721addc:8abad62d:447a22b8:2aeb216e:b09fa3ae:98b87b05:fe4b1370:279971d;Telerik.Web.UI, Version=2010.3.1109.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4:en-US:6955197e-6bcc-48a0-9bff-1fd043726dc6:16e4e7cd:f7645509:24ee1bba:e330518b:1e771326:c8618e41;Telerik.Sitefinity, Version=4.0.1210.0, Culture=neutral, PublicKeyToken=b28c218413bdf563:en-US:87977a15-4915-4f67-bcf6-275aebff508a:80c147f:f77740f1:26cfb6dc:6e04508f;Telerik.Sitefinity.Resources:en-US:78c5c361-7b1d-4fb8-8ca3-a9e273e832dd:c4ef6dcd:6f03d72a;Telerik.Sitefinity, Version=4.0.1210.0, Culture=neutral, PublicKeyToken=b28c218413bdf563:en-US:87977a15-4915-4f67-bcf6-275aebff508a:c1fc658e:b1301e64:8bc17194:a05bbffe:6ef1aa4d:d1fb4819;MyNamespace.Products, Version=1.0.4094.23506, Culture=neutral, PublicKeyToken=null:en-US:57f4e542-c913-42d4-8aef-c65af8f14fcf:94358df;Telerik.Sitefinity, Version=4.0.1210.0, Culture=neutral, PublicKeyToken=b28c218413bdf563:en-US:87977a15-4915-4f67-bcf6-275aebff508a:7777f19:7109743d;Telerik.Web.UI, Version=2010.3.1109.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4:en-US:6955197e-6bcc-48a0-9bff-1fd043726dc6:874f8ea2:dc7e0bd:1569bb5f:63b115ed:1c565fc:30f1f089:f46195d3:19620875:490a9d4e

Thanks in advance for any assistance on this. We are starting to get closer to the deadline in this project and I would really appreciate a prompt response.

Posted by Community Admin on 21-Mar-2011 00:00

I may have been incorrect about it not working for all custom fields.  It looks like the built in textbox control is working. This image control from a post by Slavo appears to be what is causing the issue. The control functions as you would expect in both scenarios even when the itemContext.item is undefined error is thrown. It opens a window with the images and fills the textbox with the url of the selected image's thumbnail.

www.sitefinity.com/.../creating_a_thumbnail_selector_for_news_items.aspx

If the control wasnt loading I could see it being the issue, but I'm having a little trouble pinpointing what is causing this behavior since the control appears to function well.. (except for the whole blowing up the products forms part of course)


Edit
I just tested the image selector on the built in generic content control and it works as expected. It appears to only have an issue when it is on the products module. Do you guys know why this would be?

Posted by Community Admin on 21-Mar-2011 00:00

Ok.. So today I reload the page and it is working.. I killed Cassini and rebuilt this app like 15 times yesterday and it didn't help (even rebooted once).  Sounds like it has something to do with a cached javascript file, but at this point the behavior was so random I can only just be happy that it it is working.

Posted by Community Admin on 06-Apr-2011 00:00

Ok guys. I just had this happen again now.  I added a custom field and now navigating to any of the pages for product editing gives me Return Code 0 or ItemContext is undefined.  I dont have days to wait on it this time. I have Turned off completely all machines accessing the web site including the web server. I have tried accessing the page from a machine with a brand new browser install (no cached files).. What is going on that causing this?? 

I just tried accessing the new custom field from code and I'm receiving this.

Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'Sizable'.
Statement(s) could not be prepared.
   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()

This is the code i'm using to access the new sizable column
this.Image = (string)product.GetValue("Image");
this.Sizable = (bool)product.GetValue("Sizable");

The field is visible on all the edit forms, but the javascript breaks before the form is editable.

edit.. here's the stack trace
[SQLException: Invalid column name 'Sizable'.
Statement(s) could not be prepared.]
   Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery() +266
   OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery() +53
   OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute() +60
 
[DataStoreException: Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'Sizable'.
Statement(s) could not be prepared.
   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()
   at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()
SQL:
SELECT [Sizable] AS COL1, [voa_version] AS COL2 FROM [sfex_product_item] WHERE [content_id] = ?                        Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'Sizable'.
Statement(s) could not be prepared.
   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery()
   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery()
   at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()]
   Telerik.OpenAccess.RT.ExceptionWrapper.Throw() +7
   OpenAccessRuntime.DataObjects.PCStateMan.handleException(Exception x) +61
   OpenAccessRuntime.DataObjects.PCStateMan.GetFieldValue(FieldMetaData fmd) +235
   OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.GetFieldValue(PersistenceCapable pc, Object fmd) +64
   OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.GetFieldValue(PersistenceCapable pc, Object fmd) +36
   Telerik.OpenAccess.RT.Metadata.OnlineFieldDescriptor.GetValue(Object component) +62
   Telerik.Sitefinity.MetafieldPropertyDescriptor.GetValue(Object component) +153
   Telerik.Sitefinity.Model.DataExtensions.GetValue(IDynamicFieldsContainer dataItem, String fieldName) +45
   SitefinityWebApp.Models.ProductModel..ctor(ProductItem product) in C:\CheckedOutRepos\texasroadhouse.svn.pond.lf\trunk\TRH_WebProject\Models\ProductModel.cs:34
   SitefinityWebApp.controls.ShoppingCart.Page_Load(Object sender, EventArgs e) in C:\CheckedOutRepos\texasroadhouse.svn.pond.lf\trunk\TRH_WebProject\controls\ShoppingCart.ascx.cs:56
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Posted by Community Admin on 11-Apr-2011 00:00

Hello Drew Greenwell,

I have responded you your  support ticket. The problem is caused because when you add a custom field from the UI of a custom module Sitefinity does not properly persist that the meta data of your custom module has been changed and upon restart your custom field is not created in the database. As mentioned in the ticket, this issue will be handled with the Sitefinity 4.1 release. In the mean time you can manually change the meta_data_changed column to 1 in sf_schema_verions table for your assembly.



All the best,
Radoslav Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed