Not sure of a way in Arcade, but very doable in python.
I use this on feature class with attachments enabled to update the attachment name to the id of the point (My attachments are all jpegs).
import arcpy
inFeatureClass = r'Database Connections\dbname.sde\dbname.DBO.Points' # feature class with attachments
pointFieldsList = ['GlobalID','ID'] # fields to load into cursor
inTable = r'Database Connections\dbname.sde\dbname.DBO.Points__ATTACH' # attachment table for feature class
tableFieldsList = ['REL_GLOBALID', 'DATA', 'ATT_NAME', 'ATTACHMENTID'] # field list in attachment table
global_dict = {}
with arcpy.da.SearchCursor(inFeatureClass, pointFieldsList) as point_cursor: # cursor to make dict of globalID's
for row in point_cursor:
if row[1]:
row1 = row[1] # I'm using "ID" as my name field, but is
else: # not always populated. if Null, substitute "NA"
row1 = "NA"
global_dict[row[0]] = row1 # add to dict with globallID as key, name as value
with arcpy.da.UpdateCursor(inTable, tableFieldsList) as cursor:
for row in cursor:
if row[0] in global_dict:
row[2] = global_dict[row[0]] + '.jpg'
cursor.updateRow(row)
R_