dave.diehl-asg
-
8/20/2008 12:20:37 PM
2Qs: Adding new document (node) by code when Doc Name Source an existing field and InsertAsNewCultureVersion usage
The subject pretty well describes what I'm looking for, but let me elaborate.
I want to add a new document from code, and have done so successfully, but I'm not confident that I'm doing it the preferred way.
If the document type of the document I'm trying to add is set to use the Document Name from an existing field and NOT an "extra field", what do you do with the NodeName property of the new node?
For example, the following code works, but I'm not sure it's right... nodTemp = New CMS.TreeEngine.TreeNode("Foo.Bar") nodTemp.NodeName = "Foobar1" nodTemp.NodeAlias = "Foobar1" nodTemp.DocumentCulture = "en-us"
Why wouldn't I assign the property instead of the NodeName? E.g. If "Foo.Bar" is defined so the Document name is set to the value of the field "SomeField", shouldn't this be sufficient?
nodTemp.SetValue("SomeField", "Foobar1")
Also...on the second question. I'm not totally sure how to use the InsertAsNewCultureVersion method. When creating nodes in code for documents that may already exist for another culture, is the following (in pseudocode) sufficient?
Do SelectSingleNode using preferred culture. if nothing found Do SelectSingleNode using ALL_CULTURES if found set DocumentCulture of found node to preferred culture. Do InsertAsNewCultureVersion else Create new node else node already exists.
|