How add field values from one nested array to another nested array

Hi Team,

I need help from you regarding array object values,

Here is sample document,

{
  "_id": "TT3898",
  "ticketActivity": [
    {
      "date": {
        "$date": {
          "$numberLong": "1649694600035"
        }
      },
      "author": "Nana Ama",
      "action": "logTicket",
      "text": "has created the ticket",
      "type": "TT3898"
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1649751161650"
        }
      },
      "author": "vbokai",
      "action": "assignee",
      "text": "has changed the assignee to",
      "type": "vbokai",
      "note": ""
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1649752358178"
        }
      },
      "author": "lokesh",
      "action": "comment",
      "text": "has commented",
      "type": "Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1649752372104"
        }
      },
      "author": "dinesh",
      "action": "status",
      "text": "updated the status to",
      "type": "resolved",
      "note": "Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1649752605548"
        }
      },
      "author": "nagesh",
      "action": "assignee",
      "text": "has sent sms to customer",
      "type": "Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1650130374339"
        }
      },
      "author": "vbokai",
      "action": "status",
      "text": "updated the status to",
      "type": "open",
      "note": ""
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1651755688760"
        }
      },
      "author": "hwahab",
      "action": "assignee",
      "text": "has changed the assignee to",
      "type": "rmolstrevold",
      "note": ""
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1655460430415"
        }
      },
      "author": "rmolstrevold",
      "action": "status",
      "text": "updated the status to",
      "type": "resolved",
      "note": "Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1655460564092"
        }
      },
      "author": "rmolstrevold",
      "action": "assignee",
      "text": "has sent sms to customer",
      "type": "Please be informed that the ECG transaction you made on the 08/02/22 with transaction id  15978305876  was successfully processed . Kindly contact ECG for any assistance on this transaction."
    }
  ]
}

from the above document there are too many objects in ticketActivity …

In every object I need separate fields names AssignedByUser, AssignedToUser and comments.

AssignedByUser will be the “ticketActivity.author” as mentioned in the same object,

AssignedToUser will be the “ticketActivity.author” of the immediate next object .

Note: In the last object assignedToUser will be null.

Comments will be the “ticketActivity.note” with condition where note filed exists in the object concat of “ticketActivity.author”, “:”, “ticketActivity.note” , it shell be added in all the objects as same,

The expected output of aggregate query as below:

{
  "_id": "TT3898",
  "ticketActivity": [
    {
      "date": {
        "$date": {
          "$numberLong": "1649694600035"
        }
      },
      "author": "Nana Ama",
	  "assignedByUser" : "Nana Ama",
	  "assignedToUser" : "vbokai",
      "action": "logTicket",
      "text": "has created the ticket",
      "type": "TT3898"
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1649751161650"
        }
      },
      "author": "vbokai",
	   "assignedByUser" : "vbokai",
	  "assignedToUser" : "lokesh",
      "action": "assignee",
      "text": "has changed the assignee to",
      "type": "vbokai",
      "note": ""
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
	
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1649752358178"
        }
      },
      "author": "lokesh",
	   "assignedByUser" : "lokesh",
	  "assignedToUser" : "dinesh",
      "action": "comment",
      "text": "has commented",
      "type": "Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611."
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
	},
	
    {
      "date": {
        "$date": {
          "$numberLong": "1649752372104"
        }
      },
      "author": "dinesh",
	   "assignedByUser" : "dinesh",
	  "assignedToUser" : "nagesh",
      "action": "status",
      "text": "updated the status to",
      "type": "resolved",
      "note": "Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611."
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
	},
    {
      "date": {
        "$date": {
          "$numberLong": "1649752605548"
        }
      },
      "author": "nagesh",
	   "assignedByUser" : "nagesh",
	  "assignedToUser" : "vbokai",
      "action": "assignee",
      "text": "has sent sms to customer",
      "type": "Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
		"comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
	},
    {
      "date": {
        "$date": {
          "$numberLong": "1650130374339"
        }
      },
      "author": "vbokai",
	   "assignedByUser" : "vbokai",
	  "assignedToUser" : "hwahab",
      "action": "status",
      "text": "updated the status to",
      "type": "open",
      "note": ""
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1651755688760"
        }
      },
      "author": "hwahab",
	   "assignedByUser" : "hwahab",
	  "assignedToUser" : "rmolstrevold",
      "action": "assignee",
      "text": "has changed the assignee to",
      "type": "rmolstrevold",
      "note": ""
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1655460430415"
        }
      },
      "author": "rmolstrevold",
	   "assignedByUser" : "rmolstrevold",
	  "assignedToUser" : "rmolstrevold",
      "action": "status",
      "text": "updated the status to",
      "type": "resolved",
      "note": "Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
    },
    {
      "date": {
        "$date": {
          "$numberLong": "1655460564092"
        }
      },
      "author": "rmolstrevold",
	   "assignedByUser" : "rmolstrevold",
	  "assignedToUser" : "",
      "action": "assignee",
      "text": "has sent sms to customer",
      "type": "Please be informed that the ECG transaction you made on the 08/02/22 with transaction id  15978305876  was successfully processed . Kindly contact ECG for any assistance on this transaction."
	  "comments": "lokesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611. 
					"dinesh:Per instructions, SMS sent to customer to contact ECG for help. The transactions reflected with ECG hence cannot be reversed by MTN. Customer can visit the Branch or call their Call Center on 0302611611".
					"nagesh: Dear Valued Customer, Kindly contact ECG for help on your ECG payment. The payment went to E.C.G. So, cannot be reversed by MTN. You can visit your branch or call their Call Center on 0302611611. Thank you."
					"rmolstrevold:Transaction was successfully processed to ECG. Customer is advice to contact ecg for assistance."
    }
  ]
}

Please help me on this as soon as possible.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.