Author Details Submitted for Review in Sitecore Content Hub

The Sitecore Content Hub system does not display information about the author who submitted the content on the content detail page for review. To make the author’s information visible on the content detail page, we need to perform the following activities 

  • Create a new member group with the additional Fields
  • Create a Script, Action, and Trigger to set the values
  • Enable the setting on the page component to display the details

Create a new member group with the additional Fields:

To add information about the author who submitted the item in Content Hub for review, follow these steps to configure it:

Step 1: Navigate to the manage icon and choose the Schema option

author-details-review-ch-1

Step 2: On the Schema page, search for M.Content and on M.Content page, click on the “New Group” option and fill in the details, and click on the save button:

author-details-review-ch-2

Step 3: Once you create a new group, click on the New Member option and add the following new members with respective types:

Member/Property Type

Name

Associated definition

Cardinality

Taxonomy

Submitted By

User

OneToMany

DateTime

Submitted At

NA

NA

In the Taxonomy member type, ensure that the “allow update” field value is set to true under the Advanced Tab.

Step 4: After creating the new member group and respective fields, click on the "Apply Changes" button.

author-details-review-ch-3 Create a Script, Action, and Trigger to set the values

In the next step, you need to create a script, action, and trigger to set the values in the above-created fields. If you are not familiar with the Sitecore Content Hub Script, Action, and Trigger, or how to write and execute them, see the blog post: Create Script, Action, and Trigger in Sitecore Content Hub

Step 1: Create a new Script and paste the following code to assign the values in the fields when the author submits content for review. 

using System.Linq;
var entity = Context.Target as IEntity;
var contentId = entity.Id ;
if (!contentId.HasValue) 
{
  MClient.Logger.Info("no entity");
  return;
}
var currentUserId = Context.TriggeringUserId ?? 0;
if (currentUserId == 0) return;
var submittedByRelation = entity.GetRelation<IChildToOneParentRelation>("SubmittedBy");
if (submittedByRelation != null && entity.ModifiedBy > 0) {
  var lastModify = entity.ModifiedOn;
  entity.SetPropertyValue("SubmittedAt", lastModify);
  submittedByRelation.Parent = currentUserId;
  try {
    await MClient.Entities.SaveAsync(entity).ConfigureAwait(false);

    MClient.Logger.Info($"submitted by: {currentUserId}");
  }
  catch (Exception e)
  {
    MClient.Logger.Error(e.Message);
  }
}

Step 2: Create an Action and assign the above script.

Step 3: Create a Trigger and in the Condition tab, set the following condition so that the action will be triggered when the author submits the content for review instead of the Save button.

author-details-review-ch-4

Step 4: Set the previously created action into the Action Tab of the trigger.

Enable the setting on the page component to display the details

Step 1: Navigate to the manage icon and choose the Page Option 

author-details-review-ch-5

Step 2: From the left panel and navigate to the Content Details page under Content. After that, in the right panel, scroll down to the end and click on the "+ Component" to new component on the content details page.

author-details-review-ch-6

Step 3: Click on the “+ Component” icon and search for the Entity Details component in the popup, enter the name, and create a new Entity Details component.

Step 4: Click on the new Entity Details component and on the details component page, go to the members tab and toggle on the Submit Details member group which created earlier.

author-details-review-ch-7

Step 5: Click on the Save button, and now you can see the author details on the Content Entity details page, who submitted the content for review.

Happy Sitecoreing ðŸ˜Š

Comments

Popular posts from this blog

Sitecore Installation Error: Failed to Start Service 'Sitecore Marketing Automation Engine'

Import CSV Data in Sitecore Using PowerShell: Part-3

Error: Method Through Reflection is Not Allowed after Applying Sitecore Hotfix