cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
reub77
Level: Power Up

Issue adding to previous value of a number field

I'm trying to update a percent complete field. There are three approvers and each one can approve at any time. I'm trying to add to this column and its previous value each time an approval comes through.

 

Ie. Supervisor approves -> i then update it to 33.3%, etc.

 

My first attempt I tried adding the 33.3 to the value of Percent Complete each time an approval comes through. Final approval would add 33.4. Seemed pretty straight forward but i get an error. Here's my workflow:

 

errorworkflow4.PNG

 

The approvals all work but i can't seem to get this running total going for all the approvals. For the adding i used this in the expression window:

 

add(body('Get_items')?['_x0025__x0020_Complete'], 33.3)

- This should add the new value to whatever the previous value was.

 

The error i get is (error disaappears when i remove the adding function and workflow runs fine, but i'd like to have a running percent complete total working):

 

'InvalidTemplate. Unable to process template language expressions in action 'Update_item_3' inputs at line '1' and column '2643': 'The template language function 'add' expects its first parameter to be an integer or a decimal number. The provided value is of type 'Null'. Please see ...

 

Note: I'm doing the adding on a 'number' field within SharePoint (displaying as a percentage). I'm using another list to collect my approvals and then update and aggregate them together on a master list. I know there's easier ways to do approvals but this is what the requirements led us to build.

2 REPLIES 2
Super User
Super User

Re: Issue adding to previous value of a number field

@reub77 

Hi there!  I think this makes sense...Your condition path says "If this thing is null, add a number to it", but "null" is not the same as "zero" and the add function wants to see a number before it can add anything to it, right?

My suggestion (there are probably more elegant ways to do this) is to initialize a variable at the beginning and set it to zero.  Then add the 33.3 to the variable in the path and update your % complete to the variable.

 

Another option would be to set the default value in your SP list for that field to "0", if possible.

 

Will that work?

-Ed-

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

reub77
Level: Power Up

Re: Issue adding to previous value of a number field

I know the screenshot was very hard to see clearly (was trying to squeeze everything in). The test for null is testing the people field's for a value and it works. It will test that it's empty and then proceed to populate it if it is empty. If it isn't empty it means that they are approving the same item again for the a role that has already approved which would not be required and would be ignored.

 

The workflow only errors when i try and add to the value that is currently in the field, which would be zero by default. 

I've updated the above screenshot for clarity.

 

 

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 370 members 4,114 guests
Please welcome our newest community members: