Add value to new column in Media file

Srikrishna Podduturi asked on June 12, 2019 14:57

Hi Team,

I have added an extra column in Media libraries (Media File) using Modules section. The column has appeared in the Media_File table.

I am inserting records into media libraries using API i.e. MediaFileInfoProvider.SetMediaFileInfo(mediaFile)

Could you please advise how can i add a value to the newly added column using the above API method?

Thanks in advance.

Correct Answer

Dmitry Bastron answered on June 12, 2019 15:01

Hi Srikrishna,

You can easily do it like this:

mediaFile.SetValue("CustomBoolValue", true);
mediaFile.SetValue("CustomStringValue", "Some string");
mediaFile.SetValue("CustomIntValue", 42);
// ..and so on and then save the media file
MediaFileInfoProvider.SetMediaFileInfo(mediaFile);
0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.