Confiforms - Sum task effort in a summary page
Asked by Fran?ois-Xavier Collet:

I probably missed something big,... but I'm not able to find a way to sum Confiforms field in a summary page.

I have Confiform "Task" form containing records. One of the "Task" field is "Effort" and another one is Project page ID "ParentProject".

On the Project page, I have table vew showing all the tasks of the project filtered by "ParentProject". --\> This works well unsing a Confiforms TableView.

On this same page I would like to have a project overview showing the total effort of all the tasks linked to the project.

Can someone help me with this?

If I use a ValueView, I can list all the efforts linked to the project filtered by "ParentProject"(something like "2 4 7 1") but can't sum those value.

Any input welcome.

Thanks

Xavier


Answers:
author: Alex Medved _ConfiForms_
body: With ConfiForms ValueView you can use the expression inside the field name and that is done the same way as you will do it in a TableViewMerger fields

Some field:(\[entry.**_here_field_name_to_sum_**\])

comments: author: Fran?ois-Xavier Collet
body: I'm not able to get the sum out of the ValueView...

![ValueViewDefinition.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/45847i6FDF7DE2780CE0ED/image-dimensions/631x409?v=v2 "ValueViewDefinition.PNG")I got this result... Which is the different effort for each tasks. total should be 10...![ValueViewResult.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/45848iD5D2EEE7F2E3ECB6/image-size/large?v=v2&px=999 "ValueViewResult.PNG")

Regards

Xavier


author: Alex Medved _ConfiForms_
body: Do you want the sum of 1+2+3+4 or the count?

for sum

Tasks sum:(\[entry.TskOnSiteEffort\])

for count

\[count\]

or

Count:(\[count\])


author: Fran?ois-Xavier Collet
body: Almost there...

If I use:

sum:(\[entry.TskOnSiteEffort\]), I get no value

If I use

sum:(TskOnSiteEffort) I got a value but the sum is a little strange...

If I have 2 tasks, it sum all the task 2 times... Task 1 (effort 1), Task 2 (effort 2) result is 6

If I have 3 task, it sum all the task 3 times... Task 1 (effort 1), Task 2 (effort 2),Task 3 (effort 3) result is 18

Total on-site effort:  
\<ac:structured-macro ac:name="confiform-value" ac:schema-version="1" ac:macro-id="6036a2ea-310f-477f-991e-dd6d1a29581a"\>  
\<ac:parameter ac:name="filter"\>TskParentPrj.PrjPage.id:509455602\</ac:parameter\>  
\<ac:parameter ac:name="fieldName"\>TskOnSiteEffort\</ac:parameter\>  
\<ac:parameter ac:name="pageTitle"\>  
\<ac:link\>  
\<ri:page ri:content-title="CFTask" /\>  
\</ac:link\>  
\</ac:parameter\>  
\<ac:parameter ac:name="formName"\>CFTask\</ac:parameter\>  
\</ac:structured-macro\>  
should be = to  
\<ac:structured-macro ac:name="confiform-value" ac:schema-version="1" ac:macro-id="7a1b8601-dbef-4dfe-9dcf-bb23ec590fbf"\>  
\<ac:parameter ac:name="filter"\>TskParentPrj.PrjPage.id:509455602\</ac:parameter\>  
\<ac:parameter ac:name="fieldName"\>Sum:(TskOnSiteEffort)\</ac:parameter\>  
\<ac:parameter ac:name="pageTitle"\>  
\<ac:link\>  
\<ri:page ri:content-title="CFTask" /\>  
\</ac:link\>  
\</ac:parameter\>  
\<ac:parameter ac:name="formName"\>CFTask\</ac:parameter\>  
\</ac:structured-macro\>

With this code I get the bellow results...

![Effort.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/45864iAD8EEAD3B15E4C1A/image-size/large?v=v2&px=999 "Effort.PNG")


author: Alex Medved _ConfiForms_
body: Quick test (form and value views)

```
<ac:structured-macro ac:macro-id="6ae76d77-d3c0-44a5-be03-15b573abb374" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="5d98717b-0049-45c5-bb25-698297711242" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="12d99662-7fb5-45f7-96c0-9b3547608b3c" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">n</ac:parameter>
<ac:parameter ac:name="fieldLabel">n</ac:parameter>
<ac:parameter ac:name="type">number</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>All</p>
<ac:structured-macro ac:macro-id="e79853af-bb1b-4223-9c80-17274e305976" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>Sum</p>
<p>
<ac:structured-macro ac:macro-id="fc8a9f62-8b91-47f3-8d34-d0a12a887043" ac:name="confiform-value" ac:schema-version="1">
<ac:parameter ac:name="fieldName">sum:([entry.n])</ac:parameter>
<ac:parameter ac:name="formName">f</ac:parameter>
</ac:structured-macro>
</p>
<p>count</p>
<p>
<ac:structured-macro ac:macro-id="f0fe510a-afa9-4284-9dea-c9cb7440a642" ac:name="confiform-value" ac:schema-version="1">
<ac:parameter ac:name="fieldName">sum:([count])</ac:parameter>
<ac:parameter ac:name="formName">f</ac:parameter>
</ac:structured-macro>
</p>
```

Works very well for me.

What ConfiForms version are you using?


author: Fran?ois-Xavier Collet
body: Using ConfiForms (version: **2.0.18** )

