User-Select Field in Confluence
Asked by Phillip Yero:

I am creating a table where others will be inputting information and one of the fields is *Status*. Now I know Confluence has the Status Macro, but I am looking for something a little more robust that would allow me to limit the choices others have to a list of set stati. This would remove spelling capitolization, and wording errors. I was thinking a drop down user-select field woudl be best, but I'm open to other suggestions.


Answers:
author: Steve Goldberg
body: To build on what Davin said. Create a user macro that uses the enum parameter type (see <https://confluence.atlassian.com/display/DOC/Guide+to+User+Macro+Templates#GuidetoUserMacroTemplates-Usingparametersinyourusermacro>). The call the status macro within that macro and have it set the variable's value based on the enum value.

comments: author: Davin Studer
body: Exactly what I would have suggested.


author: Phillip Yero
body: Many thanks.


author: Robin Roos
body: Any idea how this could be changed to allow users to alter a status without actually having to EDIT the page?


author: Davin Studer
body: Would a macro that only allows specific choices work? This could be done fairly easy with a user macro.

comments: author: Phillip Yero
body: Thanks, I think that'll work.


author: Davin Studer
body: Hers is soemthing I whipped up that could work. Just edit the enum values and what the color assignment for those values are and you should be good to go.

**Macro Body Processing:**   
Escaped

**Template:**   
## Macro title: My Status  
## Macro has a body: N  
## Developed by: Me  
## Date created: 09/26/2013  
## Installed by: Me  
## A specific list of status values.

## @param Status:title=Status\|type=enum\|enumValues=Good,Mediocre,So-so,Bad,What!\|default=auto\|desc=Pick a status.

#if ( $paramStatus \&\& $paramStatus == "Good")  
#set ( $color = "Green" )  
#elseif ( $paramStatus \&\& $paramStatus == "Mediocre")  
#set ( $color = "Grey" )  
#elseif ( $paramStatus \&\& $paramStatus == "So-so")  
#set ( $color = "Yellow" )  
#elseif ( $paramStatus \&\& $paramStatus == "Bad")  
#set ( $color = "Red" )  
#elseif ( $paramStatus \&\& $paramStatus == "What!")  
#set ( $color = "Blue" )  
#end

\<ac:macro ac:name="status"\>  
\<ac:parameter ac:name="colour"\>$!color\</ac:parameter\>  
\<ac:parameter ac:name="title"\>$!paramStatus\</ac:parameter\>  
\</ac:macro\>


author: Phillip Yero
body: Wow, thank you so much! This is perfect. Would you happen to know how to add the "Use Outline Style" option?


author: Davin Studer
body: **Macro Body Processing:**   
Escaped

**Template:**   
## Macro title: My Status  
## Macro has a body: N  
## Developed by: Me  
## Date created: 09/26/2013  
## Installed by: Me  
## A specific list of status values.

## @param Status:title=Status\|type=enum\|enumValues=Good,Mediocre,So-so,Bad,What!\|default=auto\|desc=Pick a status.

#if ( $paramStatus \&\& $paramStatus == "Good")  
#set ( $color = "Green" )  
#elseif ( $paramStatus \&\& $paramStatus == "Mediocre")  
#set ( $color = "Grey" )  
#elseif ( $paramStatus \&\& $paramStatus == "So-so")  
#set ( $color = "Yellow" )  
#elseif ( $paramStatus \&\& $paramStatus == "Bad")  
#set ( $color = "Red" )  
#elseif ( $paramStatus \&\& $paramStatus == "What!")  
#set ( $color = "Blue" )  
#end

\<ac:macro ac:name="status"\>  
\<ac:parameter ac:name="colour"\>$!color\</ac:parameter\>  
\<ac:parameter ac:name="title"\>$!paramStatus\</ac:parameter\>  
\<ac:parameter ac:name="subtle"\>true\</ac:parameter\>  
\</ac:macro\>


author: Davin Studer
body: Small edit. The Macro Body Processing should not be **Escaped** . It should be **No macro body**. Not sure whay I made that typo.


author: Phillip Yero
body: Yeah, I figured as much so I changed it. Thanks for looking out.


Tags: custom-field

macro