The requirement is to return the item id in the query string on button click. I added a template in the rendering variant and added the following line

<a href="https://some url?itemid=$item.ID">Button text</a>

Now, I want button text to come from the sitecore field. $item.fieldName is not working. What is the right way of reading the text from the sitecore field in this case?

2 Answers 2


I am in doubt now that Dawid says it doesn't exist ootb, but I have something like this working:


where "BookLink" is the name of my field. Hopefully your field does not have a space in the name ;)

The "ToString" was needed in our case as we wanted to check if it was empty (see Using #if in SXA variant NVelocity template).

  • Yep, this will work! May 29, 2019 at 11:59
  • Thanks . @Gatogordo Can you please tell me how to read the link of the current item in the same case. May 30, 2019 at 14:06

In addition to the method that @Gatogordo suggested you can use this method if your field has spaces in the name:

$item.Fields.get_Item("A Field With Spaces")

You can add .ToString() in the same way as it is used in the other answer.

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.