Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Pages created by Scheduled Job, properties not readable when the job runs next

Vote:
 

Hello all,

I have a custom scheduled job that creates and updates pages from a third-party API.

The initial create and subsequent updates from the external API work fine.  I can push data, but can't seem to pull data for comparison purposes.  Here are the basics in my job:

var svc = ServiceLocator.Current;
var repo = svc.GetInstance<IContentRepository>();
var contentType = svc.GetInstance<IContentTypeRepository>().Load<MyPage>(); 
var contentList = svc.GetInstance<ContentStore>().ListContentOfContentType(contentType, false).ToList();
var myPageLink = contentList?.FirstOrDefault(x => x.Name == myData.Name);
var page = repo.Get<MyPage>(myPageLink.ContentLink);
var clonePage = page.CreateWritableClone() as MyPage;

clonePage.Prop1 = myData.Prop1;
if (clonePage.Prop2 == null)
clonePage.Prop2 = myData.Prop2;
...

repo.Save(clonePage , SaveAction.Publish, AccessLevel.NoAccess);

When I debug and inspect both the page and the clonePage objects, none of the property values are there.  I would imagine an item that is read or cloned would contain it's values. 

Help!  What am I missing here?

Thanks, Kevin

#302014
May 18, 2023 19:26
Vote:
 

Hi, does 'myPageLink' have a work ID? If so, you will load a specific version of that content, and this version might lack the data you're expecting. If you want to load the latest version of the content, then you can use  repo.Get<MyPage>(myPageLink.ContentLink.ToRefereenceWithoutVersion()).

#302049
May 19, 2023 7:35
Kevin Gainey - May 19, 2023 14:04
Thank you Johan! Your suggestion worked perfectly for what I needed.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.