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
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
No comments:
Post a Comment