Consp
Consp

Reputation: 5

Can a variable be used in macro expression?

Can a variable be used like this code in the macro expressions to retrieve values dynamically?

I am trying the code below which return as null.

var indexId = 45;

return CMSContext.Current.GlobalObjects.Users[indexId].DisplayName;

Upvotes: 0

Views: 207

Answers (2)

Consp
Consp

Reputation: 5

I figured that the code should be on the same line. Earlier I was declaring the variable in separate line. So this works now

indexId = 45;return CMSContext.Current.GlobalObjects.Users[indexId].DisplayName;

Upvotes: 0

jurajo
jurajo

Reputation: 995

Yes, please see the macro syntax documentation

Upvotes: 0

Related Questions