Macro within page type field not resolving

Irvin Hercules asked on October 9, 2020 14:54

We have a macro that returns a string based on a cookie value (the value is matched to a list of theme colors):

CurrentTheme("") returns "theme_red" if this was previously set, else a default value is returned

It also creates/updates the cookie value when a second "override" argument is received:

currentTheme("theme_blue", "Override") will update the value and return "theme_blue"

We have two pages that set the theme color to either red or blue when visited and a bunch of dynamically themed pages that sets a CSS container class from the return string value of the macro.

Testing the macro in the console works 100%, but we are getting strange results when trying to call the macro from a page type field. In a drop down list it gets the value from the macro once and fails to update when the value changes... so it looks as if it sets the value instead of calling the macro on every subsequent page load. The reason for using a drop down list is because there are other theme colors that are set as static.

When using text fields the macro does not resolve at all.

I hope my explanation is clear. If not, please let me know and I will try my best to elaborate. Thank you

Recent Answers

Brenden Kehren answered on October 10, 2020 16:32

Maybe provide where and how you're setting these macro values for some additional context

0 votesVote for this answer Mark as a Correct answer

Irvin Hercules answered on October 19, 2020 16:46

Hi Brenden, thanks for reaching out.

The issue has since been resolved. Calling the macro directly from the web part would not update the cookie, but doing it inside a placeholder in the layout did the trick.

0 votesVote for this answer Mark as a Correct answer

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