Accessing a custom website setting by Macro Expression

David Pearson asked on May 7, 2019 22:43

I set up a custom setting using Adding custom website settings in documentation as a guide.

I would like to access this setting value via a Macro Expressions but only users with global admin privilege level can load those values according to the documentation.

The macro is returning this: {% Settings.JavaScriptVersion |(identity)GlobalAdministrator|(hash)d77385f5311c76c9a28cd04871c5156fd5037f3f1b80748d07575ac603f462d2%}

Is there a way around this? I am trying to load this value in the Master Page Template.

Thanks David

Correct Answer

Zach Perry answered on May 8, 2019 14:54

That identity is part of the macro security, it runs under that user context.

Docs

You can use {% Settings.JavaScriptVersion @%} instead to not have that show up, but it will run under the public user and may not have access. See more docs here.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Zach Perry answered on May 8, 2019 07:39

The global admin is the only one who can add that macro, but not the only one who can see the result.

I would make sure you are using the correct code name. You can validate in the macros debug under System.

1 votesVote for this answer Mark as a Correct answer

David Pearson answered on May 8, 2019 14:46 (last edited on December 10, 2019 02:31)

I just tested under the system >> Macros >> Console. The Macro is returning the correct value of 22 here.

I am calling for the value using {% Settings.JavaScriptVersion |(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

David Pearson answered on May 13, 2019 16:15

The public is not able to access the value via Macro.

My Work Around: I edited the Page Template Layout since it is a dynamic ascx control

  1. Created a public property with get; set
  2. In the Page Load I set the property with the value from the web.config app setting.
  3. Assign the property into the layout, in my case the value is in the jS somefile.js?v={#=BuildVersion#}

This works greats and clear our caching issues when the production site is built. The Javascript files gets the last Build Number with each new build, forcing the proxy servers to grab a new copy of the js.

0 votesVote for this answer Mark as a Correct answer

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