Moving record across database via applescript

I was trying to use applescript to convert markdown into PDF, and file the PDF to another database as archive.

It returns ‘can’t get content id xxxxx of database id 1’ or ‘Can’t make (variable of path) of database id 14 into type reference.’

Despite the error, the script successfully moved the PDF to the designated path.

But because it returns error the action that comes behind won’t be execute.

The following is my code.

			set CurrentDate to (current date)
			set CWDay to weekday of CurrentDate
			set CDay to texts -1 thru -2 of ("0" & day of CurrentDate)
			set CYear to year of CurrentDate
			set CMonthName to month of CurrentDate as string
			set CMonthNo to texts -1 thru -2 of ("0" & (month of CurrentDate as number))

			set newPDF to (convert record theRecord to PDF document)
			--set theDBdes to get database with uuid "uuid"
			set theDBdes to database named "Web articles"

			set CWebPath to "/" & "web" & CYear & "/" & CMonthNo & " " & CMonthName
			if exists record at CWebPath in theDBdes then
			else
				create location CWebPath in theDBdes
			end if

			set CWebGroup to get record at CWebPath in theDBdes
			move record newPDF to CWebGroup
			--set newPDF's unread to false

The variable theDBdes is the destination database where I want to move the PDF to. This applescript belongs to part of a smart rule.

It may be just very basic syntax problem. But I am not from programming background, and self-learning applescript, tried google but can’t figure it out. Thank you so much.

I don’t see the variable theRecord defined anywhere.

I use this in a smart rule, so theRecord is predefined as the record(s) which matches the criteria.

Good on you for learning some scripting!

I’m curious if this is your expected output…

And yes, that PDF was made from a Markdown document.

PS: Please post the whole script from the popup editor. Thanks!

2 Likes

Thanks for the reply. I am trying it from Script Debugger and it works now… I will try again and see if I can isolate the issue, and get back later.