How to Update Record in Custom Module using module builder
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
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.
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"
);