Effective Date of Action From A User Action Node

 7 Replies
 2 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
tommyg-006
Basic Member
Posts: 11
Basic Member

    Hello,

     

    I am working on a flow in IPA for Leave of Absence Processing.  In the flow there is a User Action Node where the end user choose one of the following actions:

     

    Employee Returned from Leave

    Employee Failed to Return (Terminate)

    Extend Employee Leave

    I need a way to get the effective date of the action, but this may not be the same date as when the User Action was completed.  Lawson recommended having the end-user put in the date as a message on the action, which I have formatted in MM/DD/YYYY format.  I would like to through an assign node change the format to YYYYMMDD so it can be used in either LP51 or PA52.  However, the date is coming out as string and I have not had any luck either converting it to a date or reformatting to the needed format. 

    Any suggestions? 

    Todd Mitchell
    Veteran Member
    Posts: 87
    Veteran Member

      I have used javascript to create a new variable and define it using the substring command.  

       

      vEffectiveDate                 = substring(vArr[2],6,10) + substring(vArr[2],0,2) +  substring(vArr[2],3,5) ;

       

      Note:  I didn't take the time to format this for your needs, only presenting it as an example.

       

      Dave Curtis
      Veteran Member
      Posts: 136
      Veteran Member

        Same as Todd, I would use javascript.  I have an IPA process that I do that same thing.  They add the date to a message and it pulls the message.

        Then, using a substring function it pulls the date into a few different formats

         

        The users are instructed to enter the date in format MM/DD/YYYY

         

        substring(qMsgDtl_Message,6,10) + substring(qMsgDtl_Message,0,2) + substring(qMsgDtl_Message,3,5) 

         

        You may already have this in place but I will give one warning - the users will mess up with the date.  They will enter M/D/YY and other format.  Since it is free text they will enter just about anything... So I have format checking in place and if the format is incorrect it sends the user an email and loops the process back into their inbox and in the email it tells them the format is incorrect and clarifies the format needed.  

        Users get mad and send emails saying "I keep entering the same thing and it keeps telling me it is wrong - it will not take the date I am entering" BUT it saves PA52 errors later in the process and the users get it eventually.

         

         

         

         

        tommyg-006
        Basic Member
        Posts: 11
        Basic Member
          Thanks Todd and Dave for the suggestion! I was looking online for hours for a solution like that. I put that logic into my flow, but now I am getting an output like this:

          Activity started: Assign2980 (Run Id: 25)
          ReturnDateVar = <_messages>


          Evaluating JavaScript expression ReturnDateFinal = ReturnDateVar.substring(6,10); to value ages
          Variables in Process:
          ReturnDateVar = <_messages>



          Is the flow supposed to return messages with that format? If so I believe I would have to count the spaces until I get to the actual date, correct?
          tommyg-006
          Basic Member
          Posts: 11
          Basic Member
            Dave,

            Do you use the "moment" javascript function to validate the format of the date?
            Dave Curtis
            Veteran Member
            Posts: 136
            Veteran Member

              I have to use a Landmark transaction to pull the message.

              The transaction pulls the message using the following transaction string

               

              _dataArea="<!--appProdline-->" & _module="pfi" & _objectName="PfiMessage" & _actionName="Find" & _actionOperator="NONE" & _actionType="MultipleRecordQuery" & _runAsUser="" & _authenticatedUser="" & _pageSize="30" & _relationName="" & _setName="SymbolicKey" & _asOfDate="" & _effectiveDate="" & PfiWorkunit="<!--WorkUnit-->" & PfiMessage & Message & PfiWorkunit

               

              Following the transaction node I have an assign node that "collects" the message 

               NodeName_Message

              My Landmark transaction node name is qMsgDtl

              So the Variable Value I have to pull the date and format it is

              substring(qMsgDtl_Message,6,10) + substring(qMsgDtl_Message,0,2) + substring(qMsgDtl_Message,3,5)

               

               

               

              Dave Curtis
              Veteran Member
              Posts: 136
              Veteran Member

                To validate the date, I use an expression using pattern test

                javascript below;

                 

                var dte = qMsgDtl_Message;
                var pat =  /^[0-9]{2}\/?[0-9]{2}\/?[0-9]{4}$/;
                var at = pat.test(dte);

                if(at === true)
                 {intRej = 0;
                 }
                else  {intRej = 1;
                }

                 

                 

                This tests the output of the message variable and if it matches MM/DD/YYYY the output is 0 otherwise the output is 1.  I then use a Branch node and if the output is 1 it loops back around and sends an email and places the action back in the users inbox.

                tommyg-006
                Basic Member
                Posts: 11
                Basic Member
                  Thank you Dave and Todd for the assist! I have that piece of the flow up and running, and it is doing exactly what I wanted.