Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

getTagFromIdentifierAndTitle in SharePoint 2013 returns null

$
0
0

I have some javascript that runs when the new item form is opened. The code works fine in SharePoint 2010, but will not work in SharePoint 2013. When the form loads, I get an Unable to set property 'value' of undefined or null reference error so the getTageFromIdentifierandTitle function is returning null, but I can't figure out why. 

I am using the below code.

_spBodyOnLoadFunctionNames.push("executeOnLoad");

function executeOnLoad()
{
  getTagFromIdentifierAndTitle("input","","RequestID").value = id;
  getTagFromIdentifierAndTitle("input","","Date Created").value = simpleDate;
}

function getTagFromIdentifierAndTitle(tagName, identifier, title)
{
  var len = identifier.length;
  var tags = document.getElementsByTagName(tagName);
  for (var i=0; i < tags.length; i++) {
    var tempString = tags[i].id;
    if (tags[i].title == title && (identifier === "" || tempString.indexOf(identifier) == tempString.length - len)) {
      return tags[i];
    }
  }
  return null;
}


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>