Schedule Job to set PageReference type to URL type



I have an existing Teaser item block that has a property named Link of type PageReference that points to the internal pages.The requirement is to change the Link type to URL that will point to either internal/external urls.

For this,I have created a new property named URL of type URL.

Now since the Link property is internal,I need to set all the internal links to the newly created property which is of type URL.

For this I have to create a schedule job as part of the migration activity to handle the existing blocks in production enviroment.

I am able to get the Content Usages of the Teaser Item block type .The issue is i need to set the newly added URL property with the existing Link property which is Page reference.

var contentTypeRepository = ServiceLocator.Current.GetInstance<EPiServer.DataAbstraction.IContentTypeRepository>();
var contentModelUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();
var repository = ServiceLocator.Current.GetInstance<IContentRepository>();

//Teaser Item Block
var blockItem = contentTypeRepository.Load(typeof(TeaserItemBlock));

// get usages, also includes versions
IList<ContentUsage> usages = contentModelUsage.ListContentOfContentType(blockItem);

Now I want to traverse through the Link property of Page reference & set it to URL property.

I am still in the learning phase of Episerver & so any help is appreciated.


Sep 18, 2020 16:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.