when to use document id field over reference field?

prasanna11
Mega Guru

> What are major difference between these fields.?

> Are there any scenarios where we can prefer document id over reference field?

> What should i consider if i decide to change the datatype of a field?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Prasanna,



> What are major difference between these fields.?



A reference field uses a related table field to point to a specific record in the prescribed table. E.g. caller is a reference to sys_user.


A document_id field can point to any record on any table. It includes the table as well as the record reference (e.g. Incdient: INC0010013)



> Are there any scenarios where we can prefer document id over reference field?



I generally don't use document_ids in my apps as I don't want to give the user the ability to point to any record on any table. I like to keep control on what is being used so I know what fields I have access to on the target record.



Document_ids are useful for things such as logging where you may not know the table the record points to.



> What should i consider if i decide to change the datatype of a field?



Be aware that changing a data type on a field can lose all data in that field (the column is effectively blanked out.) Always backup your entire table and test first!


View solution in original post

8 REPLIES 8

Chuck Tomasi
Tera Patron

Hi Prasanna,



> What are major difference between these fields.?



A reference field uses a related table field to point to a specific record in the prescribed table. E.g. caller is a reference to sys_user.


A document_id field can point to any record on any table. It includes the table as well as the record reference (e.g. Incdient: INC0010013)



> Are there any scenarios where we can prefer document id over reference field?



I generally don't use document_ids in my apps as I don't want to give the user the ability to point to any record on any table. I like to keep control on what is being used so I know what fields I have access to on the target record.



Document_ids are useful for things such as logging where you may not know the table the record points to.



> What should i consider if i decide to change the datatype of a field?



Be aware that changing a data type on a field can lose all data in that field (the column is effectively blanked out.) Always backup your entire table and test first!


Hi Chuck,

 

Do you see any threat about using a reference field that refers directly to task (core) table ?

Hi Goulart,

If you need to point to the task table to reference any task record (e.g. problem, incident, pm_task, sc_req_item, sc_task, etc) then that's fine. Just make sure it's what you need to fulfill your requirement(s).

It might help to know a little bit more about what your requirement is and what you are trying to accomplish.

Correct me if I'm wrong, but you can't "dot-walk" through a document_id field. For that you will need a reference field to make it work. That would be a big thing and you need to think this through IF you choose to use a document_id field.

If you look at sysapproval_approver, they actually solved this with two fields which is kind of Icky... the "Approving" is the document ID and put is all the correct info. But then they have "approving For" which is a reference field for task table. This works almost the whole time, besides when it e.g. comes to knowledge articles, since that table isn't extended from task.

 

//Göran
Feel free to connect with me: