Thursday, 3 October 2013

Website Recommanded

Free Web Part
http://www.amrein.com/apps/page.asp?Q=312

SharePoint 2013 Foundation with Yammer Integration

Create a text file, upload to document library with the following content:

<!DOCTYPE HTML>
<html>
<head>
<style>
#embedded-feed{
 border:1px solid #f0f0f0;
 padding:2px;
 height:500px;
 width:278px;
}
</style>
</head>
<body>
<script data-app-id="hyB2pTvrL36Y50py8EWj6A" src="https://assets.yammer.com/platform/yam.js"></script>
<script>
yam.connect.embedFeed(
{ container: '#embedded-feed'
, network: 'xxxx.com'
//, feedType: 'group' // can be 'group', 'topic', or 'user'
//, feedId: '2712' // example feed ID for BSC group
, config: {
 header: false
}
});
</script>
<div id="embedded-feed"></div>
</body>
</html>


In a webpage, insert a content webpart and link to this file, done.

Tuesday, 10 September 2013

SharePoint database Maintenance

USE [SharePoint_Config]
GO
ALTER DATABASE [SharePoint_Config] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE('SharePoint_Config_log', 100)
ALTER DATABASE [SharePoint_Config] SET RECOVERY FULL WITH NO_WAIT  
GO

Tuesday, 27 August 2013

Hide Quick Launch Menu Items

<script type="text/javascript">
 var context = null;
 var web = null;
 var currentUser = null;
 var currentUserId = '';
 var value = null;

 ExecuteOrDelayUntilScriptLoaded(hideDiv,"SP.js");
 function hideDiv() {
  context = new SP.ClientContext.get_current();
  web = context.get_web();
  context.load(web, 'EffectiveBasePermissions');
  currentUser = web.get_currentUser();
  currentUser.retrieve();
  context.load(web);
  context.executeQueryAsync(onSuccessMethod, onFaiureMethodl);
 }
 function onSuccessMethod(sender, args) {
  var userObject = web.get_currentUser();
  //alert('User name:' + userObject.get_title() + '\n Login Name:' + userObject.get_loginName());
  var perm = web.get_effectiveBasePermissions();
  if(perm.has(SP.PermissionKind.approveItems)){
   jQuery('#NewProductInformation').css("visibility", "visible");
  }
 }
 function onFaiureMethodl(sender, args) {
  alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
 }
</script>

Thursday, 7 March 2013

Print calendar form using standard browser printing function

In master page, add:
@media print {
.cssPrintButton {
 DISPLAY: none
}   
.no-print { display:none; }
    .marginleftzero {
 margin-left:0px !important;
}
}

<div class="TopArea s4-notdlg no-print" style="height: 138px">
<div class="s4-ca s4-ca-dlgNoRibbon marginleftzero" id="MSO_ContentTable">

add one content webpart to disp page
<div class="cssPrintButton"><input onclick="window.print();return false;" type="button" value=" Print this page "/> </div>

Speed up your SharePoint 2013 server

Reduce the CPU impact the search service:

PowerShell: Set-SPEnterpriseSearchService -PerformanceLevel Reduced

Reduce the memory usage by noderunner.exe processes:

1.       Open file in notepad:  C:\Program Files\Microsoft Office Servers\15.0\Search\Runtime\1.0\noderunner.exe.config

2.       Change the value at <nodeRunnerSettings memoryLimitMegabytes="0" /> to 100 (Megabytes) for example.

Friday, 18 January 2013

Upgrade laptop hdd for Windows 2008 R2 OS

As a SharePoint developer I need Hyper V feature, I am using Windows 2008 R2 OS as my laptop system. Laptop hdd is 250G which is not enough. Recently I got a 1TB portable hdd from company lottery. So I start to upgrade my laptop hdd.
1. I tried DriveImage xml, the duplicated hdd cannot start OS
2. I download the diskgenius software from http://www.diskgenius.cn/download.asp and installed on Windows 2008 R2
3. Connect portable hdd to laptop and start disk 2 disk copy
4. Replace laptop hdd with the 1TB hdd
5. Resize partation using diskgenius


Saturday, 12 January 2013

SharePoint Apps development experience

Better to know this when you start to develop your SharePoint Apps

1. When adding a new list to apps, it will be placed in your apps web, not your host web.

2.  Javascript client object model is the core to built SharePoint Apps.

to be continued....

Friday, 11 January 2013

Update metadata field value

To update metadata field, firstly you have to find the exact value of the metadata value.

Update metadata value manually, then use the following script to find the value:


