I have created some custom renditions for assets in Content Hub,so whenever i upload new asset these renditions will be created automatically, but for existing assets we need to click on refresh rendering button/link for that(to create new renditions).

Is there any way that we can write some action script which will be called from some trigger on asset modification and start a job and create these new renditions?


1 Answer 1


Got an awesome blog, You can take the reference from that


Updating my answer as above blog is not working anymore and because of that reason I already got 3 down votes

Update : Attaching the code snippet::

var targetIds = new List<long>
    // use a query to get your ids

var jobEntity = await client.EntityFactory.CreateAsync("M.Job").ConfigureAwait(false);
jobEntity.SetPropertyValue("Job.Type", "MassEdit");        
jobEntity.SetPropertyValue("Job.State", "Created");       
jobEntity.SetPropertyValue("Job.Condition", "Pending");       
jobEntity.SetPropertyValue("Job.TargetCount", Convert.ToInt64(0));       
jobEntity.SetPropertyValue("Job.TargetsCompleted", Convert.ToInt64(0));       
var jobId = await client.Entities.SaveAsync(jobEntity).ConfigureAwait(false);       

// then the description
var descriptionEntity = await client.EntityFactory.CreateAsync("M.JobDescription").ConfigureAwait(false);  
string jobConfiguration = $@"{{
           ""$type"": ""Stylelabs.M.Base.MassEdit.MassEditJobDescription, Stylelabs.M.Base"",
    ""Operations"": [
            ""$type"": ""Stylelabs.M.Base.MassEdit.RefreshRenditionsOperation, Stylelabs.M.Base"",
            ""Renditions"": [{string.Join(",", renditionNames.Select(name => $"\"{name}\""))}],
            ""FailedOnly"": false,
            ""RefreshHistory"": false,
            ""RefreshSubfiles"": false
    ""FinalizeOperations"": [],
    ""Targets"": [{string.Join(",", targetIds)}]

descriptionEntity.SetPropertyValue("Job.Configuration", JToken.Parse(jobConfiguration));       

var jobRel = descriptionEntity.GetRelation("JobToJobDescription", RelationRole.Child);       
jobRel.SetIds(new long[] { jobId });              
var descriptionId = await client.Entities.SaveAsync(descriptionEntity).ConfigureAwait(false);              

// logger.LogInformation($"Created job description {descriptionId}");       

// And finally update the job (we can only do that after the description is created)           

var loadConfig = new EntityLoadConfiguration()        
    PropertyLoadOption = new PropertyLoadOption("Job.State", "Job.TargetCount"),
    RelationLoadOption = RelationLoadOption.None,
    CultureLoadOption = CultureLoadOption.Default       
jobEntity = await client.Entities.GetAsync(jobId, loadConfig).ConfigureAwait(false);       
jobEntity.SetPropertyValue("Job.State", "Pending");       
jobEntity.SetPropertyValue("Job.TargetCount", Convert.ToInt64(targetIds.Count));       

await client.Entities.SaveAsync(jobEntity).ConfigureAwait(false);  

  • Add content from blog here as well, because this blog may not work sometimes. Oct 21, 2022 at 5:53
  • Hi Gautam, this is a link only answer. To better serve this community, can you please add a more complete answer.
    – Pete Navarra
    Oct 21, 2022 at 21:05
  • Updated my answer to serve better this community -Thank!
    – Gautam
    Jun 22 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.