Article

How to fix the issues related to using Related Data fields in Sitefinity Multisite

« Go Back

Information

 
EnvironmentProduct: Sitefinity
Version: 7.0, 7.1
OS: All supported OS versions
Database: All supported Microsoft SQL Server versions
Question/Problem Description

Items cannot be related from the default provider for the current site in multisite mode. More about the problem can be seen in the discussions on our Feedback Portal:

Dynamic Modules: Issue with Related Data in Multisite environment​ http://feedback.telerik.com/Project/153/Feedback/Details/132038-dynamic-modules-issue-with-related-data-in-multisite-environment

and SitefinityDevs Google+ community:

https://plus.google.com/112271179538938975901/posts/SNeBr8Qz1UN

Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement NumberBug 132038 http://feedback.telerik.com/Project/153/Feedback/Details/132038
Cause
The observed behavior is due to the fact that provider to be used for the Related Data field can be specified on its creation. Afterwards, if sharing the module among other sites, by default creates a different provider for each site, thus the field will not work, since it cannot find the provider it’s been told to look for.
Resolution

Upgrade to Internal Build 7.1.5202 or later.

In the build is added support for creating related data fields working with default source (provider) per site in a multisite environment. In other words, the field will now automatically resolve which is the default provider for the current site and allow you to select items from it.

Internal Build 7.1.5202 release notes: http://www.sitefinity.com/developer-network/forums/general-discussions-/internal-hotfix-builds#xtd_1FCk-UaMwcC3XrrPuw

Important: The Internal Build 7.1.5202 or later, provides a fix for any newly created related data fields, so if the use case allows it, we recommend to proceed by recreating the existing fields. If recreating is not possible, please, follow the Workaround in the article.

Workaround
For versions 8.x and newer:
1. Go to Advanced settings -> Dynamic Modules -> Controls -> the module -> Views -> InsertView -> Sections -> Related Data -> Fields, the field.
2. Change the related data provider, for example to sf-site-default-provider
3. Perform the same for EditView as well.

Note: these modifications might leave some values unchanged in the database and could lead to problems with persisting the selected object of the related data. If this occurs, do the following:

Important: Make sure a full database backup is performed beforehand.

1. In [sf_mb_dynamic_module_field] table, find the entry corresponding to the Related Data field, and set its related_data_provider from the initially selected (e.g. OpenAccessProvider) to sf-site-default-provider. 
 
update [sf_mb_dynamic_module_field]
set related_data_provider = 'sf-site-default-provider'
where module_name = 'ModuleName' and nme = 'RelatedDataFieldName'

2. In [sf_meta_attribute] table, find your related provider by name its id2, and change its val from the initially selected (e.g. OpenAccessProvider) to sf-site-default-provider. 
update [sf_meta_attribute]
set val = 'sf-site-default-provider'
where id2 = 'RelatedDataFieldsId-XXXXX-XXXXX-XXXX-XXXX’ and nme = 'RelatedProviders'
id2 is the id of the related data field as in [sf_meta_fields], and in [sf_mb_dynamic_module_field]. 

3. Recycle the application pool

For older versions:
  1. Upgrade to Internal Hotfix Build 7.1.5202 or later
  2. Run the following script against the database, modifying it according to the inline comments, to fix the fields you desire (Make sure a full database backup is performed beforehand):
    update sf_meta_attribute
    set val = 'sf-site-default-provider'
    from sf_meta_types mt join sf_meta_fields mf
    on mf.type_id = mt.id
    join sf_mt_fields_sf_meta_attribute mfma
    on mfma.id = mf.id
    join sf_meta_attribute ma
    on mfma.id2 = ma.id
    where ma.nme = 'RelatedProviders'
    and mf.clr_type = 'Telerik.Sitefinity.RelatedData.RelatedItems'
    and mf.field_name = 'News2' -- Replace the field to which the item is related
    and mt.name_space = 'Telerik.Sitefinity.DynamicTypes.Model.ShowRoom' -- Replace The namespace of the type.
    and mt.class_name = 'Car' -- Replace the type's class name
      
    -- E.g. Adding a related data field to a News Item the namespace would be Telerik.Sitefinity.News.Model
    -- and the class name would be NewsItem. For the field name, replace the value with which the NewsItem is related
    -- to the other content type. To get the field name, take a look in the custom fields dialog for content items
    -- ang pages and in the module builder screen for dynamic items.
  3. Modify the configuration files for the module(s) where Related data fields are added and the problem is experienced (Back up your App_Data/Sitefinity/Configurations folder beforehand). In each configuration file that has to be fixed, modify the Related data field relatedDataProvider property to say sf-site-default-provider, for example:

     

    <field frontendWidgetLabel="Related documentation articles" frontendWidgetVirtualPath="inline" relatedDataType="Telerik.Sitefinity.DynamicTypes.Model.DocumentationArticles.DocumentationArticle" relatedDataProvider="OpenAccessProvider" allowMultipleSelection="True" id="blablbaControl" dataFieldName="blablba" displayMode="Write" wrapperTag="Li" title="Related documentation articles" fieldType="Telerik.Sitefinity.Web.UI.Fields.RelatedDataField, Telerik.Sitefinity" cssClass="sfFormSeparator" fieldName="blablba" type:this="Telerik.Sitefinity.Web.UI.Fields.Config.RelatedDataFieldDefinitionElement, Telerik.Sitefinity">
                                        <validator expectedFormat="None" maxLength="0" minLength="-1" regularExpression="^(.{0,})?$" required="False" maxLengthViolationMessage="The input is too long" messageCssClass="sfError" minLengthViolationMessage="The input is too short" validateIfInvisible="True" />
                                        <expandableDefinition expanded="True" />
                                    </field>

    becomes:

    <field frontendWidgetLabel="Related documentation articles" frontendWidgetVirtualPath="inline" relatedDataType="Telerik.Sitefinity.DynamicTypes.Model.DocumentationArticles.DocumentationArticle"
    relatedDataProvider="sf-site-default-provider" allowMultipleSelection="True" id="blablbaControl" dataFieldName="blablba" displayMode="Write" wrapperTag="Li" title="Related documentation articles" fieldType="Telerik.Sitefinity.Web.UI.Fields.RelatedDataField, Telerik.Sitefinity" cssClass="sfFormSeparator" fieldName="blablba" type:this="Telerik.Sitefinity.Web.UI.Fields.Config.RelatedDataFieldDefinitionElement, Telerik.Sitefinity">
                                        <validator expectedFormat="None" maxLength="0" minLength="-1" regularExpression="^(.{0,})?$" required="False" maxLengthViolationMessage="The input is too long" messageCssClass="sfError" minLengthViolationMessage="The input is too short" validateIfInvisible="True" />
                                        <expandableDefinition expanded="True" />
                                    </field>

This will tell the field to automatically resolve the default provider for the site, instead of using the initially specified provider. 

Notes
Attachment 
Last Modified Date8/14/2017 3:39 PM
Disclaimer

The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.



Feedback
 
Was this article helpful?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful.



Characters Remaining: 255