function queryitems(){
var query = "<Query>";
query += "<Where><Eq><FieldRef Name='ContentType' /><Value Type='Text'>Document</Value></Eq></Where></Query>"
$().SPServices({
    operation: "GetListItems",
//webURL: window.location.protocol + "//" + window.location.host,
webURL: "https:" + "//" + url,
    async: false,
    listName: list,
    CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll' IncludeRootFolder='True' /></QueryOptions>",
CAMLQuery: query,
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_ID") + " : " + $(this).attr("ows_Year") + "</li>";
        $("#tasksUL").append(liHtml);
        var obj = {
        itemid: $(this).attr("ows_ID"),
    };
    arrayid.push(obj);      
      });
    }
  });
}

After get the value, in my case is: 3;#2012, I use the following script to update around 1000 items in a run:
function updateitems(){
    var yearvalue="3;#2012";
    var update_string = "<Batch OnError='Continue'>";
    for (i=0; i<arrayid.length; i++) {
        update_string += "<Method ID='"+(i+1)+"' Cmd='Update'>";
        update_string += "<Field Name='ID'>"+ arrayid[i].itemid+"</Field>";
        update_string += "<Field Name='Year'>"+ yearvalue +"</Field>";
        update_string += "</Method>";
    }
    update_string += "</Batch>";

$().SPServices({
    operation: "UpdateListItems",
        async: false,
        batchCmd: "Update",
        listName: list,
        updates: update_string,
webURL: "https:" + "//" + url,
    completefunc: function (xData, Status) {
        var liHtml = "<li>" + xData.responseText + "</li>";
        $("#Updated").append(liHtml);
    }
  });
}

It is great ~~

Thursday, 10 January 2013

Add columns to user information list

Go to site collection root site, Site Action >> Site Setting >> People and Groups

Go to Setting>>List setting of People and Groups

We can add more columns from here

Open pdf file in a new window

In a document library, pdf, word, excel file open in the same window as view does. For word, excel still have a breadcrumb links which can navigate back, for pdf we need a solution to open it in a new window via this script:

<script>
$(“a[href$='.pdf']“).removeAttr(‘onclick’).attr(“target”,”_blank”);
< /script>

Simple and efficient !

Integration services cannot upgrade HAL

Yesterday I did server replacement project. To simplify the process, I migrated the physical server windows 2003 sbs to virtual machine. Be careful on RAM installation as it has 12 slots, I guess only 6 slots are available if one processor installed, it takes me 2 hours to figure out. 

After conversion, the integration services couldn't be installed on virtual server. Finally I found a easy and interesting way to solve it:


Finishing touch is:
You need to use msconfig.exe and go to boot.ini. In my case, there were two boot entries of my server2003 installation. The one with disk2vhd at the start was on top. Change it to the normal server2003 boot path and reboot the machine.

payne80 you are awesome ~~

Windows 2008 Server R2 Auto Login

I am using Windows 2008 Server R2 as my laptop OS, after joining to company domain, the auto login feature was not working any more. Today I found a blog and made my day:

 http://www.expta.com/2008/04/how-to-enable-autologon-for-windows.html

 For reference I copy the commands:
 reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d "1" /f

Run control userpasswords2

To set default Domain name
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d %USERDOMAIN% /f

Alternatively using reg file (didn't try):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"DefaultDomainName"="DomainNameGoesHere"
"DefaultUserName"="Administrator"
"DefaultPassword"="AdminPasswordGoesHere"

A craftsman who wishes to do his work well must first sharpen his tools.

There is a mission impossible on Windows 2008 R2 Server: using hibernate function on a Hyper V enabled server, please leave a message if you know how to do it, I worship you as a guru ^_^

Customize Black Top Bar of Google in Chrome

By default Google doesn't allow user to change the top link bar, maybe they think all people are programmers as smart as them, then no worries people can customize links as well ^_^

Yeah, I finally find how to customize the top link bar as following, the way is a bit tricky to find:
1. Firstly I tried IE, I gave up because the add-in Trixie was built in 2007 and nobody support any more.
2. Then I tried Greasemonkey, found  it only support Firefox.
3. Then I tried Google Extension - Big G Black Bar Sorter, as far as I know, this one only works on google.com and not for google.com.sg
4. Thanks God, I notice Chrome supports native user script as extension, which means everyone can write extension using JavaScript, wow, this is great!

Go to http://userscripts.org/ and found this guy: http://userscripts.org/scripts/show/131931, download and install, it works.

Here is another script which is simple but still working well: http://userscripts.org/scripts/review/111786

My top link bar of Chrome:




Let me know if you encounter any problems because maybe I have the same experience.

Enjoy~~