Tuesday, March 24, 2015

Javascript to check broken links

Hi Guys, recently i came across to find out whether the given set of URL's are broken links or not.

I have created below sample snippet to findout whether a URL exists Or not.

<html>
<head>
<script type = 'text/javascript'>
function IsUrlExists(url) {
  var http = new XMLHttpRequest();
  alert(http);
  http.open('HEAD', url, false);
  http.send();
  alert(http.status);
  return http.status != 404
}
</script>
</head>
<body>
<input type="text" name="Url" id="url">
<input type="button" value="Check" id="btncheck" onclick="IsUrlExists(document.getElementById('url').value);">
</body>
</html>

Hope this helps..

Monday, March 23, 2015

Publishing Infopath Form to a new site/ Infopath change publish location

Hi Folks,

In this post we are going to Change the target site/ list url for publishing Infopath form

Problem Statement:
You have a Infopath form developed with a List template, present in a Sharepoint List of Development Environment. Now that you want to publish this form to Production environment but while publishing you will not be prompted to enter new URL in publishing wizard.
When you try to open the publishing Wizard from File Menu and then click on Publish you can see only the below two options.
·         Sharepoint List
·         Export Source Files
The "Sharepoint List" option remembers the Quick Publish Location and even has a Label stating: "The form will be published to: http://oldurl"
Clicking on the it, just does exactly the same as Quick Publish action i.e., quick publish without bringing up the wizard to choose the publish location.
Solution:
I found the best approach as below. It involves in updating the manifest files and view files. Below is the approach which does the trick.
1.       Infopath form (xsn) file is basically a cab file with bunch of related files in it.
2.       Rename xsn to cab extension
3.       Extract the cab file to a location
4.       Open the manifest.xsf file and replace the OLD URL with new URL.
5.       Update the new ListID and ContentTypeID in the Manifest.xsf(If you don’t do this, you will get List not found error).
6.       Open all the xsl files(views) present under extracted folder and perform the steps 4 and 5 if it has old URL and ListID/ContentType ID present.
7.       Save all the modified files and then right click on the manifest.xsf file and open click on design.

8.       This will open the Infopath form and Go to Publish. You will be able to see the updated New URL. Go ahead and Publish It and you are done.

Monday, February 24, 2014

How to Show and Hide a jQuery UI dialog popup

In this post we are going to load a specific page in a jquery UI dialog box. Below are the steps which does the trick.
Step 1: 
Add the jquery reference and then
Add the below empty div to your HTML
<div id="dlgdivcontent">
</div> 

Step2: 
Add the below java script function to your page
var $mydialog;
    function opendialogbox(url, popintitle) {
        $mydialog= $('#dlgdivcontent')
               .html('<iframe " src="' + url + '" width="500" height="350" scrolling="auto" frameBorder="0"></iframe>')
               .dialog({
                   autoOpen: false,
                   show: "fade",
                   hide: "fade",
                   modal: true,
                   height: 350,
                   width: 500,
                   resizable: false,
                   title: popintitle,
                   close: function (event, ui) {
                   //custom action if any on close click
                   }


               });

        $mydialog.dialog('open');
    }

Step3: 
Call the function opendialogbox with parameters as Url and Title on which wherever the link/button that you want to trigger the dialog box.

Popular Posts