MOSS: Cannot set "Modified", "Modified By", "Created" and "Created by" fields in the publishing pages list without changing version?

Hello everyone,
I've got the task to programmatically import data to a moss web by add publishing pages to the pages-library with enabled moderation and major/minor-versioning.
This is not really difficult but the main issue is to set the values for the fields "Created", "Created by", "Modified" and "Modified by".
Also this is not relly difficult. By setting the internal field-properties "Author" for Created by and "Editor" for Modified by there values are set.
But the main problem now is, that I have to approve the publish page. After that, the value of the "Modified"-Field is change to the current datetime which is not acceptable.
If I redo an updating of the listitem, the file-version is increased to 1.1 which is also not acceptable. I do this by .UpdateOverwriteVersion(), which MSDN says of that it doesn't increase the version but indeed it does.
Following an example code of my approach:
using (SPSite spSite = new SPSite(SiteCollectionURL))
using (SPWeb spWeb = spSite.OpenWeb())
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(spWeb);
PageLayout[] layouts = publishingWeb.GetAvailablePageLayouts(<Guid of my pageLayout>);
if (layouts != null && layouts.Length > 0)
PageLayout layout = layouts[0];
PublishingPage newPage;
// add new publishing page
newPage = publishingWeb.GetPublishingPages(0).Add("test.aspx", layout);
newPage.Title = "testpage";
newPage.ListItem[SPBuiltInFieldId.Comments] = "test comment";
newPage.Update();
newPage.CheckIn("Checked in programmatically");
SPListItem tmpListItem = publishingWeb.PagesList.GetItemById(newPage.ListItem.ID);
string creationDate = "2009-11-05T22:35:10Z";
string modifyDate = "2009-11-06T22:35:10Z";
tmpListItem["Author"] = "1;#User 1";
tmpListItem["Editor"] = "2;#User 2";
tmpListItem["Created"] = creationDate;
tmpListItem["Modified"] = modifyDate;
tmpListItem.UpdateOverwriteVersion();
// data is now alright set, now approve
tmpListItem.File.Approve("Approve test");
// publishingpage is now approved but modified-date has changed, try to reset data
SPListItem updItem = spWeb.GetList(spWeb.Url + "/Pages").GetItemById(tmpListItem.ID);
updItem["Author"] = "1;#User 1";
updItem["Editor"] = "2;#User 2";
updItem["Created"] = creationDate;
updItem["Modified"] = modifyDate;
tmpListItem.UpdateOverwriteVersion();
// now all four values are correct but now version is 1.1 and approval status 'draft' again
Also updating the listitem by ProcessBatchData doesn't do it becaue I couldn't successfully update the author/editor-fields.
Do you have any working ideas or hints for me?
Greetings from Germany,
LoneSurvivor

