Announcement

Collapse
No announcement yet.

Request for Assistance in Implementing "Approved By" Field Functionality

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Request for Assistance in Implementing "Approved By" Field Functionality

    Greetings, developers,
    I have implemented a new field called "Status," which includes options for both "Reject" and "Approve." To enhance this functionality, I am looking to introduce another field named "Approved By." This "Approved By" field should function similarly to the "Created By" or "Modified By" fields. While multiple users will possess the authority to either approve or reject, I am specifically interested in capturing and recording the user responsible for approving a transaction.
    My aim is to track and store the user who initiates the change of status to "Approve." Could you please guide me on how to achieve this?



  • #2
    If you enable the Audited option in the settings of this field, any changes to it will be made to the Stream. Does this functionality suit you?

    Click image for larger version

Name:	1.png
Views:	131
Size:	3.1 KB
ID:	96747

    Comment


    • #3
      victor, No i need to Save this in Field.

      Comment


      • #4
        Hey sapyantuk

        You can create a relationship on your entityDefs, you can add the code below to your entity:

        PHP Code:
        {
            
        "fields": {
                
        "approvedBy": {
                    
        "type""link",
                    
        "readOnly"true,
                    
        "view""views/fields/user",
                    
        "fieldManagerParamList": []
                }
            },

            
        "links": {
                
        "approvedBy": {
                    
        "type""belongsTo",
                    
        "entity""User"
                
        }
            }

        Then you can use formula or Hooks to catch the person who changes the status field like below:

        PHP Code:
        if (entity\isAttributeChanged('status') && status == 'Approved') {
            
        entity\setAttribute('approvedById'modifiedById);
            
        entity\setAttribute('approvedByName'modifiedByName);
        }
        ​ 
        Hope this helps.
        Rabii
        Web Dev

        Comment

        Working...
        X