Macro Rule Parameters: how to reference one field from another?

Daniel Ward asked on November 30, 2018 20:18

I'm setting up a macro rule with a few parameters. I have one parameter that displays as a dropdown list, with options sourced from the Kentico database via SQL query, and I want to limit the options based on the selection of another parameter field in the same macro rule. Is it possible to reference the selected value of another field in a query, or is there a better way to do this? I've tried including variations of syntax like {%fieldname.Value#%} in my WHERE clause, and while it doesn't generate any errors, I don't get any value for the field when I evaluate it.

Correct Answer

Peter Mogilnitski answered on December 1, 2018 04:34

Your second sql query is crushing, because the first one does not return anything. Forget about macro rules. You have 2 fields and you want to one field show values based on another field, you have 2 columns role and user, here how you do it:

First column is called role you put

select 0,'please select role'
union
select distinct roleid, RoleDisplayName from  View_CMS_UserRole_Joined

and set Has depending fields: yes

second column is called user, you put

select 0, 'please select user'
union
SELECT userid, UserName FROM View_CMS_UserRole_Joined where roleid = {%role%}

and Depends on another field: yes

0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on November 30, 2018 23:05 (last edited on November 30, 2018 23:11)

should be just {%fieldname%}. Might need to check Has depending fields and
Depends on another field.
Image Text

You have to save the form though:

Image Text

0 votesVote for this answer Mark as a Correct answer

Daniel Ward answered on December 1, 2018 01:04

Thanks, I tried all that but it's not working, including the dependency checkboxes. For clarification, I'm working on a macro rule for a contact group. The parameter with a dependency just generates a SQL error because the dependent value never resolves.

From what I read, the "Has dependent fields" setting is supposed to cause the page to refresh/post back after selecting a value, but that doesn't happen.

My source field parameter (UserID) looks like this: Image Text

My parameter using the UserID field looks like this: Image Text

My macro rule: Image Text

And in my contact group condition, I'm able to select the first parameter, but not the second: Image Text Image Text

0 votesVote for this answer Mark as a Correct answer

benyamin jain answered on December 1, 2018 09:32 (last edited on December 1, 2018 09:33)

this error more likely about the the types of field you use.is both fields are integral?

also it is possible that your macro not resolved correctly.

0 votesVote for this answer Mark as a Correct answer

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