Versioning of an Item

When a different user creates the version of the item ,the creator of the current revision remains same as the first version. In my case I want to change the creator to the person who actually created it.How to achieve it ? AnyBody?

  • Hello,

    The created_by_id is a system property that automatically gets set when the first version of an item is created. It's also not possible to edit this property once it's created.

    There's a couple different approaches you could take instead of using the created_by_id to achieve the same result. If this is an automatically versioned item instead of a manually versioned item, you could simply label the modified_by_id property as the creator and look at that instead. modified_by_id is another system property that points to the user that made the most recent change to the item. For automatically versioned items, this should always point to the user who created that version.

    If this is a manually versioned item, you could instead add your own custom property like version_created_by with some custom logic in an onBeforeVersion event to set this property to the user making the change.

    Chris


    Christopher GIllis

    Aras Labs Software Engineer

  • it sets the value on the form but when I try to get that property before starting the workflow manually it refers to the previous creator.and when i explicitly change it before the start of the workflow it shows me Itemisnotlocked exception but its not coming from my method.

  • Hi there,

    I believe a little more information about your setup and/or use case is required to help you fix this issue.
    The modified_by_id will update after a change to the item has been made, but you might get discrepancies if you are inside an onBeforeUpdate or onBeforeVersion method and try to access this information.

    The ItemIsNotLockedException could indicate that you are "apply()"-ing a change on an item inside a method that results in another change "apply()"-ed on that item. I would always be careful with using apply() on items within any onBefore/AfterUpdate/Version etc method, since you are unlocking the item implicitly when, for example, applying an edit-action on an item. This then leads to the exception when the update that caused the onBeforeUpdate-method to trigger tries to apply() its changes and finds an unlocked item (to which update/edit-actions cannot be applied).
    For some setups, however, you can simply set the new property on the Item in the onBeforeXxxx-method without using apply() and have your change committed to the database using the implicit apply() in the scope that the method gets called in. But, to advise anything more specific, a little more information on your setup would be required.

    Hope this helps,

    C

  • Thanx for the response.I have resolved the issue.