Inheritance and relationships between base and child classes in terms of field values

SB87
Tera Expert

I think I already know the answer, but want to be certain. If we take the [task] and [incident] tables for example, I am aware the [incident] table extends the [task] table. When looking at API Explorer, I can see the [incident] inherits the fields from [task] + has its own unique fields. I can also trace the sys_id of the incident and locate it in the [task] table. 

My questions:

  1. If a task and incident have a field in common, for example opened_at, then does this field actually exist in the incident table at all, or is it just observing the field stored in the [task] table?
  2. Will the value of the opened_at field always match between the [incident] and [task] table for the same sys_id, or can it ever be different?

I get why inheritance is used, it avoids field duplication and a base class like [task] serves many different ticket types, but what I am unfamiliar with is the instances of the fields. For example, if I look at the [incident] table using API Explorer I can see that all the fields from [task] + [incident] are listed, but do the [task] fields actually exist in the [incident] table or is this just the illusion given to the end-user where the fields shown are just reflecting what is actually found in the [task] table?

Thanks in advance.

1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage

Hi @SB87 

 

Below might help you :-

 

The field opened_at does not exist as a separate physical field in the [incident] table. It's a reference to the opened_at field in the [task] table. When you access the opened_at field on an incident record, ServiceNow follows the reference to the [task] table and retrieves the value from there.

 

Yes, the value of opened_at will always match between the [incident] and [task] table for the same sys_id. Since the [incident] table references the [task] table's field, any changes to the opened_at field in the [task] table will be reflected in the [incident] table.

View solution in original post

1 REPLY 1

Ravi Gaurav
Giga Sage

Hi @SB87 

 

Below might help you :-

 

The field opened_at does not exist as a separate physical field in the [incident] table. It's a reference to the opened_at field in the [task] table. When you access the opened_at field on an incident record, ServiceNow follows the reference to the [task] table and retrieves the value from there.

 

Yes, the value of opened_at will always match between the [incident] and [task] table for the same sys_id. Since the [incident] table references the [task] table's field, any changes to the opened_at field in the [task] table will be reflected in the [incident] table.