Help

Duplicating a record and adding 24 hours to the Date field (based on record id passed from automatio

Topic Labels: Scripting
Solved
Jump to Solution
3381 7
cancel
Showing results for 
Search instead for 
Did you mean: 
Kosta_Kondraten
7 - App Architect
7 - App Architect

I am attempting to setup a workflow for a Callback system for my Sales calls. My plan was that when a record in my Callback List View inside my Touchpoints table was updated to have the Call Result column be set to Voicemail select - that it would automatically duplicate itself and the duplicate would have 24 hours added to the Start Date/Time column - so that I would automatically see that record the next day in the Today's Calls View in the Touchpoints table.

My challenge is that I am unable to find a way to duplicate a record based on the ID - so far I have created an automation and passed the record id as 'rec_id' variable to be accessed through the input.config() variable in the script that is set to run when my Trigger matches as per this screenshot:
https://share.getcloudapp.com/p9uL4eKP

After reviewing some other examples of scripts I have created a script which you can see in the Gist below:
https://gist.github.com/HeadStudios/98c8837c02a0fb8540e3e36333281945

While this script does not work - I feel it at the very least outlines what I am attempting to achieve quite well. Pardon my ignorance as JS is not my first programming language.

While my script doesn't report any errors - I am unable to detect any new rows created.

Any input on my challenge would be much appreciated.

P.S. As an aside the script takes 12 seconds to run - so any input on speeding it up would be much appreciated also. Thanks!

 

1 Solution

Accepted Solutions
catz
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Kosta, 

For creating a linked record, the object would look like this:

 

let newStuff = await table.createRecordsAsync({
  'Notes': "Ready to make a deal? You have 24 hours bond" + name,
  'Start Date/Time': next,
  'Contact': {id: name}
});

 

Assuming the primary key of the "Contacts" table is the name, this would work. If not, then you would pass in the ID of the Contact record you are trying to link. Hope this helps, let me know! 

See Solution in Thread

7 Replies 7
catz
5 - Automation Enthusiast
5 - Automation Enthusiast

You can add additional input values to input.config() to represent the key pieces of data you would like copied over, from the left panel. You don't need to map that recordId as that gets automatically generated when a new record is created.


As for solving the date issue, I would add another column called something like "Next Contact Date" for example, and use the existing date column in a DATEADD formula to add one day.

ex: DATEADD({Last Contacted},1,'days')

Hope this helps 🙂

Thank you, this is an approach that I had not considered but actually makes a lot of sense. I will mark this as Solved for now as it is an approach using techniques which I am familiar with. Thank you.

Hi Kosta, did my solution work for your project? anything else I can help with?

otherwise, just a friendly reminder to please mark this as solved 🙂

Hi Catz,

Thank you for the follow up - am attempting this now and once I have a proof of concept I will mark as resolved.

Thank you for all your help so far - your advice of adding a formula with dateadd function was very astute and I look forward to implementing it in my solution and marking it as the correct answer.

Best,

Kosta_Kondraten
7 - App Architect
7 - App Architect

I can confirm catz solution works perfectly - my only challenge is being able to populate a Link field. I had assumed since I can just paste the name of the Contact into the Contact column and have it become automatically linked to the Contact record I could do the same when doing the createRecordAsync command - and pass the contact name - however this has not worked for me and I see a strange error as below:

https://share.getcloudapp.com/kpuOGbpw

Any input on being able to create a new record and populating the Link field using the Contact Name passed would be much appreciated.

Thank you!

 

catz
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Kosta, 

For creating a linked record, the object would look like this:

 

let newStuff = await table.createRecordsAsync({
  'Notes': "Ready to make a deal? You have 24 hours bond" + name,
  'Start Date/Time': next,
  'Contact': {id: name}
});

 

Assuming the primary key of the "Contacts" table is the name, this would work. If not, then you would pass in the ID of the Contact record you are trying to link. Hope this helps, let me know! 

Thank you so much Catz!