Thank you very much Lijun.
Actually I did exactly what you mentioned here, and I already knew refElemId can't be any arbitrary positive number, it must be the Element ID from the attachement, and I've writen the ref info successfully into the Master…