In an automation script I have the DVE Element available via engine.FindElement method.
It is also possible to know the parent element that generated the DVE:
elementToConfigure.RawInfo.DveParentDmaId
elementToConfigure.RawInfo.DveParentElementId
But how can I know the Primary Key of the row that generated a DVE element?
I need this value so I can map it to a Function Resource (this contains the parent dma and element Id and the primary key)
Both DVE Name and the Resource ID are stored in the [Generic DVE table]; therefore you should be able to access resource Id from DVE name using data available in that table.
Alternative is to use the ResourceManagerHelper and an appropriate filter:
FilterElement<Resource> filter = ResourceExposers.DmaID.Equal(fctDve.DmaId).AND(ResourceExposers.ElementID.Equal(fctDve.ElementId));
var fctResource = RMHelper.GetResources(filter).OfType<FunctionResource>().First();