Macro in where condition

lawrence whittemore asked on April 10, 2015 06:23

I have this as a macro {% cookie = Cookies["Season"].ToString(); month = currentdatetime.Month; if (cookie == "") {if (month > 2 && month < 6) {x = "1"}; if (month > 5 && month < 9) {x = "2"}; if (month > 8 && month < 12) {x = "3"}; if (month > 11) {x = "4"}; if (month < 3) {x = "4"}; return x} else {return cookie}|(handlesqlinjection)false#%}

and am trying to put it in a where condition but it doesn't seem to want to resolve. When I place it in a different field it resolves a 1. When I type a 1 into my where condition it yields the results I want.

Am I missing something? in version 7.0.103

Recent Answers


Jan Hermann answered on April 10, 2015 06:57

Hello,

it should get resolved in the Where condition as well. Please open the macro editor by clicking the small black arrow that is next to the Where condition label and copy your macro there.

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 10, 2015 13:45

Lawrence have you tried turning on Debugging to see what the macro is outputting? Are there any errors in the event log?

0 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on April 10, 2015 14:18 (last edited on December 10, 2019 02:30)

I turned on macro debugging and the macro doesn't even run. I also tried adding a simpler macro and it doesn't run it just shows up as code.

Do macros not work in widgets?

This is what it shows in the where condition when the page tries to load {%CurrentDocument.DocumentName|(identity)GlobalAdministrator%}' + '|%')

0 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on April 10, 2015 14:48

As a test I made added a repeater with the same settings directly to the page and it worked fine. So there is something with the widget that I am doing wrong.

0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on April 10, 2015 14:54 (last edited on December 10, 2019 02:30)

Hello Lawrence,

Did you tried with parentheses?

Something like this:

{% ( cookie = Cookies["Season"].ToString(); month = currentdatetime.Month; if (cookie == "") {if (month > 2 && month < 6) {x = "1"}; if (month > 5 && month < 9) {x = "2"}; if (month > 8 && month < 12) {x = "3"}; if (month > 11) {x = "4"}; if (month < 3) {x = "4"}; return x} else {return cookie} ) |(handlesqlinjection)false|(identity)GlobalAdministrator%}

2 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on April 10, 2015 14:59

No Luck, I have also tried changing the where conditions filed Form control to different types to see if that would help

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on April 10, 2015 16:42

In order for your custom macro to be debugged, I think you need to include the (debug)true at the end along with the sql injection. Try placing that in and see if your starts to show up in the debug.

0 votesVote for this answer Mark as a Correct answer

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