Displaying a richTestField for limit set of time

Hello All,

I have requirement where I need to display a message if my integration call returns false, and that message should disappear after sometime or user refresh the form. To display the message i am using rule input Boolean variable. If user submit the task and in process user receive false from integration call user  gets reverted back to task with the value and we are displaying the message. I tried using of refresh variable but not able to find the exact solution. Please suggest.

Thanks!!!

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Why not have the rich text field showing your error message have a small icon or link that the user can click to "dismiss" the error message?

  • User does not want any clicks, should be auto refresh or within some interval.

  • 0
    Certified Lead Developer
    in reply to Ravi Roshan

    You could also handle this with refresh timer, but the minimum wait time as decided by Appian will be 1 minute.  I'd still suggest giving them a "dismiss" link if they feel like getting rid of it before then, but of course that's up to you.

  • Thanks Mike, But I tried with the refresh variable no luck with that. I tried using some local variable as well but that also not helping me in this scenario. Just to clear i have ri boolean flag based on which I am displaying the message. 

  • 0
    Certified Lead Developer
    in reply to Ravi Roshan
    But I tried with the refresh variable no luck with that.

    Can you share your relevant code, so we can help troubleshoot?  Please use the Insert --> Insert Code feature found in your text entry box, to ensure code is well formatted and friendly to look at here.

  • a!localVariables(
      local!isInitiationValid: true,
      local!result,
      a!formLayout(
        label: "Form",
        contents: {
          a!sectionLayout(
            contents: {}
          ),
          a!sectionLayout(
            label: "Section",
            contents: {
              a!textField(
                label: "ri!isInitiationValid",
                value: ri!isInitiationValid,
                readOnly: true
              ),
              a!textField(
                label: "local!isInitiationValid",
                value: local!isInitiationValid,
                readOnly: true
              ),
              if(
                ri!isInitiationValid,
                {},
                rule!TestMessage(
                  isInitiationValid: ri!isInitiationValid
                )
              )
            }
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Complete",
              style: "PRIMARY",
              saveInto: {
                rule!TestIntegration(
                  customId: "abcd",
                  ProjectId: "123",
                  onSuccess: {
                    a!save(
                      local!result,
                      a!fromJson(
                        fv!result.body
                      )
                    )
                  }
                ),
                a!save(
                  ri!isInitiationValid,
                  index(
                    local!result,
                    "IsInitiationValid",
                    ""
                  )
                ),
                a!save(
                  local!isInitiationValid,
                  ri!isInitiationValid
                )
              },
              submit: true
            )
          },
          secondaryButtons: {}
        )
      )
    )

    hello Mike,

    In process model, if the ri!isInitiationValid is false, i am routing the path back to user input task and displaying the message. here comes the challenge that, the message should go once user refresh the page. 

  • 0
    Certified Lead Developer

    Couldn't you do something with a!localVariables with the option to refresh every thirty seconds?  You should be able to have it load the error when the form does (I'm assuming that you'd know whether it failed or not when the form loads), and then thirty seconds later update the display variable to false.  You'd be setting a boolean flag to false every 30 seconds, but I don't see that really draining the performance of your form too much.

    If you don't know whether the integration failed on startup, I don't know what to tell you.  It seems you might have to write to the database, and query the database again every thirty seconds.  When the form gets it's AC! inputs and plugs them into the ri!'s of the form, that's the last you ever see of the process variables it seems.  I have yet to find a way to have the form go into it's parent process and pull what a PV is now.  That's what I was hoping, but still no.  To my knowledge Appian has yet to build a way for a process model to send a message to a form that's currently open, except via database.

  • +1
    Certified Lead Developer
    in reply to Ravi Roshan

    You should still be able to utilize a!refreshVariable() to conditionally show some extra information (like a section, or really anything else you want) for a particular time span after the form is initially loaded.  After you get that working, you could still bake in a user-clickable "dismiss" option or various other possibilities, as long as you figure out the rather easy logic involved.

    This example has a section that should stay for around 30 seconds:

    a!localVariables(
      local!isInitiationValid: true,
      local!result,
    
      local!refreshTime: a!refreshVariable(
        value: now(),
        refreshInterval: 0.5
      ),
      local!pageLoadTime: a!refreshVariable(
        value: local!refreshTime,
        refreshOnReferencedVarChange: false()
      ),
      
      a!formLayout(
        label: "Form",
        contents: {
          a!sectionLayout(
            label: "Error Message",
            showWhen: local!refreshTime = local!pageLoadTime,
            contents: {
              /* Error Message Contents (will go away after first 30-second refresh) */
            }
          ),
          a!sectionLayout(
            label: "Section",
            contents: {
              a!textField(
                label: "ri!isInitiationValid",
                value: ri!isInitiationValid,
                readOnly: true
              ),
              a!textField(
                label: "local!isInitiationValid",
                value: local!isInitiationValid,
                readOnly: true
              ),
              if(
                ri!isInitiationValid,
                {},
                rule!TestMessage(
                  isInitiationValid: ri!isInitiationValid
                )
              )
            }
          )
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Complete",
              style: "PRIMARY",
              /*saveInto: {*/
                /*rule!TestIntegration(*/
                  /*customId: "abcd",*/
                  /*ProjectId: "123",*/
                  /*onSuccess: {*/
                    /*a!save(*/
                      /*local!result,*/
                      /*a!fromJson(*/
                        /*fv!result.body*/
                      /*)*/
                    /*)*/
                  /*}*/
                /*),*/
                /*a!save(*/
                  /*ri!isInitiationValid,*/
                  /*index(*/
                    /*local!result,*/
                    /*"IsInitiationValid",*/
                    /*""*/
                  /*)*/
                /*),*/
                /*a!save(*/
                  /*local!isInitiationValid,*/
                  /*ri!isInitiationValid*/
                /*)*/
              /*},*/
              submit: true
            )
          }
        )
      )
    )

  • Thanks Mike. This worked. 

    Just small change i made to make it as per my requirement because as per your code the message was reappearing whenever the form was reloading. So I made pageLoadTime as rule input and storing the value while getting the integration call and getting the difference to show the message.