I will create a new form to test on something simpler...

I'll let you know if I have the same issue.

Many thanks for your support

Xavier


author: Fran?ois-Xavier Collet
body: It works...

My mistake, the ValueView was in a ListView... moved it outside and now the \[entry.TskOnSiteEffort\] is recognized and the sum work just fine!

Many thanks

Xavier


author: Alex Medved _ConfiForms_
body: It might be also possible to have it inside the ListView, but you need to handle the "double evaluation" of the expressions

So instead of

```
[entry.TskOnSiteEffort]
```

you will need to do something like

```
[entry._func.asEntryRef(entry.TskOnSiteEffort)]
```

So the ListView evaluates it to "\[entry.TskOnSiteEffort\]" which is then used by ValueView

See more about virtual functions in ConfiForms here: <https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions>


author: Fran?ois-Xavier Collet
body: This work fine, many thanks.  
I have one final problem now (I hope it's the final one... ;o)).  
I use an ifttt marco to create a page (which should contain the ValueView fields).  
In my ifttt macro i have this...

![IFTTT marco page create.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/46007iC54F47C21121E326/image-size/large?v=v2&px=999 "IFTTT marco page create.PNG")  
But when I execute the macro, I "lose" the entry fields name.

![Result in the created page.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/46008iA36AA86293D9AAF5/image-size/large?v=v2&px=999 "Result in the created page.PNG")  
Expected result (which is Ok if I create the page manually)

![Expected page created result.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/46009iF38662203304AFC7/image-size/large?v=v2&px=999 "Expected page created result.PNG")  
Is there anything in the ifttt syntax I should add to preserve the expression value?  
Thanks  
Xavier


author: Alex Medved _ConfiForms_
body: You need to use the asEntryRef function, as I have mentioned in my comment on Friday

The problem is - when you create a page with IFTTT macro then the expressions get evaluated agains the current record's values

And you need to handle this yourself or create the template and include it in a raw format, without evaluation of the expressions: <https://wiki.vertuna.com/display/CONFIFORMS/Using+Confluence+templates+with+ConfiForms+and+avoid+configuration+duplication>


author: Fran?ois-Xavier Collet
body: Hi Alex,

Still working on this test configuration,... but have now another problem (linked with the rawtemplate usage).

I have 2 forms, one "CFProject" form (which create a project page) and a "CFTask" which also create a Task page (but the pages are not the problem).

The "CFProject" form has a field "PrjPage" which store the project page id.  
The "CFTask" form has a field "TskParentPrj" which is a Smart Dropdown which I use to store a ref to the parent project.

On the project page I have a "CFTask" registration macro which pass to the new "CFTask.TskParentPrj" value = "CFProject.id" to the new task.  
This work just fine!  
The "CFTask" registration button was initally created by a IFTTT macro which pass the "CFProject.id".

But now I'm using a rawtemplate to create the Project page,... this doesn't work anymore.

My question is then how (if possible) to get the CFProject.id and pass it to the new task...

In the Task registration, I can use \[entry._page.parent.id\] which gives me the "PrjPage.id" from the "CFProject" form, but from this point I'm not able to get the corresponding "CFProject.id" that the Smart Dropdown is expecting.

Any magical trick to get this to work (not sure my explainatio nis very clear)?  
Many thanks  
Regards  
Xavier


author: Alex Medved _ConfiForms_
body: When you use **rawtemplate** then the expressions you have inside the template are not evaluated

That is by design

If you need to evaluate the parameters inside the template then include it as a normal template, and if you need to have the parameters for some of the parts of your page then use "**asEntryRef**" function

```
[entry._func.asEntryRef(entry.TskOnSiteEffort)]
```

This allows you to "workaround" the evaluation of parameters when page gets created and such expressions become

```
[entry.TskOnSiteEffort]
```

on a created page


author: Fran?ois-Xavier Collet
body: Ok ... now I understand asEntryRef ...

The use of rawtemplate was the lazy approach (in my case).

I will have to update all my template, but so far it seems to work Ok... using a "none raw" template and the asEntryRef for most of the fields...

Confiforms logics is new to me... But I think I start to get it! ;o)

Many thanks

Xavier


author: Fran?ois-Xavier Collet
body: Hi Alex,

I think I will need your support one more time...

All the above work well now.

I have another step I would like to implement in my test configuration.

As I explain, I now have project and Task working well.

My intent is to create an similar form for standard project.

Let say they are StdProject and StdTask.

When I create a new project I can select in a list of stdProject what StdProject I would like to use as "template".

When I create the new Project, I have created a ifttt macro (in the project form) which copy all StdTask linked to the selected StdProject to the new Project...

I have a problem here to copy the stdTask and update it's ParentProject to link it to the new project...

I'm not able to get a ref to the new created project.

Let me know if it's clear or if you need more information to understand what I try to do.

Regards

Xavier


author: Alex Medved _ConfiForms_
body: Sorry, really hard to follow. Could you send a support request via <https://wiki.vertuna.com/display/VERTUNA/Support+Request+Form>, so we can communicate a bit more frequent and exchange the storage formats

Thanks

Alex


author: Fran?ois-Xavier Collet
body: Yes I know hard to explain too...

I will open a support case with more information.

Thanks

Xavier


Tags: confiforms

confluence-server

server