{set-data}
Plugin: Scaffolding Plugin, from version 2.3-dr5
Allows entering of text in a single- or multiple-line text field.
Usage
Parameters
| Name |
Required |
Default |
Description |
| [default]/name | | | The name of the field. |
| value | | | The value to set. You can alternatively use the body of the macro, which is useful if setting more complex wiki markup. |
| type | | text | The type of field to display. May be one of the following:
- text - (default) Text data.
- number - An integer or decimal value.
- date - A date.
- boolean - A true/false value.
- content - A link to a single Confluence page/news item. E.g. 'SPACEKEY:My Page' or just 'My Other Page'.
- attachment - A link to a page/news item attachment. E.g. '^mypicture.jpg'.
- user - A link to a registered user. This is their username, not their full name. E.g. 'joebloe' or 'administrator'.
|
| format | | | The number format (e.g. '#,##0.00') or date format (e.g. 'dd MMM yyyy') to use when parsing the value being set. The parameter will be ignored for data types other than 'number' or 'date'. This is basically required when the data type is 'date', since the default date format is unlikely to be used when setting a date. |
| hidden | | false | When set to 'true', the value being set will not be displayed to the page viewer. |
See Also
Hi
I'm trying to use set-data to get a value from another page to use in an eval-data expression, but I'm getting an error in the formats on the set-data command. This is the code I'm using:
{eval-data:TotalManDays|format=#,##0.0}sumtable("ManDays", "DaysUsed"){eval-data} {set-data:ManDaysBudget|type=number}{report-info:data:Total Planned Time|source=@parent}{set-data} {eval-data:ManDaysRemaining|format=#,##0}${ManDaysBudget}-${TotalManDays}{eval-data}But I get the following error:
set-data: The value provided does not match the number format: {report-info:data:Total Planned Time|source=@parent} 20.0Hmm. I think you'll have to inject the number value into the equation. You could either do it with a {set-data} as you have it, or put it directly into the {eval-data}. My example will do the latter:
{eval-data:TotalManDays|format=#,##0.0}sumtable("ManDays", "DaysUsed"){eval-data} {report-on:content:parent|injected=true}{eval-data:ManDaysRemaining|format=#,##0}%data:Total Planned Time%-${TotalManDays}{eval-data}{report-on}David
Thanks for this but it doesn't quite work. The values set in the example I'm working on are Total Planned Time of 20 and Total Days Used of 9, which should leave a ManDaysRemaining of 11.
If I use your example, I get a result of 20, which suggests that the code is not finding the TotalManDays variable - is it perhaps looking on the parent page?
I then tried the {set-data} route and used the following:
{report-on:content:parent|injected=true} {set-data:ManDaysBudget|type=number}%data:Total Planned Time%{set-data} {report-on} {eval-data:ManDaysRemaining|format=#,##0}${ManDaysBudget}-${TotalManDays}{eval-data}That gave me a result of -9 which suggests that it is not picking up the ManDaysBudget variable - the value of 20.0 is displayed correctly on the screen but the {set-data} is not apparently working correctly. Putting the {report-on} inside the {set-data} gave me the same error as I have before.
I have finally cracked it, however, using {replace-and-render} and putting the {report-on} section in a {replace-item} and putting the variable directly inside the {eval-data}.
Thanks for your help.
Yeah, it's probably related to when eval-data and set-data actually update the stored value - that is, when the user saves the page. It won't be updated until the next save, so 'injection' may not work here.
Anyway, glad you sorted it out.
Hi,
I am using this to try to set a parameter:
{set-data:Type|type=content|hidden=true}{get-data:content:parent > data:FAQ Topic}{set-data}I tried using {report-info} as well but no luck. Is there a nice way to get any added child page to inherit the value of "FAQ Topic" which is a data variable that gets set on the parent like so:
{text-data:FAQ Topic|type=line|required=true}Enter Topic Name{text-data}Thanks.
Are you sure that 'type=content' is what you want here? What macro type is 'data:FAQ Type', and what does it contain? How will you be using the new 'Type' field?
I want to use the new field 'Type' to appear on the main index page, which will list questions from sub-pages that have different values for 'Type'. So from the main page, child page A might have 5 entries and child page B might have 5 entries (with A and B being different 'Types'). Then on the main page, I want to have a list that shows all 10 entries and a column to display the 'Type'.
I think data:FAQ Topic is just text-data, and I am not sure how to "return" that value using the get-data macro.
I'm still not sure I fully understand your use case. Are you saying that you'll have a structure something like this:
And on the hope page you want to list the "FAQ X" pages in a single table, and list the type ('A', 'B', etc) in a column next to it?
That being the case, I would skip the 'set-data/get-data' routine altogether, and just list the 'content:parent' in your report. Something like:
{report-table} {local-reporter:content:children} {expand-on:content:children|as=faq} {local-reporter} {report-column:title=Title}{report-info:expanded:faq > content:title|link=true}{report-column} {report-column:title=Type}{report-info:expanded:item > content:title|link=true}{report-column} {report-table}The expand-on macro will drill down to the children of the 'Type' pages, and put each page in the 'expanded:faq' key. The original type page is in the 'expanded:item' key.
Thanks I will try that!
I'm trying to figure out how to set a value of a field that is not displayed to some users. I have a "Status" field that is not editable or visible by the page creator, but I want the value of the field to be set automatically to "Submitted" when the user saves the page. I thought I could do this using get/set data but am doing something wrong. I think I just don't understand how they work. But here is what I was trying:
{set-data:name=IssueStatus|hidden=true}{get-data:name=IssueStatus}Submitted{get-data}{set-data}The idea was:
IssueStatus = (IssueStatus == null) ? "Submitted" : IssueStatus;
Further down the page is:
{show-to:space=@self:admin} {list-data:IssueStatus|type=select} {list-option}Submitted{list-option} {list-option}Under Review{list-option} {list-option}In Progress{list-option} {list-option}Complete{list-option} {list-option}Postponed{list-option} {list-option}On Hold{list-option} {list-option}Canceled{list-option} {list-data} {show-to}To summarize - how can I initialize the value for a field that a user can't see, and do it without overwriting the field that the admin sees?
Thanks!
As to the basic issue (setting default values for list-data), I don't think you can at present. However, a workaround for your scenario could be to try something like this:
{show-to:space=@self:admin} {list-data:IssueStatusList|type=select} {list-option}Submitted{list-option} {list-option}Under Review{list-option} {list-option}In Progress{list-option} {list-option}Complete{list-option} {list-option}Postponed{list-option} {list-option}On Hold{list-option} {list-option}Canceled{list-option} {list-data} {set-data:name=IssueStatus|hidden=true}{get-data:name=IssueStatusList}Submitted{get-data}{set-data} {show-to}The key is to have different values for the list-data and set-data names. Otherwise, they step on each other's toes.
All that said, I don't think it will truely resolve your issue anyway, since the 'IssueStatusList' will be a WikiReference object while the 'Submitted' value will be a String. You might get away with it in this case, but it's not a general solution. Feel free to create a feature request to allow setting default values in list-data.
I got it to work with a mix of reporting and set-data. Pretty slick, I'd say.
{report-block} {local-reporter:@self} {text-filter:data:IssueStatus|include=.*} {local-reporter} {report-body}{report-body} {report-empty}{set-data:name=IssueStatus|hidden=true}Submitted{set-data}{report-empty} {report-block}Is it possible to set a value on another page? This would be sooo useful because it would allow changes to disparate pages from a report! ...Although I guess I'd need an ajax component to make the update dynamic. Use case: On a report of projects, a popup window or ajax ui allows a project date to be changed on the page being reported on.
Adding a page parameter would do the trick.
{set-data:data:KeyName|page=AnotherPage}The Value{set-data}The short answer is no, you can't. For efficiency reasons set-data only stores values when a page is edited. Any other calls are basically ignored. Changing this would be fairly tricky.
Even your example wouldn't work with set-data. You are basically suggesting a mini 'scaffold edit' page. That might be possible, but would require some custom plugin work, and not trivial at that...
Thanks for the quick reply! Is there another route to setting some data on another page?
Is Scaffolding data accessible and/or modifiable directly via something like Scriptix?