+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to Update Record in Custom Module using module builder

How to Update Record in Custom Module using module builder

3 posts, 0 answered
  1. Shareef
    Shareef avatar
    1 posts
    Registered:
    24 Feb 2014
    17 Jun 2014
    Link to this post

    Hi,

    I'm Create dynamic module  using module builder,

    There is no Code-reference for Update Record,

    please help me how to update record using coding 

     Thanks,

    Shareef

  2. Arno
    Arno avatar
    249 posts
    Registered:
    08 Sep 2010
    17 Jun 2014
    Link to this post

    Hi Shareef,

    I suppose you want to update a dynamic content item? The sample code is in the "Get a ... by ID" section of the code reference. If that section is not there, you'd best report that to Telerik.

  3. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    Registered:
    26 Mar 2015
    18 Jun 2014
    Link to this post
    Hello all,

    @ Shareef,

    You are correct, there is no Code Reference for updating a Dynamic Item. The way you can do that is by using the SetValue extention method. Here is a code example for the Press Releases module. It will update a field named TextField of an item with title Text:
    using Telerik.Sitefinity.Model;
     
    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
                Type richTextType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.RichTextFieldTest.RichText");
     
                var richTextItem = dynamicModuleManager.GetDataItems(richTextType);
     
                foreach (var item in richTextItem)
                {
                    if (item.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master && item.GetValue("Title") == "Test")
                    {
                        item.SetValue("TextField", "Your Updated Text");
     
                    }
                       
                }


    Regards,
    Ivan D. Dimitrov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
3 posts, 0 answered