The context can be specified when creating an object.
new(`my.module:MyType`, context: $context)
The context should correspond to the "planned" container of the object and can be used when initializing context-dependent default values.
In the case of persistent objects, the container is then calculated using the composition relationship into which the new object is finally inserted. If you want to use transient objects mixed with persistent objects in a view (e.g. to insert transient grouping nodes), it can be helpful if you can freely determine the container of a transient object (especially for a persistent object, although a transient object can never be inserted into a composition reference of a persistent object). A function that calculates the parent node of an object can then use the generic tContainer() function without having to differentiate between transient and persistent objects.
Test
Execute in the script console, it must return true:
new(`DemoPlain:B`, transient: true, context: currentUser()).container() != null || throw("Missing container.")