Saturday, 29 January 2011

How to set custom list item 'Approval Status' programmatically

These days I'm also working on the 'List Migration' feature in my codeplex tool for document and list migration and copy operation.


You can enable moderation on a custom list by using this option under List Settings > Versioning Settings




Once this option is enabled, SharePoint creates two columns(Approval Status, Approval Comments) in a custom list to store the moderation status and comments.


When you write any migration scripts you'll have to take these columns into account as well otherwise all the migrated items will result to 'Pending' approval status. 


In order to set these columns programmatically, I'll suggest that you use the following code:

One thing worth mentioning here, people often confuse 'SystemUpdate' with 'Update'. The 'SystemUpdate' will update the contents of a list without changing 'Modified', 'Created' datetime stamps. The update performed using 'SystemUpdate' will note create any additional version(if versioning is enabled). Where as 'Update' updates the 'Modified','Created' timestamps, user information(who has updated)  along with the version history(if enabled).


I also noticed, when you create a custom list item inside a folder directory make sure the folder url is in the following format
folderurl: '/lists/{customlist}/{foldername}'.
 ****** there's no '/' in the end


Majid



No comments:

Iconise ‘Add Picture’ control in PowerApps

Default look you get for ‘Add Picture’ control is not very appealing for end user and there is no OTB way of specifying icon for this con...