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 Reply Children
  • 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
                )
              }
            )
          }
        )
      )
    )

  • this may seem stupid but where do I go to create local variables? in the interface builder there is a section for local variables but there is no add button.

  • 0
    Certified Lead Developer
    in reply to Omar Ali

    I dunno, I always recomment just switching over to Expression Mode (and staying there).