Sales

Get Involved. Join the Conversation.

Topic

    Mohammed Rafi
    Get object workflow approver name and timestamp
    Topic posted December 20, 2018 by Mohammed RafiBlack Diamond: 60,000+ Points 
    211 Views, 17 Comments
    Title:
    Get object workflow approver name and timestamp
    Content:

    Hi,

     

    I have object workflow using parallel approval in which if anyone of the approver in the group approves the workflow is completed with APPROVED status. Now I would like to know who has approved among the list of approvers and the timestamp and these detailed need to be stored in custom fields such as Approved By, Approved Time.

     

    Kindly suggest the ways to achieve.

     

    Regards,

    Mohammed Rafi

    Comment

     

    • Usha Ramesh

      Dear Mohammed,

      Approver who would be approving the transaction would be the logged-in user I suppose.

      We can use the following groovy to get the logged in User

      def loggedinuserpartyId = adf.util.getUserPartyId();

      And then set this variable value to any field as required.

      Any trigger could be used like "Before Update trigger"

      Please do let me know your thoughts

      Regards

      Usha Ramesh

       

      • Mohammed Rafi

        Dear Usha,

        Is this when approver goes to application and approves using notifications receieved under bell icon ?

        There is another situation as approvers receives email notifications which are having actionable links as Approve or Reject if this is the case and if they approve without going to application how to handle this situation as well

        Please provide your inputs

        Thank you

        • Usha Ramesh

          Dear Mohammed,

          When the approver receive the bell notification, he would be navigated to the Transaction when he clicks the link and hence the above solution would work.

          Not worked on email approvals as of now, because i was still thinking that it will come in the future releases.

          Regards

          Usha Ramesh

          • Mohammed Rafi

            Dear Usha,

            How to capture the approval time is there way to do this

            Thanks

             

             

            • Usha Ramesh

              Dear Mohammed,

              When you are going to create the Custom Field of type date, it would store both Date and Time.

              def Approval_Date = today()

              The above can be used to get the current, system date time. The time that is captured is in UTC, If there are different Time Zones then code has to be written to convert the time to the user's timezone.

              Regards

              Usha Ramesh

    • Reghu

      What's the purpose of getting approval time and approver?  If its mere information purpose on the history of approval.. you can use this table to create a report and behind a button display it

       

      fa_fusion_soainfra.WFTASKHISTORY

      • Mohammed Rafi

        The parallel approval which is built on custom object has 10 members and the users would like to know who actually approved in the group with the timestamp

        approverer name and timestamp need to be displayed in custom field

    • Reghu

      do a small test

       Approve a record and see whether the last updated by is rightly captured as the right person ( in my opinion it should). 

      If yes, the best is to use the logged in user name of the approver when the status changes to approved and take the current time stamp as the approved time.

      • Mohammed Rafi

        Pefect will do the same

         

      • Mohammed Rafi

        Hi Reghu,

        Here there is another challenge the approval is sent to different group and each group has separate approval which is handled in single object workflow.

        Once all the group has approved finally the workflow ends with the status as APPROVED

        I need to also capture who approved from each group.

        Thanks

    • Reghu

      Try and keep us posted on the outcome

    • Reghu

      How will you store each stage in a single field?  I don't think you are explaining me the requirement properly.  

      I feel all you need is just a track record.  Like audit history of the approval sequence. Please discuss with your business completely and if you get yes as the answer to my question.  Then use the table I gave you, to create a report and show them. Its a very clean approach, rather than storing each stage approvers in 'n' no of fields (without having to know the event to capture each approval stage)

      • Mohammed Rafi

        Reghu - Kindly go through my issue again mentioned this is challenging custom solution which no one ever done in Oracle world which has made product team turn towards us.

        In parallel approval more than one group cannot be used which is still an ER with Oracle. Now I made solution to have multiple groups attached to parallel approval workflow.

        when each group say there are three groups TAX, Finance and Legal.  When all groups have approved the status changes to APPROVED.

        Now how to know who has approved in each group with time stamp understanding the requirement still takes time as this is something which has not thought or done by any team in custom cloud development using Apps Composer in CRM

         

    • Reghu

      Simulate it once and observe the records created in the table, you will get clear picture.

    • Ygal Allouche

      Mohammed,

       

      use this SQL to get the Approvers and date separated  by';'.  compositeinstanceid can be found on PR/PO in the field 'approval_instance_id' :

      (SELECT 
      compositeinstanceid,
      RTRIM(EXTRACT(EXML,'//COL2/text()'),' ; ') PREV_RQ_APPROVER,
      RTRIM(EXTRACT(EXML1,'//COL2/text()'),' ; ') UPDATEDDATE
       
      from 
       
      ( select T.compositeinstanceid,
        xmlelement(col, XMLAGG(xmlelement(col2,T.PREV_RQ_APPROVER||' ; ') ORDER BY  T.UPDATEDDATE)) EXML,
        xmlelement(col, XMLAGG(xmlelement(col2,T.UPDATEDDATE||' ; ') ORDER BY  T.UPDATEDDATE)) EXML1
              FROM 
              (Select compositeinstanceid, 
        decode (ORIGINALASSIGNEEUSER,'',decode (SUBSTATE,'DELEGATED', FROMUSERDISPLAYNAME, ASSIGNEESDISPLAYNAME),
                decode (FROMUSER,'workflowsystem',ASSIGNEESDISPLAYNAME, FROMUSERDISPLAYNAME)) PREV_RQ_APPROVER, max(UPDATEDDATE) UPDATEDDATE
           From  fa_fusion_soainfra.WFTASKHISTORY
           Where  assignees is not null   
           and    workflowpattern not in ('AGGREGATION', 'FYI')
           and    componentname ='ReqApproval'
           and    outcome = 'APPROVE'
           and    UPDATEDBY <> 'workflowsystem'
       
       
               and    ENDDATE is null
               group by compositeinstanceid, decode (ORIGINALASSIGNEEUSER,'',
                decode (SUBSTATE,'DELEGATED', FROMUSERDISPLAYNAME, ASSIGNEESDISPLAYNAME),
                decode (FROMUSER,'workflowsystem',ASSIGNEESDISPLAYNAME, FROMUSERDISPLAYNAME)) ) T
              GROUP BY t.compositeinstanceid
      )       
       
      ) PREV_RQ,

      Regards,

      Ygal