Button Configurations

Certified Associate Developer

Hi Community Team

I have a query, I need to configure the formlayout buttons. Like Approve and Reject

1. When I click on a Submit button first time, a textfield needs to be populated. It is populated then I click on the submit second time, It Needs to store the textfield field data  into the DB.

But, here I'm facing issue, When I click on Submit Button Firsttime.. tn the Process Model the action is completed.. Unable to add data to the textfield. In DB is showing Empty.

For the textfield I applied ShownWhen: ri!Cdt.Status = true(),

2. When I click on the Cancel button first time, a Textfield needs to be populated. It is populated then I click on the cancel button again, No actions were taken. I want it to complete the action. Needs to store the textfield field data  into the DB.

Similarly, here also For the textfield I applied ShownWhen: ri!Cdt.Status = false(), 

Status is a boolean field in my cdt.

Can You help me out, how to figure it out.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Try in the button Widget keep the submit as false for initial submit and make true for secondary submit so that you can achieve this.

    And in same way implement for cancel as well

  • 0
    Certified Associate Developer
    in reply to JayaPrakash Ravipati

    Hi JayaPrakash, I really appreciate your approach.. My first idea is to implement like yours.. When I click on  submit Textfield is not populated  my form was submitted and then action is completed. Later, I realized to go with the radio buttons, it is one of the possible way to solve my approach.

    I'm not familiar and not aware with initial Submit and secondary submit. Could you please explain how it works.. and can you share the code for the reference.. it really helps everyone who wants to solve this kind of approaches in future.

  • 0
    Certified Lead Developer
    in reply to Chandrasekhar Reddy
    can you share the code for the reference

    The buttonWidget() component has a parameter called "submit", which accepts a boolean value (true or false).  If it's set to false, the form/task will not submit upon click of the button, while any saves in its saveInto parameter will execute.

  • 0
    Certified Associate Developer
    in reply to Chandrasekhar Reddy

    Hi ,

    try the below code So, you will know how the submit parameter works in buttonwidget()

    a!localVariables(
      local!map: a!map(name: "", email: "", comment: ""),
      local!submit: false(),
      local!showWhen: true(),
      {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Name",
                  value: local!map.name,
                  saveInto: local!map.name
                ),
                a!textField(
                  label: "Email",
                  value: local!map.email,
                  saveInto: local!map.email
                )
              },
              showWhen: local!showWhen
            ),
            a!columnLayout(
              contents: {
                a!paragraphField(
                  label: "Comments",
                  value: local!map.comment,
                  saveInto: local!map.comment
                )
              },
              showWhen: not(local!showWhen)
            ),
            a!columnLayout()
          }
        ),
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: if(local!submit, "Approve", "Submit"),
              saveInto: {
                a!save(local!showWhen, false()),
                a!save(local!submit, true())
              },
              submit: local!submit,
              style: "PRIMARY"
            ),
            
          },
          secondaryButtons: {
            a!buttonWidget(
              label: if(local!submit, "Reject", "cancel"),
              saveInto: {
                a!save(local!showWhen, false()),
                a!save(local!submit, true())
              },
              submit: local!submit,
              style: "SECONDARY"
            )
          }
        )
      }
    )

Reply
  • 0
    Certified Associate Developer
    in reply to Chandrasekhar Reddy

    Hi ,

    try the below code So, you will know how the submit parameter works in buttonwidget()

    a!localVariables(
      local!map: a!map(name: "", email: "", comment: ""),
      local!submit: false(),
      local!showWhen: true(),
      {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Name",
                  value: local!map.name,
                  saveInto: local!map.name
                ),
                a!textField(
                  label: "Email",
                  value: local!map.email,
                  saveInto: local!map.email
                )
              },
              showWhen: local!showWhen
            ),
            a!columnLayout(
              contents: {
                a!paragraphField(
                  label: "Comments",
                  value: local!map.comment,
                  saveInto: local!map.comment
                )
              },
              showWhen: not(local!showWhen)
            ),
            a!columnLayout()
          }
        ),
        a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: if(local!submit, "Approve", "Submit"),
              saveInto: {
                a!save(local!showWhen, false()),
                a!save(local!submit, true())
              },
              submit: local!submit,
              style: "PRIMARY"
            ),
            
          },
          secondaryButtons: {
            a!buttonWidget(
              label: if(local!submit, "Reject", "cancel"),
              saveInto: {
                a!save(local!showWhen, false()),
                a!save(local!submit, true())
              },
              submit: local!submit,
              style: "SECONDARY"
            )
          }
        )
      }
    )

Children
No Data