This is more of a â€˜note to selfâ€™ as Iâ€™m constantly being caught out when getting an object from Tridion using the various TDSE methods.
Iâ€™ll use the example of getting a folder via the TDSE object.Â To do this you have two ways:
- The TDSE.GetFolder(â€œIDâ€, Publication Object) Method
- The TDSE.GetObject(â€œIDâ€, OpenMode, Publication, ReadFilter) Method
The GetFolder will always need a valid Publication object, where as the GetObject will allow a null to be thrown in.
Iâ€™ve done this a thousand times:
- TDSE.GetFolder(â€œtcm:1-123-2â€, null);
Then spent about 20 minutes checking the XML, the webdav etc etc.
The benefit of being able to pass the null, is that if the Publication object doesn’t exist, you don’t have to create it surely making the GetObject a far superior method to use… just remember to cast to the correct Tridion item type:
- Folder fld = tdse.GetObject(…) as Folder
Please tell me Iâ€™m not alone in being constantly caught out by this!