# Using Custom Code to copy specific meeting type data

**URL:** <https://community.hubspot.com/t/using-custom-code-to-copy-specific-meeting-type-data/86376>\
**Category:** Data Hub\
**Tags:** workflows\
**Created:** [July 28, 2023, 3:54pm UTC](https://community.hubspot.com/t/using-custom-code-to-copy-specific-meeting-type-data/86376 "2023-07-28T15:54:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JBortle](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@JBortle](https://community.hubspot.com/u/JBortle)\
**Post date:** [July 28, 2023, 3:54pm UTC](https://community.hubspot.com/t/using-custom-code-to-copy-specific-meeting-type-data/86376/1 "2023-07-28T15:54:35Z")

</div>

Hello everyone!

Quick question for anyone who has used custom code inside of workflows. I am currently trying to copy the date of a specific meeting type to a field on the deal level. I’ve tried a workflow, but it doesn’t want to pull the data from this specific type of meeting, but all meetings.

Does anyone have experience with this? Or anyone know how to accomplish this?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![PamCotton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pamcotton/32/47916_2.png) [@PamCotton](https://community.hubspot.com/u/PamCotton)\
**Post date:** [July 28, 2023, 9:34pm UTC](https://community.hubspot.com/t/using-custom-code-to-copy-specific-meeting-type-data/86376/2 "2023-07-28T21:34:11Z")

</div>

Hello @JBortle Happy Friday! Thank you for reaching out to our Community!

I want to invite our top experts to share their thoughts @HFisher7 @mangelet @johnelmer any suggestions for @JBortle?

Thank you,

Pam

---

<div class="post-metadata">

**Author:** ![HFisher7](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hfisher7/32/101931_2.png) [@HFisher7](https://community.hubspot.com/u/HFisher7)\
**Post date:** [July 30, 2023, 8:57am UTC](https://community.hubspot.com/t/using-custom-code-to-copy-specific-meeting-type-data/86376/3 "2023-07-30T08:57:01Z")

</div>

Hey @JBortle - Theoretically, you should be able to utilise the value in the ‘Meeting type’ within your code to only stamp over the date value if the Meeting type is equal to that which you want it to be.  
Alternatively, this is possible utilising Zapier:

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/c/cc04cb49ada53a7bdd439dd677965d90a7bf14ee.png)

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 3, 2023, 6:59am UTC](https://community.hubspot.com/t/using-custom-code-to-copy-specific-meeting-type-data/86376/4 "2023-08-03T06:59:51Z")

</div>

Hi @JBortle ,

I have created a small workflow with a coded action that retrieves specific data from the most recent meeting and copies that data to contact properties, so quite similar to what you want to achieve;

 ![Schermafbeelding 2023-08-03 om 08.54.10.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/2/42463676bf98e4cba22dca9de59a3ba71224e85c.jpeg)

Here is the code;

```lia-code-sample
const axios = require('axios');

exports.main = async (event, callback) => {
 const lastMeetingDate = event.inputFields['engagements_last_meeting_booked'];
 const contactID = event.inputFields['hs_object_id'];
 let location = event.inputFields['afspraak_locatie__single_line_tekst_'];
 let type = event.inputFields['type_afspraak'];
 let date = event.inputFields['afspraak_datum'];
 let time = event.inputFields['afspraak_tijd'];

 const associations = await axios({
 method: 'get',
 url: `https://api.hubapi.com/crm/v3/objects/contacts/${contactID}/associations/meetings/?limit=10`,
 headers: {
 'Content-Type': 'application/json',
 'Authorization': `Bearer ${process.env.CONTACT_TOKEN}`
 }
 }).then((response) => {
	if (response.data.results.length > 0) {
 console.log(`Found ${response.data.results.length} meetings for contact ${contactID}`)
 return response.data.results.map((result) => { 
 	return {
 id: result.id
 }
 })
 } else {
 return false
 }
 }).catch((error) => {
 console.log(error)
 })

 if (associations) {
 const data = {
 properties: [
 "hs_timestamp",
 "hs_meeting_start_time",
 "hs_meeting_location",
 	"hs_activity_type"
 ],
 inputs: associations
 }

 const latestMeeting = await axios({
 method: 'post',
 url: `https://api.hubapi.com/crm/v3/objects/meetings/batch/read?archived=false`,
 headers: {
 'Content-Type': 'application/json',
 'Authorization': `Bearer ${process.env.CONTACT_TOKEN}`
 },
 data: JSON.stringify(data)
 }).then((response) => {
 if (response.data.results) { 
 // Get the latest meeting
 	return response.data.results.reduce((a, b) => new Date(a.createdAt) > new Date(b.createdAt) ? a : b)
 }
 }).catch((error) => {
 console.log(error.response.data)
 })

 if (latestMeeting) {
 location = latestMeeting.properties.hs_meeting_location;
 date = new Date(latestMeeting.properties.hs_meeting_start_time)
 time = latestMeeting.properties.hs_meeting_start_time ? `${String((date.getHours() + 2)).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}` : '';

 await axios({
 method: 'patch',
 url: `https://api.hubapi.com/crm/v3/objects/contacts/${contactID}`,
 headers: {
 'Content-Type': 'application/json',
 'Authorization': `Bearer ${process.env.CONTACT_TOKEN}`
 },
 data: JSON.stringify({
 properties: {
 afspraak_datum: new Date(date.getFullYear(), date.getMonth(), date.getDate())
 }
 })
 }).then((response) => {
 console.log(response.data)
 }).catch((error) => {
 console.log(error.data)
 })
 }
 }

 callback({
 outputFields: {
 location: location,
 date: date,
 time: time,
 type: type,
 }
 });
}

```

So when retrieving the associated meetings, I only return the most recent one. You might have to do something similar based on what type of meeting you want to return.  
I hope this helps!
