Try our conversational search powered by Generative AI!

Schedule Job updating customer facing content but not visible when editing.


Hey guys,

I've a small niggly issue here. I've created a scheduled job to add a new value to each of the products we have. The value (integer) is stored in the database e.g. product code - ts_77 is updated with activity level = 3. This is visible on the customer facing product page.

When a member of the team want to update the content on the page the new activity level field is blank (null) which causes and issue when a manual content update occurs where a null value is published.

The code I'm using to update the database is:

public static bool UpdateActivityLevel(string code, int actLevel, string lastSyncBy)
if (CatalogRef == null) CatalogRef = CatalogContext.Current;

int holidayCatalogID = GetCatalogId(HOLIDAY_CATALOG_NAME);
if (holidayCatalogID == 0)
throw new Exception(string.Format("No Catalog found with the name {0}", HOLIDAY_CATALOG_NAME));

// Get a CatalogDto object.
CatalogDto catalogDto = CatalogRef.GetCatalogDto(holidayCatalogID, new CatalogResponseGroup(CatalogResponseGroup.ResponseGroup.CatalogFull));

CatalogEntryDto entryDto = null;
entryDto = CatalogRef.GetCatalogEntryDto(code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));

string skuMetaClassName = "Package_Product_Class";
bool retVal = false;

//try updating Package_Product_Class

MetaDataContext metaContext = CatalogContext.MetaDataContext;
MetaClass metaClass = MetaClass.Load(metaContext, skuMetaClassName);
MetaObject metaObj = MetaObject.Load(metaContext, entryDto.CatalogEntry[0].CatalogEntryId, metaClass.Id);

//only update the Activity level
SetField(metaContext, metaObj, "ActivityLevel", actLevel);
//last updated information
MetaHelper.SetMetaFieldValue(metaContext, metaObj, "LastSync", new object[] { DateTime.UtcNow });
MetaHelper.SetMetaFieldValue(metaContext, metaObj, "LastSyncBy", new object[] { lastSyncBy });

// Save the entry.

retVal = true;

} catch (Exception e)
ErrorLogger.LogError(e, e.Message);
retVal = false;

return retVal;

Furthermore, the LastSync field is not updating in the editing CMS end which lead me to believe both are related.

Any help / suggestions would be greatly appreciated.



Apr 16, 2019 12:09

Hi John,

Did you check the details of the log error? What it is?

And what does the "SetField(metaContext, metaObj, "ActivityLevel", actLevel);" method do?

Best regards,


Apr 16, 2019 13:15

Hey Giang,

The error logs are clear.... like I said in the initial comment the value is being saved it's just not coming into editing the document - the activity level field is blank.

the SetField() is just short hand for MetaHelper.SetMetaFieldValue().

Apr 16, 2019 15:33

First of all we recommend to use content API instead, it is the way forward.

It sounds like everything works as expected but in Catalog UI you are seeing a different version. Make sure to add Versions gadget and check 

Apr 16, 2019 16:41

Hey Quan,

are you referring to using the IContentLoader and CMS API

Or using the IRelationRepository stuff?



Apr 17, 2019 17:55

From what I can tell you are updating some metafields, so the content API - which also works with catalog content should be used. IRelationRepository should be used when you need to update the relations between catalog entities, and it's also recommended over ICatalogSystem 

Apr 17, 2019 20:47

Thanks Quan, what I needed in the end was the IContentRepository to make the update.

Worked a charm.

Thanks guys,


Apr 18, 2019 17:50
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.