1 using
(SPSite siteObj =
new
SPSite(
"http://hydpc1129:9999/ITS/"
))
2
{
3
using
(SPWeb webObj = siteObj.OpenWeb())
4
{
5
SPList empListObj = web.GetList(
"LegalContracts"
);
6
SPListItem empItem = empListObj.Items.Add();
7
empItem[
"Title"
] =
"Emp1"
;
8
empItem[
"Department"
] =
"Finance"
;
9
empItem.Update();
10
//empItem.SystemUpdate();
11
//empItem.SystemUpdate(true);
12
//empItem.SystemUpdate(false);
}
}
Update
In the above code, Line 9 empItem.Update() will update the “EmpList” data. This will also update the built in columns “Modified” and “Modified By”.SystemUpdate
If we are using Line 10 empItem.SystemUpdate(); this will update the “EmpList” data but not the built in columns “Modified” and “Modified By”.If we are using Line 11 empItem.SystemUpdate(true);this will update the “EmpList” data but not the built in columns “Modified” and “Modified By”. But it will increment the item version
If we are using Line 12 empItem.SystemUpdate(false);this will update the “EmpList” data but not the built in columns “Modified” and “Modified By”. Also, does not increment the item verision
SystemUpdate will trigger all the list events if any and also the changes can be observed in Audit logs. Only alerts will not be triggered that are configured on the list.
Note:
If we are using SharePoint model, we are flexible to use any of the methods as per our requirement.
But, if we are using client object model only Update method will be available, SystemUpdate method will not be available. Its obvious that SystemUpdate method is not available because, clients are updating the database data and server should be aware of this(though logs are still updated).
I think that is good reason why client object model does not expose SystemUpdate method
No comments:
Post a Comment