Below x++ code used to copy document from table to table or from record to another table
public static void copyDocuRef(smmActivities _smmActivitiesFrom, smmActivities _smmActivitiesTo) { DocuRef smmActivitiesFromDocuRef; while select smmActivitiesFromDocuRef where smmActivitiesFromDocuRef.RefTableId == tableNum(smmActivities) && smmActivitiesFromDocuRef.RefRecId == _smmActivitiesFrom.RecId { DocuRef::createFromDocuRef(smmActivitiesFromDocuRef, _smmActivitiesTo.RecId , tableNum(smmActivities)); } }