4

I have a custom token %tokenname% in single line text and richtext fields. I would like to replace the token with some custom value in the Sitecore JSON rendering. Please see some example data below:

{
  "uid": "04f1b740-1eff-415e-a1c3-93bce2c2a274",
  "componentName": "GeneralContent",
  "dataSource": "{0F766E67-7341-4155-B53F-5BEA598C8C24}",  
  "fields": {
    "Subheading": {
      "value": "" 
    },
    "Body": {
      "value": "This is the %tokenname% I would like to buy"
    },
    "Heading": {
      "value": "Limited to number of %tokenname% to buy."
    }
  }
}

Just wondering where can I do that. I tried with Sitecore.Pipelines.RenderField pipeline which doesn't work. Is that because I can't use it for JSON Rendering which is different from the traditional Sitecore MVC Controller Rendering?

1
  • Can we have some front end code where you are consuming the field? You should be able to manipulate the value before displaying it. Commented Jun 27, 2022 at 13:57

1 Answer 1

1

Unfortunately, in Sitecore JSS case, fields are not being processed by the RenderField pipeline, therefore, you have to implement your custom token replacement yourself while rendering the concerned fields.

Your Answer

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

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