5 Replies Latest reply on Nov 20, 2014 10:57 AM by dmshimself

    Prevent Add to Cart firing when Errors detected on Window

    AndrewWard Apprentice

      Hope someone can help as I have a show stopper in using the Self Service Portal Service Catalogue to run our business service requests.

       

      It is an essential requirement that field validation is done to ensure that only clean data is accepted into the process. So far no matter what I have tried I have not found any way to prevent invalid data being accepted into the process - believe me I have tried and tried and feel like I am running round and round in circles going absolutely nowhere. I have a programming and long IT background and can't for the life of me believe that this basic checking of data input on a form cannot be performed so I can only conclude I am missing something.

       

      This shows the closest I have come so would welcome any comments that may help me to provide a solution or a new avenue to investigate.

       

      Using this window for a CI in the Self Service Catalogue

      ChangePaySlipDest.png

      On this form this is required for:

      • National Insurance number to follow allowable pattern matches in format 2 chars/6 digits/1 char e.g. AB123456A
      • Payroll No to be 6 or 7 digits with an optional trailing hyphen and 1 or 2 digits e.g. 123456, 123456-1, 1234567-12

       

      The Request Management\Request\_LGSSDataValidationMsg business object is displayed in the top errors field created using this Window Calculation to inform the user what has failed validation and why.

      Name: _LGSSDataValidationMsg

      DataType: String

      Max Length: -1

      IsMandatory: False

      SubdataType: None

      Window Calculatioin:

      import System

      static def GetAttributeValue(Request):

      Value = ""

      if Request._NINumber != null:

        if not Request._NINumber.ToUpper() =~ /^[ABCEGHJ-PRSTW-Z][ABCEGHJ-NPRSTW-Z]\d{6}[A-D]$/:

         Value = "NI no. " + Request._NINumber + " is invalid format must be XX999999X\n  prefix cannot contain D, F, I, Q, U or V\n  2nd character cannot be O\n  suffix must be A,B,C,D\n"

        else:

         Value = "NI no. " + Request._NINumber + "is valid\n"

      else:

        Value = "NI no. must be entered\n"

      if Request._PayrollAssignmentNumber != null:

        if not Request._PayrollAssignmentNumber =~ /^\d{6,7}(-d{1,2})?$/:

         Value = Value + "Payroll no. " + Request._PayrollAssignmentNumber + " is invalid\n  must be 6 or 7 digits with optional trailing hyphen and 1 or 2 digits\n"

        else:

         Value = Value + Request._PayrollAssignmentNumber + " is valid format\n"

      else:

        Value = Value + "Payroll no. must be entered\n"

      return Value

       

      The "I Confirm" field is used as the trigger for the validation calculation which, because it is mandatory, until it has been set (and all other mandatory fields) the "Add to Cart" or "Add to Cart and Checkout" will not progress the form instead it returns the window with the system detected field errors at the top. This screen shot shows the system error field being filled when the "I Confirm" was changed to Yes -  firing the calc and then clearing the I Confirm before clicking "Add To Cart".

      systemdetectederrors.png

      The main problem is once all mandatory fields on the form have been completed then selecting "Add to Cart" or "Add to Cart and Checkout" will run ok and the record will be written and the process instigated with invalid data.

      It is therefore necessary to trigger the system detected errors to force the window to remain active. I thought to achieve this by adding an additional hidden mandatory calculated field (currently being displayed as Validate) onto the window and using the same logic as the error message calculation return a null value if an error was detected.

      import System

      static def GetAttributeValue(Request):

      Value = ""

      ErrFlag = false

      if Request._NINumber != null:

        if not Request._NINumber.ToUpper() =~ /^[ABCEGHJ-PRSTW-Z][ABCEGHJ-NPRSTW-Z]\d{6}[A-D]$/:

         ErrFlag = true

      else:

        ErrFlag = true

      if Request._PayrollAssignmentNumber != null:

        if not Request._PayrollAssignmentNumber =~ /^\d{6,7}(-d{1,2})?$/:

         ErrFlag = true

      else:

        ErrFlag = true

      if ErrFlag = true:

        return null

      else:

        return true

       


      Unfortunately because this is a calculated field the window ignores it's mandatory status and so does not trigger the mandatory fields error on the window and so continues with invalid data.

       

      I also attempted to set the I Confirm field to a calculation using the data validation field as the trigger but this is a recursive trigger and is prevented by the design console i.e. a target field cannot be triggered by an object it is a trigger for.

       

      The other area I considered was to look at the process that the form is linked to. The initial steps are shown below.

       

      initial steps.png

       

      As far as I can figure though as soon as you hit "Add to Cart" or "Add to Cart and Checkout" and they run okay the window is deactivated in the self service portal and control is passed to the process. As the first step is to open a request then any invalid data will already be associated with the record which is what I am trying to prevent.

       

      Hope I've made everything clear?       

        • 1. Re: Prevent Add to Cart firing when Errors detected on Window
          ITSMMVPGroup

          The traditional LD approach is to detect the error in the process via a calculation and then display a form inviting correction and loop round.  Once it is all valid you could set a flag saying 'validated' or some such.

           

          However, one thought would be to use a dynamic window calculation to expose a mandatory read only string attribute in the case of an error.  That way they will get an error before saving as they will not be able to fill in that attribute.  So very close to your original idea.

           

          If that isn't going to work for you, talk to your LD account manager.  They have access to an SI team that may be able to help.

          • 2. Re: Prevent Add to Cart firing when Errors detected on Window
            AndrewWard Apprentice

            Thanks for the response

             

            Thought I'd give the introduction of a new read only string attribute onto the form a go. Unfortunately as soon as you make it read only it is no longer picked up as a missing mandatory field and therefore does not prevent the add to cart.

            Okay I thought what about if I simply remove the protection and hide this string attribute behind another window control that way it would fail the mandatory check preventing the add to cart. Unfortunately the translation engine for the web form rearranges the window so that this attribute is no longer underneath the other control.

             

            The other complication that needs to be addressed is the fact that even if we manage to get the add to cart deferred by a mandatory field missing error, or other blocking condition, it would also be necessary to clear the "I Confirm" trigger field to force the user to reselect it again once corrections have been made otherwise the error check window calculations will not be run again to recreate the error message string or empty the error string and remove the blocking condition if no validation errors were detected. 

            • 3. Re: Prevent Add to Cart firing when Errors detected on Window
              ITSMMVPGroup

              If it is mandatory in the circumstances required, that would be a bug and you could draw this to the attention of your support team. 

               

              But I'm not sure you can crack this general principle without going along the route LDSD normally uses: allow the data to be saved, check it and then pop up forms to correct it.

               

              I'd strongly recommend you contact your account manager and set up a conversation with an LD specialist to avoid, or at least mitigate, further frustrations on your part.

              • 4. Re: Prevent Add to Cart firing when Errors detected on Window
                AndrewWard Apprentice

                I have raised a red flag to the project managers recommending that this is escalated back to the account manager.

                 

                This is the second time you mentioned the general principle of saving, checking then correcting on a pop-up window.

                 

                Am I correct in my assumption that in this instance this is not possible because the initial form fill in is being done in the self service portal which does not support such dialogue?

                • 5. Re: Prevent Add to Cart firing when Errors detected on Window
                  ITSMMVPGroup

                  Self service for sure supports regular process actions.  So I'd be writing this process along the following lines ...  The form is presented in self service and you use what validation tools LD provides and the user saves the form.  Some calculations are then done within the process to do the additional validation you want.  If some corrections need to be done, a suitable action in self service is provided inviting the user to correct the data.  Round and round the loop you go until the data is OK.  You then provide a Submit action (or some such) for the user to say yes this is ready to be processed.  As an FYI this also allows them to collect data in stages before pressing the final go button.  I'd also put a response level in place to remind them they haven't finished submitting.

                   

                  If you or your project managers have had previous discussions with LD about how you wanted to do validation and LD have agreed you'll be able to do it, then I'd certainly be pushing back and asking them to provide whatever is required to do this.  But if some assumptions have been made along the way about how LD works, then you may not make much progress.  Hence my suggestions about doing things a a particular way because I know it works.

                   

                  There may be other ways of course and it's perfectly legitimate to ask LD for advice.  They have some clever people working there as well as an SI team that can provide additional functionality by bespoke development.