Add/Update Datetime Field in ECMA Script Code Used var addBrowserUtcOffset = function (date) { var utcOffsetMinutes = date.getTimezoneOffset(); var newDate = new Date(date.getTime()); newDate.setTime(newDate.getTime() - (utcOffsetMinutes*60*1000)); return newDate; } function updateListItem() { this.clientContext = new SP.ClientContext(); var date = new Date(2012, 8, 17, 5, 0); console.log(date); this.isoDate = clientContext.get_web().get_regionalSettings().get_timeZone().localTimeToUTC(date.toISOString()); clientContext.executeQueryAsync( Function.createDelegate(this, this.onGetDate), Function.createDelegate(this, this.onQueryFailed) ); } function onGetDate() { var dateToInsert = addBrowserUtcOffset(this.isoDate.get_value()); var oList = this.clientContext.get_web().get_lists().getByTitle('testlist'); var oListItem = oList.getItemById(1); oListItem.set_item('dateField', dateToInsert.toISOString()); oListItem.update(); this.clientContext.executeQueryAsync( Function.createDelegate(this, this.onUpdate), Function.createDelegate(this, this.onQueryFailed) ); } function onUpdate() { console.log('DONE'); } function onQueryFailed(sender, args) { console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } updateListItem();
Thursday, 28 September 2017
Friday, 11 August 2017
Saturday, 27 December 2014
Compare SPUser objects in SP code
I have to compare the User
value in the Assigned To Field of the List with the other User value.
Here is the exact code that will do this.
SPUser spUser = GetSPUserOne();
SPUser spPrevUser = GetSPUserTwo();
For Windows Authentication This will do
if(spUser.Sid.Equals(spPrevUser.Sid))
{
…..
}
For FBA you have to follow this
if(spUser.UserToken.CompareUser(spPrevUser.UserToken))
{
…..
}
Here is the exact code that will do this.
SPUser spUser = GetSPUserOne();
SPUser spPrevUser = GetSPUserTwo();
For Windows Authentication This will do
if(spUser.Sid.Equals(spPrevUser.Sid))
{
…..
}
For FBA you have to follow this
if(spUser.UserToken.CompareUser(spPrevUser.UserToken))
{
…..
}
Create a SharePoint Provided Hosted App in SharePoint 2013
http://www.sharepointnadeem.com/2014/02/sharepoint-2013-provider-hosted-app.html
http://www.sharepointnadeem.com/2014/02/sharepoint-2013-provider-hosted-app.html
Saturday, 5 April 2014
SharePoint 2010: User Profiles properties not updated in People Editor and My Settings
SharePoint 2010: User Profiles properties not updated in People Editor and My Settings
Initially I have a set of users in the user profiles with only some set of Properties mapped. I have not set properties like Department, Email and Mobile number. My People Editor is showing empty values for Department, Email, Mobile Number and Title.

Now I set back the values in the user profiles as shown below
I have saved the above user profiles properties. Now when I check back in People Editor, this values are not reflected.
Resolution:
This user profiles properties are not reflected to the site collection. Each site collection has the user info list which will store the details locally in each site collection. To Sync the details two timer jobs need to be run.
1. Profile Synchronization – Default to run every hour
2. Quick Profile Synchronization- Default to run every minute
Using STSATM command we can initiate and force the timer job to run.
First run the Profile Synchronization timer job.
Ø Stsadm –o Sync –SyncTiming M:5
Now call the second timer
Ø Stsadm –o Sync -sweeptiming M:5
In some cases if the above does not update run the below stsadm command
Ø Stsadm –o sync –listdatabases <n> and
Ø Stsadm –o sync –deletedatabases<n>
-here n refers the days. While doing the Sync this database will be created. Delete databases command will delete old databases and recreate the full sync database. This delete would affect or delete your content database.
Initially I have a set of users in the user profiles with only some set of Properties mapped. I have not set properties like Department, Email and Mobile number. My People Editor is showing empty values for Department, Email, Mobile Number and Title.

Now I set back the values in the user profiles as shown below
I have saved the above user profiles properties. Now when I check back in People Editor, this values are not reflected.
Resolution:
This user profiles properties are not reflected to the site collection. Each site collection has the user info list which will store the details locally in each site collection. To Sync the details two timer jobs need to be run.
1. Profile Synchronization – Default to run every hour
2. Quick Profile Synchronization- Default to run every minute
Using STSATM command we can initiate and force the timer job to run.
First run the Profile Synchronization timer job.
Ø Stsadm –o Sync –SyncTiming M:5
Now call the second timer
Ø Stsadm –o Sync -sweeptiming M:5
In some cases if the above does not update run the below stsadm command
Ø Stsadm –o sync –listdatabases <n> and
Ø Stsadm –o sync –deletedatabases<n>
-here n refers the days. While doing the Sync this database will be created. Delete databases command will delete old databases and recreate the full sync database. This delete would affect or delete your content database.
Subscribe to:
Posts (Atom)
