How to show the confirmation form on any action

Certified Senior Developer

I want to know about to show confirmation form on any error or completion of a particular activity. 

Suppose, in write to data store entity, i want to show the alert box on the success updation/insertion of the data.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    The simplest way to do exactly what you specify is to populate PV's using the onSuccess output and onError outputs that come pre-defined in the Write to Datastore node.  Then use an XOR gateway on the process model to send flow to one of two User Input tasks.  Make your forms to show the error or success, plus any data you got from Write to Datastore you want to show.  That and a big friendly submit button the user can use to close the form when they've looked it over enough.

    The onSuccess message probably just closes the process when they submit that form.  You are free to do whatever you want to handle the error when they submit that form, or just end the process too.  Another helpful thing is a timer exception on the confirmation screens, so that it eventually submits on behalf of the user, should they navigate away or do something else like that.

  • 0
    Certified Lead Developer
    in reply to Dave Lewis

    A write to DS node will pause if there is an error. And that is by intention as the process controls integrity of the data in DB.

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    That does make me wonder why there's an onError output sometimes.  Maybe there's errors that don't cause it to crash?

  • 0
    Certified Lead Developer
    in reply to Dave Lewis

    I think the 'OnSuccess' & 'OnError' outputs are available only for the smart service functions & not for the smart service nodes.

  • Exactly. And this is also why we can only call a single smart service function in a saveInto.

  • 0
    Certified Lead Developer
    in reply to Dave Lewis

    OK then scratch a lot of what I said.

    You can either have a confirmation screen and utilize the savedValues output to show info to the users, or if it does break, the process will be paused by exception.  You can have a parent process that only waits so long before it does something else and terminates killing the stalled process.  That something else can include a "Something went horribly wrong" message to the user.

  • 0
    Certified Senior Developer
    in reply to Dave Lewis

    Actually, i am using the interface only rather than the process model and i want to build the function such as alert box to confirm about the action to the user.

  • 0
    Certified Lead Developer
    in reply to Deepak gupta

    Oh!  You can create any kind of layout you want that shows confirmation or error message, and set it's showWhen property appropriately so you only display it when the database function is called.

  • 0
    Certified Lead Developer
    in reply to Deepak gupta

    Hi ,

    Hope below code helps you to do it

    a!localVariables(
      local!dbWriteSuccessful: 0,
      /* 
      0 - No Updates,
      1 - Successful Update/Creation,
      2 - Error
      */
      
    {
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              {
               
                /* Error Banner */
                a!cardLayout(
                  contents: {
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item: a!richTextDisplayField(
                            labelPosition: "COLLAPSED",
                            value: {
                              a!richTextIcon(
                                icon: "exclamation-circle",
                                color: "NEGATIVE",
                                size: "MEDIUM"
                              )
                            }
                          ),
                          width: "MINIMIZE"
                        ),
                        a!sideBySideItem(
                          /* Replace this rich text with your error message */
                          item: a!richTextDisplayField(
                            labelPosition: "COLLAPSED",
                            value: {
                              a!richTextItem(
                                text: {
                                  "Update Failed"
                                },
                                style: "STRONG"
                              )
                            }
                          )
                        )
                      },
                      alignVertical: "MIDDLE",
                      spacing: "STANDARD"
                    )
                  },
                  style: "ERROR",
                  marginBelow: "STANDARD",
                  accessibilityText: "Error message",
                  showWhen: local!dbWriteSuccessful=2
                ),
                /* Success Banner */
                a!cardLayout(
                  contents: {
                    a!sideBySideLayout(
                      items: {
                        a!sideBySideItem(
                          item: a!richTextDisplayField(
                            labelPosition: "COLLAPSED",
                            value: {
                              a!richTextIcon(
                                icon: "check-circle",
                                color: "POSITIVE",
                                size: "MEDIUM"
                              )
                            }
                          ),
                          width: "MINIMIZE"
                        ),
                        a!sideBySideItem(
                          /* Replace this rich text with your success message */
                          item: a!richTextDisplayField(
                            labelPosition: "COLLAPSED",
                            value: {
                              a!richTextItem(
                                text: {
                                  "DB Write Successfull"
                                },
                                style: {
                                  "STRONG"
                                }
                              )
                            }
                          )
                        )
                      },
                      alignVertical: "MIDDLE",
                      spacing: "STANDARD"
                    )
                  },
                  style: "#e7f4e4",
                  marginBelow: "STANDARD",
                  accessibilityText: "Success message",
                  showWhen: local!dbWriteSuccessful=1
                )
              },
              a!buttonArrayLayout(
                buttons: {
                  a!buttonWidget(
                    label: "Button",
                    style: "PRIMARY",
                    saveInto: {
                      a!writeToDataStoreEntity(
                        dataStoreEntity: <Your Entity>,
                        valueToStore: {<Your Data> },
                        onSuccess: {
                          a!save(local!dbWriteSuccessful, 1)
                        },
                        onError: {
                          a!save(local!dbWriteSuccessful, 2)
                        }
                      )
                    }
                  )
                },
                align: "END"
              )
            }
          )
        }
      )
    })