Script:generate a markdown file in the selected group and inherits part of the metadata of it

Help everyone, I want to generate a markdown file in the selected group in the database where the “exclude group from tags” option is unchecked, Let this markdown file inherits part of the metadata of the group. I tried to write a script, like this:

tell application id "DNtp"
		set theRecords to selection of think window 1
		if theRecords = {} then error "Nothing selected."
		repeat with thisRecord in theRecords
			set thisName to my recordName(name of thisRecord, filename of thisRecord)
			set thisChild to children of thisRecord
			set thisIndex to create record with {name:thisName, type:markdown} in thisChild
			set modification date of thisIndex to modification date of thisRecord
			set creation date of thisIndex to creation date of thisRecord
			set tags of thisIndex to tags of thisRecord
				set thumbnail of thisIndex to thumbnail of thisRecord
			end try
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

But the markdown file is not created in the group. I think it’s because I didn’t add a group tag to the newly generated markdown file, but I don’t know how to modify this script~
The result I want to achieve is something like this

Thank you all!

According to your description the group is selected, therefore you should create create the new file in the selected group (in thisRecord instead of in thisChild). Then the new file should automatically inherit the tag and setting it isn’t necessary.