Got an awesome blog, You can take the reference from that
https://www.contenthub.dev/2022/10/content-hub-tip-27-refresh-renditions.html
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>
{
32637
// 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);