Thursday, March 21, 2013

Get and set BDC Column Value via Javascript

Hi All

We already know very well reagarding "getTagFromIdentifierAndTitle" function in SharePoint which is very useful to set and get the value of TextBox, DataField, Dropdown and many more to set and get the values from control. But what about if your list contains BDC Column value. How to set  and get the value from BDC Column?

Here is the jascript to achieve set and get the BDC column Value.

<script type='text/javascript'>
//set default value
_spBodyOnLoadFunctionNames.push("loadandhideBDC");
function loadandhideBDC()
{
setDefault();
}

//To check it contains value before saving
 function PreSaveAction() {
var elem = getBDCTagFromIdentifierAndTitle("TEXTAREA","Object Picker", 1);
if(elem.value =="")
{
 alert( "Invalid Value");
 return false;
}
}

function getBDCTagFromIdentifierAndTitle(tagName, title, count) {
var tags = document.getElementsByTagName(tagName);
var myCount = 0;
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title){
myCount++;
if(count == myCount){
return tags[i];
}
}
}
return null;
}


function setDefault() {
var variety = "";
var elem = getBDCTagFromIdentifierAndTitle("TEXTAREA","Object Picker", 1);
if(elem) elem.value = variety;
var elem = getBDCTagFromIdentifierAndTitle("DIV","Object Picker", 1);
if(elem) elem.innerText = variety;
}
</script>

Disha Shah

Jquery Redirect After save an item from NewForm.aspx and EditForm.aspx

Hello all

I came across to an situation where user needs to redirect to a "Thank You" or lets say different page when they save item fron "NewForm.aspx" or "EditForm.aspx".

As I do not want to use Visual Studio code that ater save item Event Receiver - "ItemAdded" I tried to look around is there any other option available like Jquery , and yes we can , so easy :)

Here is the code for that.

$(document).ready(function() {

        var button = $("input[id$=SaveItem]"); 
// change redirection behavior 
button.removeAttr("onclick"); 
 button.click(function() { 
             var elementName = $(this).attr("name"); 
             var aspForm = $("form[name=aspnetForm]"); 
             var oldPostbackUrl = aspForm.get(0).action; 
             var currentSourceValue = GetUrlKeyValue("Source", true, oldPostbackUrl); 
             var newPostbackUrl = oldPostbackUrl.replace(currentSourceValue, "custompageurl.aspx"); 
   
             if (!PreSaveItem()) return false; 
             WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", newPostbackUrl, false, true)); 
         }); 
});

Enjoy Jquery!
Disha Shah

Running SharePoint 2010 vhd in Windows 7 using Oracle Virtual Box.

Hi All

Here are the steps regarding how to run the 2010 VHD on Windows 7 box by using Oracle Virtual Box.

First we need to download and install below 3 softwares.

1>  Configure BIOS for HAV PCs.
http://www.microsoft.com/windows/virtual-pc/support/configure-bios.aspx

2> Download Oracle Virtual Box.
http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html

3>  Download SharePoint 2010 VVHD.
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27417

4> Place all files in a folder and extract the application file which will create a single vhd.
 
Let us see the below steps how to run the SharePoint 2010 VHD by using the Oracle VM Virtual Box. 
  1. Open Virtual Box and click "NEW" - which brings you one wizard to select for VHD. 
  2. Choose Operation System as "Microsoft Windows" and version as "Windows 2008 (64bit)click, "Next."
  3. In Memory dialogue box type 4096 MB(Recommended) or more and click, Next. Make sure your client system has more than 4GB RAM.
  4. Choose "Use existing hard disk" and navigate to  2010-7a.vhd clicking the icon.Next  and click, Finish.
  5. Click on "Storage" in the detail section. Click, 2010.7a.vhd and delete it using delete icon .     
  6. Click "SATA Controller" and delete it using delete icon.
  7. Under IDE Controller click add vhd icon.
  8. In dialogue box, click "choose existing disk.
  9. "Navigate to the 2010-7a.vhd and click ok.
  10. Under "System" allow process to use 2 CPUs instead of default 1.
  11. Start the virtual machine.
 Enjoy!
 Disha Shah