How to create Listitems for dropdown using K# macro

Aniket Pudale asked on March 3, 2017 07:11

I am trying to show Radio buttons for form field using macro depending on user role. Here is code if (CurrentUser.IsInRole("BasicUsers")) {"1;Properties" } else {if (CurrentUser.IsInRole("SalesTeam")) {"4;Digital Assets"

} else{if (CurrentUser.IsInRole("MarketingTeam")) {"2;Description & Marketing Info"} } }# This code is working fine, But when if i want to add one more radio button for some role using code below if (CurrentUser.IsInRole("BasicUsers")) {"1;Properties" } else {if (CurrentUser.IsInRole("SalesTeam")) {"4;Digital Assets" "1;Properties" } else{if (CurrentUser.IsInRole("MarketingTeam")) {"2;Description & Marketing Info"} } }# This code is not showing any Radio buttons. is there any specific syntax for creating listItem in macro?

Correct Answer

Peter Mogilnitski answered on March 3, 2017 07:59

ok the syntax is: value;name;macro visibility condition.

Assuming you want to make certain radio buttons visible only for certain roles:

1;Properties;{%CurrentUser.IsInRole("BasicUsers") || CurrentUser.IsInRole("SalesTeam")|(identity)GlobalAdministrator%}
1 votesVote for this answer Unmark Correct answer

Recent Answers


Aniket Pudale answered on March 3, 2017 08:12

Thanks

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on March 3, 2017 08:46

The result of your macro expression needs to return pairs of values separated by new line in List of options option. For example:

{%"1;first\n2;second"%}

0 votesVote for this answer Mark as a Correct answer

Aniket Pudale answered on March 3, 2017 10:25 (last edited on December 10, 2019 02:30)

1;Properties 2;Description & Marketing Info;{%CurrentUser.IsInRole("MarketingTeam")|(identity)GlobalAdministrator%}

Return Error- The entered values cannot be saved. Please see the fields below for details. Data source: The options must be in format value;text there must be only one option on each line.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 3, 2017 14:59 (last edited on December 10, 2019 02:30)

Not sure that your syntax with semicolon is correct, try this instead:

4;Digital Assets;{%CurrentUser.IsInRole("SalesTeam") || CurrentUser.IsInRole("MarketingTeam")|(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

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