Executing CMS_Queries in custom macro expression

Sam Mueller asked on March 13, 2017 21:01

How can I execute some of the predefined queries in CMS_Queries within a macro expression?

{% Queries["cms.user.selectbyusername"] #%}

Which is basically this in SQL:
SELECT * FROM CMS_User WHERE UserName = @UserName

I know I have to supply the expression with a UserName value, how would I do that in macro expression form?

Recent Answers

Peter Mogilnitski answered on March 13, 2017 21:36 (last edited on March 13, 2017 21:43)

Normally you create a custom macro and use kentico API to do that, but sometimes you can get by with already defined objects {% GlobalObjects.Users.Where("UserName='Administrator'").FirstItem["UserName"] #%}

P.S. Queries objects shows the content of CMS_Query table, you can't really run this as SQL query.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.