How to create a total field

Hi,

I'm new to Appian and I'd like to create a total field.

example:

field1+

field2 +

field3+

field4

-------

total 

and I'd like to display the total in a text field 

thanks,

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The simplest way by far would be to create a 5th text field below the previous 4, and set it to readOnly with a value of "ri!field1 + ri!field2 ..." etc.

  • Hi Mike, 

    I was able to display the total amount of the 4 fields in a text field but how can I save the sum of 4 fields in my total fields. In powerApps , you just need to create a calculated field but I don't know how it works in Appian.

    Thanks,

  • 0
    Certified Lead Developer
    in reply to Omar Ali

    This depends a bit on the context of what you're trying to do and where/how.  Is this a form used on a Task in a running process model?  If so, the easiest way I've found to do something like this is to have your Submit button save the calculated value into a Rule Input, passing that value back into the process where you can use it for whatever you were wanting.

  • Hi Mike,

    I was charged by my organization to evaluate Appian. I have created a form where employees submit a training request including the cost of the training. I have a section for inputting the cost with 4 decimal fields(tuition cost, living cost….etc) to input the financial information and 1 field to save the total of the cost. It is all part of an approval process where the employee submit the form a manager recommend it and finally an executive will approve it. I need help to saving the total cost in a Totalcost field.

    Thanks mike for your it is really appreciated.

  • 0
    Certified Lead Developer
    in reply to Omar Ali

    Here's a quick example of how I would structure this - this only has 2 initial values but can be scaled to pretty much as many as you want.

    a!localVariables(
      local!item1: 0,
      local!item2: 0,
      
      local!total: local!item1 + local!item2,
      
      a!formLayout(
        label: "Addition example",
        contents: {
          a!textField(
            label: "Value 1:",
            value: local!item1,
            required: true(),
            saveInto: {a!save(local!item1, tointeger(save!value))}
          ),
          a!textField(
            label: "Value 2:",
            value: local!item2,
            required: true(),
            saveInto: a!save(local!item2, tointeger(save!value))
          ),
          a!textField(
            label: "Totals:",
            readOnly: true(),
            value: local!total
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              saveInto: {
                a!save(
                  ri!evaluatedTotal,
                  local!total
                )
              }
            )
          }
        )
      )
    )

Reply
  • 0
    Certified Lead Developer
    in reply to Omar Ali

    Here's a quick example of how I would structure this - this only has 2 initial values but can be scaled to pretty much as many as you want.

    a!localVariables(
      local!item1: 0,
      local!item2: 0,
      
      local!total: local!item1 + local!item2,
      
      a!formLayout(
        label: "Addition example",
        contents: {
          a!textField(
            label: "Value 1:",
            value: local!item1,
            required: true(),
            saveInto: {a!save(local!item1, tointeger(save!value))}
          ),
          a!textField(
            label: "Value 2:",
            value: local!item2,
            required: true(),
            saveInto: a!save(local!item2, tointeger(save!value))
          ),
          a!textField(
            label: "Totals:",
            readOnly: true(),
            value: local!total
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              saveInto: {
                a!save(
                  ri!evaluatedTotal,
                  local!total
                )
              }
            )
          }
        )
      )
    )

Children