How to Update Record in Custom Module using module builder

Posted by Community Admin on 04-Aug-2018 04:48

How to Update Record in Custom Module using module builder

All Replies

Posted by Community Admin on 17-Jun-2014 00:00

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

Posted by Community Admin on 17-Jun-2014 00:00

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.

Posted by Community Admin on 18-Jun-2014 00:00
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
 
This thread is closed