Summary
Question
Answer
Add the following code into after add trigger that creates the first record that will create a relationship with the existent one
var relation = new SCFile("screlation");
relation.source = record.id; -- where id is the name if the field that stores the record ID
relation.source_filename = "table1"; --- table1 should be replaced by the master table of the record just created
relation.depend = record.relationid; -- where relationid is the name if the field that stores the related ID record
relation.depend_filename = "table2"; --- table1 should be replaced by the master table of the related record to associate
relation.type = "Related";
relation.doInsert();