Can a variable be used in macro expression?

194 Views Asked by At

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;
2

There are 2 best solutions below

0
On BEST ANSWER

Yes, please see the macro syntax documentation

0
On

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;