I think iv cracked it...
Coppied straight from my code so the variable names dont match but the principal is there...
$dstfile.ListItemAllFields["Author"] = ($author.ID.ToString() + ";#" + $author.LoginName)
$dstfile.ListItemAllFields["Editor"] = ($modifier.ID.ToString() + ";#" + $modifier.LoginName)
$dstfile.ListItemAllFields["Created"] = $srcfile.TimeCreated.ToLocalTime()
$dstfile.ListItemAllFields["Modified"] = $last.ToLocalTime()
# changes to editor have to be done by Update or UpdateOverwriteVersion
$dstfile.ListItemAllFields.UpdateOverwriteVersion()
if ($file.Level -eq "Published") {
# publish not needed and overwrites 'Editor' so dont use
# $dstfile.Publish($file.CheckInComment)
# use .Approve() which updates the major minor versions too
$dstfile.Approve($file.CheckInComment)
# approve changes the dates so correct here
$dstfile.ListItemAllFields["Created"] = $srcfile.TimeCreated.ToLocalTime()
$dstfile.ListItemAllFields["Modified"] = $last.ToLocalTime()
$dstfile.ListItemAllFields.SystemUpdate()

Similar Messages

  • How to set border lines in table and also in template in the smartforms ?

    How to set border lines in table and also in template in the smartforms ?
    As I have to create table with following detals
    total row = 3
    row1 = 3 column
    row2 = 6 column
    row3 = 9 column
    for 2nd and 3rd row data to be fetched using coding.
    so can anybody explain me what should i use
    Table or Template ?
    and I want the border like excel format.
    Can anybody suggest me ?
    Thanks
    naresh

    if the data is multiple i.e. line items choose table.
    if the data is single i.e. fixed choose template.
    Create table
    >  Draw u r no lines
    > choose option select pattern
    > select display framed patterns
    Choose u r required one.
    out lined, or full lined. u can choose option.
    same procedure to be followed for template also.
    with regards,
    Kiran.G

  • When I set all the tracks in the latest Garageband to the same volume levels and save, when I open the file again they've changed back to a previous setting?

    I'm trying to mix a recording in the latest 2014 version of Garageband, but when I set all the tracks in the latest Garageband to the same volume levels and save, when I open the file again they've changed back to a previous setting? Does anyone know why it changes even after saving the file?
    Below is my iMac settings.

    Do you have a back up?
    If not you're into using file recovery software like  File Salvage - you can download a free trial and it will scan the disk for you and tell you with might be recoverable. Actual recovery will require that you purchase the app. There may be many files with the same or similar names. Always recover the largest file size.
    There are other such apps. Search on Macupdate or the App Store

  • I wish to reinstall Adobe Creative Suite 6 Design Standard on a replacement PC using the original box CD and Serial Number. Website says SN is valid but cannot find corresponding Adobe product.  My product is not on the drop down list offered.  hat do I d

    I wish to reinstall Adobe Creative Suite 6 Design Standard on a replacement PC using the original box CD and Serial Number. Website says SN is valid but cannot find corresponding Adobe product.  My product is not on the drop down list offered.  What do I do next?

    Contact support by web chat.
    Mylenium

  • Creating and saving a book for a web page

    I have been able to create and save as a pdf a 100 page travel book with about 195 photos. It was 89.9 mb. I gave it to my webmaster to put on my website but it is still a 10mB file that one has to download off the internet.
    my questions are...if you just want to use it as such, is there a way to make the book smaller in size,, not visual size--without losing quality in viewing = less MB? Or can one save the book in another way? (the movie version is very small to see all that is written).
    any advise would be most appreciated, thanks,
    tarzana

    tarzana:
    Welcome to the Apple Discussions. While in the book mode do a Print to PDF with the Save PDF to iPhoto option selected. That will create a jpg file of each page of the book that you can use to create an iWeb photo page and slideshow or create an iPhoto Web Gallery. I also use the same method to create an iDVD slideshow with music for each book that I make as described in Tutorial #6.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • BAPI Diff between Creat and Create from Data

    Hi All,
    for Sales order creation we have Many BAPI function module.
    how can i decide which module shoud i use ..a
    and what is the diff bw create and create from data function module.
    And i have read some where about BAPI --- ' acces to SAP applications from Third party can only by means of BAPI's.'..
    it means can't third party call RFC's in SAP.
    if they can call RFC's why BAPI.
    i met this question in so many Situations.
    But i didnt get clear answer for this.
    could u pls help me.
    Thanks in advance.
    Jeyaseelan.G

    hi jeyaseelan guru,
    there no difference actually ...between a create bapi and create from data() bapi...
    open business object type kna1 in swo1 and see that  differeence lies in the versions .....double click on create method under the methods node u will find tat create bapi  used from the release 30a and create from data bapi used from the release from 45a.......... based on the versions it offer more features ............
    so, try to use a bapi of newer version
    The BAPI Create() or CreateFromData() creates an instance of an SAP business object type, for example, a purchase order. These BAPIs are class methods.
    reward points if helpful.....
    Message was edited by:
            raam

  • How to add a "Create and Create Another" button to form

    I have an input form on a table with several LOV select lists and a text field. To ease data entry, the user wants to create several records, one at a time, by remaining on the same form page. Built-in APEX functionality adds the record and returns the user to the report page.
    User wants to create the first record by clicking the Create button, stay on the form with all the LOV values as they were (not clearing cache), change one or two LOV choices and the text field, and click a "Create and Create Another" button. The user will stay on the form until clicking the "Cancel" button.
    I changed the branch on the form to call itself. The LOV and text field values remain, but the "Create" button disappears to add another. Of course, I'll need to run the Get PK process to get the next sequence number for the new record.
    Looking for the best way to accomplish this. Thanks!

    If it is using the default setup, I believe you would clear the PK field (and now others) on branch to same for "Create and Create Another", as that is the default criteria for whether the Create button is shown.

  • I received an email from an acquaintance with her handwritten personal  signature at the bottom. Is thereafter way for me to create and use such signatures at the end of my emails from apple products?

    I received an email from an acquaintance with her handwritten personal  signature at the bottom. Is thereafter way for me to create and use such signatures at the end of my emails from apple products?

    Settings > Mail > Signature

  • HT2534 The none option is not showing for indian itune store. So cant i create and itune account for just downloadning free app anymore without credit card information?

    The none option is not showing for indian itune store. So cant i create and itune account for just downloadning free app anymore without credit card information?

    HI..
    The None option is not available in all countries  
    iTunes Store: Which types of items can I buy in my country?

  • I'm trying to set up my iphone 5s and it has been on the apple screen for hours with no improvement

    I'm trying to set up my iphone 5s and it has been on the apple screen for hours with no improvement
    I don't know  how to restart it...I've tried everything and it won't move away from this screen.  It's been plugged into my computer for a while now, and still does nothing.

    You need to connect to the compuer via the lighting cable that came with it. IF that failes follow this article http://support.apple.com/kb/HT1808

  • To see the username and datetime who/when created and who/when last updated the record

    Excel Addin and Web UI future:
    We need to see the username and datetime who/when created and who/when last updated the record.
    We need these columns in tables (as shown columns with status error)
    from Moscow with money

    Vincent,
    By the way, Just this week
    we have +20 MDS-users
    from Moscow with money

  • HT5706 My Apple TV is frozen on the time and date setting and then it goes to the screen saver I tried changing the batteries on the remote and it still doesn't make a difference someone help

    My Apple TV is frozen on the time and date setting and then it goes to the screen saver I tried changing the batteries on the remote and it still doesn't make a difference someone help...has anyone else had these problems?

    Hi i ran into the same problem Ithoght it was the control, i changed the batteries the the control, and stil did not work, in the same connection (network and everything) i installed a new one and it worked perfectly, i can deduct the unit is nit working properly

  • Using WEB Output HTML Gallery and uploading using ftp upload the HTML page views correctly but images only display the alt tag?

    Using WEB Output HTML Gallery and uploading using ftp upload the HTML page views correctly but images only display the alt tag in the browser window?

    After a little investigation, I discovered that PNGs also do not render correctly in IE7 in similar circumstances.
    I ended up using Levels in Photoshop to bring the output blacks up to "5", saved the images as PNGs, modified the HTML from .jpg to .png, and that seems to have covered up the problem well enough.
    By the way, I did confirm that IE8 beta 2 renders the images correctly.
    Brian

  • I have three different listings for Bob Seger on my iPod (bob Seger, Bob Seger System and Bob Seger and The Silver Bullet Band) How can I put all 3 in the same artist folder without changing artist name?

    I have three different listings for Bob Seger on my iPod (Bob Seger, Bob Seger System and Bob Seger and The Silver Bullet Band) How can I put all 3 in the same artist folder without changing artist name?

    Can you just create a new "Playlist", name it Bob Seger and drag what you want into the Playlist.
    File/New Playlist

  • A cmr-field and a cmp-field on the bean are using the same name. The names

    Hi:
    I am using weblogic 8.1 and MyEclipse 5.1.1. I am deploying my ear application through MyEclipse 5.1.1 as an ear file.
    When I ran the following EJB QL:
    SELECT OBJECT(p) FROM Product p.category = ?1
    I get the following error:
    n relation Category-Product, a cmr-field and a cmp-field on the bean are using the same name. The names of cmr and cmp fields must be unique.
    It is basically complaining that I have a field
    <cmr-field>
                             <cmr-field-name>category</cmr-field-name>
                        </cmr-field>
    in my ejb-jar.xml and also the same category in the
    <cmp-field><field-name>category</field-name></cmp-field>
    field. The problem is that if I changed the value of the cmr-field, I have to add a get and set in my productLocal.java and when you do that you have to do the same in the ejb-jar.xml.
    Here is my ejb-jar.xml:
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC
    "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
    "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <ejb-name>CategoryEJB</ejb-name>
    <local-home>com.CategoryHomeLocal</local-home>
    <local>com.CategoryLocal</local>
    <ejb-class>com.CategoryBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Integer</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>Category</abstract-schema-name>
         <cmp-field><field-name>categoryId</field-name></cmp-field>
    <cmp-field><field-name>categoryName</field-name></cmp-field>
    <cmp-field><field-name>picture</field-name></cmp-field>
    <cmp-field><field-name>pictureWidth</field-name></cmp-field>
    <cmp-field><field-name>pictureHeight</field-name></cmp-field>
    <cmp-field><field-name>labelOn</field-name></cmp-field>
         <cmp-field><field-name>labelOff</field-name></cmp-field>
         <cmp-field><field-name>button</field-name></cmp-field>
    <primkey-field>categoryId</primkey-field>
    <security-identity><use-caller-identity/></security-identity>
              <query>
                   <query-method>
                        <method-name>findCategory</method-name>
                        <method-params></method-params>
                   </query-method>
                   <ejb-ql>
                        SELECT OBJECT(c) FROM Category c
                   </ejb-ql>
              </query>
         </entity>
         <entity>
    <ejb-name>ProductEJB</ejb-name>
    <local-home>com.ProductHomeLocal</local-home>
    <local>com.ProductLocal</local>
    <ejb-class>com.ProductBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Integer</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>Product</abstract-schema-name>
         <cmp-field><field-name>productId</field-name></cmp-field>
    <cmp-field><field-name>brandName</field-name></cmp-field>
    <cmp-field><field-name>productDescription</field-name></cmp-field>
    <cmp-field><field-name>purchasePrice</field-name></cmp-field>
    <cmp-field><field-name>category</field-name></cmp-field>
    <primkey-field>productId</primkey-field>
    <security-identity><use-caller-identity/></security-identity>
              <query>
                   <query-method>
                        <method-name>findProduct</method-name>
                        <method-params>
                        <method-param>com.CategoryLocal</method-param>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        SELECT OBJECT(p) FROM Product p.category = ?1
                   </ejb-ql>
              </query>
         </entity>
    </enterprise-beans>
    <relationships>
                   <ejb-relation>
                   <ejb-relation-name>Category-Product</ejb-relation-name>
                   <ejb-relationship-role>
                        <ejb-relationship-role-name>
                             Category-has-many-Product-numbers
                        </ejb-relationship-role-name>
                        <multiplicity>one</multiplicity>
                        <relationship-role-source>
                             <ejb-name>CategoryEJB</ejb-name>
                        </relationship-role-source>
                        <cmr-field>
                             <cmr-field-name>productNumbers</cmr-field-name>
                             <cmr-field-type>java.util.Collection</cmr-field-type>
                        </cmr-field>
                   </ejb-relationship-role>
                   <ejb-relationship-role>
                        <ejb-relationship-role-name>
                             Product-belongs-to-Category
                        </ejb-relationship-role-name>
                        <multiplicity>many</multiplicity>
                        <cascade-delete/>
                        <relationship-role-source>
                             <ejb-name>ProductEJB</ejb-name>
                        </relationship-role-source>
                        <cmr-field>
                             <cmr-field-name>category</cmr-field-name>
                        </cmr-field>
                   </ejb-relationship-role>
              </ejb-relation>
    </relationships>
    <assembly-descriptor>
    <security-role>
    <role-name>Employees</role-name>
    </security-role>
    <method-permission>
    <role-name>Employees</role-name>
    <method>
    <ejb-name>CategoryEJB</ejb-name>
    <method-name>*</method-name>
    </method>
    </method-permission>
    <container-transaction>
    <method>
    <ejb-name>CategoryEJB</ejb-name>
    <method-name>*</method-name>
    </method>
    <method>
    <ejb-name>ProductEJB</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>     
    Here is my weblogic-cmp-rdbms-jar.xml:
    <!DOCTYPE weblogic-rdbms-jar PUBLIC
    '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB RDBMS Persistence//EN'
    'http://www.bea.com/servers/wls810/dtd/weblogic-rdbms20-persistence-810.dtd'>
    <weblogic-rdbms-jar>
    <weblogic-rdbms-bean>
         <ejb-name>CategoryEJB</ejb-name>
    <data-source-name>ShoeStore</data-source-name>
         <table-map>
              <table-name>category</table-name>
              <field-map>
              <cmp-field>categoryId</cmp-field>
              <dbms-column>categoryID</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>categoryName</cmp-field>
              <dbms-column>categoryName</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>picture</cmp-field>
              <dbms-column>Picture</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>pictureWidth</cmp-field>
              <dbms-column>PictureWidth</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>pictureHeight</cmp-field>
              <dbms-column>PictureHeight</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>labelOn</cmp-field>
              <dbms-column>LabelOn</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>labelOff</cmp-field>
              <dbms-column>LabelOff</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>button</cmp-field>
              <dbms-column>Button</dbms-column>
              </field-map>
    </table-map>
    <automatic-key-generation>
    <generator-type>SQL_SERVER</generator-type>
    </automatic-key-generation>
    </weblogic-rdbms-bean>
    <weblogic-rdbms-bean>
         <ejb-name>ProductEJB</ejb-name>
    <data-source-name>ShoeStore</data-source-name>
         <table-map>
              <table-name>PRODUCT</table-name>
              <field-map>
              <cmp-field>productId</cmp-field>
              <dbms-column>productId</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>brandName</cmp-field>
              <dbms-column>brandName</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>productDescription</cmp-field>
              <dbms-column>productDescription</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>purchasePrice</cmp-field>
              <dbms-column>purchasePrice</dbms-column>
              </field-map>
              <field-map>
              <cmp-field>category</cmp-field>
              <dbms-column>categoryId</dbms-column>
              </field-map>
    </table-map>
         <!-- Automatically generate the value of ID in the database on inserts using sequence table -->
    <automatic-key-generation>
    <generator-type>SQL_SERVER</generator-type>
    </automatic-key-generation>
    </weblogic-rdbms-bean>
    <weblogic-rdbms-relation>
         <relation-name>Category-Product</relation-name>
    <weblogic-relationship-role>
    <relationship-role-name>Product-belongs-to-Category</relationship-role-name>
              <relationship-role-map>
    <column-map>
    <foreign-key-column>categoryId</foreign-key-column>
    <key-column>categoryID</key-column>
    </column-map>
              </relationship-role-map>
    </weblogic-relationship-role>
    </weblogic-rdbms-relation>
    </weblogic-rdbms-jar>
    Here is my productLocal.java:
    package com;
    import javax.ejb.CreateException;
    import javax.naming.NamingException;
    import java.util.Date;
    import java.util.Vector;
    import java.util.Collection;
    public interface ProductLocal extends javax.ejb.EJBLocalObject
         public Integer getProductId();
         public void setProductId(Integer productId);
         public String getBrandName();
         public void setBrandName(String brandName);
         public String getProductDescription();
         public void setProductDescription(String productDescription);
         public Double getPurchasePrice();
         public void setPurchasePrice(Double purchasePrice);
    public CategoryLocal getCategory();
         public void setCategory(CategoryLocal category);
    Here is my ProductBean.java:
    package com;
    import javax.naming.InitialContext;
    import javax.ejb.EntityContext;
    import javax.ejb.CreateException;
    import javax.naming.NamingException;
    import java.util.Date;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.Vector;
    import java.lang.Integer;
    public abstract class ProductBean implements javax.ejb.EntityBean
         public Integer ejbCreate(Integer id)
              this.setProductId(id);
              return null;
         public void ejbPostCreate(Integer id)
         //public abstract Integer getCategoryId();
    //     public abstract void setCategoryId(Integer categoryId);
         public abstract CategoryLocal getCategory();
         public abstract void setCategory(CategoryLocal category);
         public abstract Integer getProductId();
         public abstract void setProductId(Integer productId);
         public abstract String getBrandName();
         public abstract void setBrandName(String brandName);
         public abstract String getProductDescription();
         public abstract void setProductDescription(String productDescription);
         public abstract Double getPurchasePrice();
         public abstract void setPurchasePrice(Double purchasePrice);
         public void setEntityContext(EntityContext ec)
              System.out.println("ProductBean setEntityContext");
         public void unsetEntityContext()
              System.out.println("ProductBean unsetEntityContext");
         public void ejbLoad()
              System.out.println("ProductBean ejbLoad");
         public void ejbStore()
              System.out.println("ProductBean ejbStore");
         public void ejbActivate()
              System.out.println("ProductBean ejbActivate");
         public void ejbPassivate()
              System.out.println("ProductBean ejbPassivate");
         public void ejbRemove()
              System.out.println("ProductBean ejbRemove");
    What do I needed to do to fix this problem.
    Any hint or help would be greatly appreciated!!!
    Yours,
    Frustrated

    cmr field which is "category" in ur mapping , u can't use as cmp field in abstract schema mapping. just remove category from cmp field . and every thing is fine

Maybe you are looking for