Tuesday, May 31, 2011

Javascript replace function

As the name implies, replace function searches a string for a particular substring provided as a function parameter and replaces it with the desired string.
Example No. 1
var tempStr = "replace function is not working";
document.write(str.replace("not working", "working"));
Result tempStr = replace function is working

However one problem with replace function is that it only replaces the first substring found.
Example No. 2
var tempStr = "a1b1c1d1e1f1";
document.write(str.replace("1", "+"));
Result tempStr = a+b1c1d1e1f1

We need something like replaceAll function in this situation. replaceAll function doesnot exists but we have a work around.

Example No. 3
var tempStr = "a1b1c1d1e1f1";
tempStr = tempStr.replace(new RegExp("1", 'g'),"+");
Result tempStr = a+b+c+d+e+f+

Thursday, May 26, 2011

Open window in a new browser

There are times when you want to open web page in a new window/browser using Javascript. Before we discuss javascript solution, let me share other ways as well to open new pages using clientend.
It cant get any simpler than this
To view all my post, pleace click here
Code <a href="http://www.qaziarfeen.blogger.com" >here </a>
Code <a href="http://www.qaziarfeen.blogger.com" target="_blank" >here </a>

Using Button
Instead of hyperlinks, we can use HTML buttons as well and make them behave the same way as hyperlinks

Use the following code to test the behaviour to open page in the same window

<input id="btOpen1" type="button" value="Home" onclick="return ClearUrl();" />

<script type="text/javascript" >
function ClearUrl() {

window.location.href = "www.google.com";
}
</script>



Use the following code to test the behaviour to open page in a new window
<input id="btOpen1" type="button" value="Home" onclick="return ClearUrl();" />
<script type="text/javascript" >
function ClearUrl() {
window.open('http://qaziarfeen.blogspot.com'_blank');
}
</script>

Wednesday, May 25, 2011

Email Notification Delays in SharePoint 2007

I was observing delays in notification email being received when I assign a task to someone using SharePoint Task.
I have already post on how to resolve it in SharePoint 2010. Here is a revision again


The timer interval service which sets this delay is called "job-investigation-alerts" This service send notifications out. The default timer interval is 5 minutes but we can of course change it using stsadm command

Open command prompt and browse to 12\bin and run the following command to identify if the job is running on the site



stsadm -o getproperty propertyname job-immediate-alerts -url < your-site-URL >


If you get Property Exists="Yes" and Value as some value defining the interval configured, it means that the service is running and you can change the interal using the following command

To set the property run the following command



stsadm -o setproperty -propertyname job-immediate-alerts -propertyvalue < A valid Windows SharePoint Services Timer service schedule > -url < your-site-URL >


Property Value can be set in the following manner


stsadm -o setproperty -propertyname job-immediate-alerts -propertyvalue "every 1 minutes between 0 and 59"


By running the above command you set the job to run every minute


References: