Blog Stats

How to Remove {generate-id()} from a Customized Form in SharePoint

If you’ve done much work using custom forms in SharePoint, you’ve probably run into the {generate-id()} bugaboo. For reasons that I’ve not been able to determine, if you use an id attribute in any HTML element, SharePoint Designer adds the {generate-id()} string to the end of the name you’ve set. Here’s an example. If you code this:

I haven’t seen this generate-id issue show up in a very long time, and I’ve done a lot of custom form stuff in the interim. My guess is that one of the Service Packs (probably SP1) or hotfixes has made it go away.

SharePoint may think there are valid reasons for this code but it breaks our form; it breaks the our javascript validation, but it is looking for an id that does not exist. Seems to me the only possible use for the generate-id is to prevent developers from referring to elements by id.

Actually SharePoint did do just that on a hard coded input with a unique ID. And when the Javascript tried to find the contents o the element it returned “‘undefined’ is null” error and stopped processing the page.

and when I am longed it the line read correctly but when anyone else is logged in we get

“‘undefined’ is null”

following guidelines in article added

to the xsl template in which this control existed
and changed input to

and got

“Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator.”

OK this web site did not read my pasted elements as text. What the above should have read is
this was the initial element
input type=”hidden” id=”UserName” value=”{$UserIdVar}”

And Sharepoint changed it to

input type=”hidden” id=”UserName{generate-id()}” value=”{$UserIdVar}”
and
then we made it
input type=”hidden” id=”UserName{generate-id($DummyVar)}” value=”{$UserIdVar}”
after
adding parm
xsl:param name=”DummyVar”

My error. In copying and pasting the param from the page above resulted in those slanted quotes instead of standard quotes which could not be evaluated. After fixing that everything worked as designed.

Think you’ve got great Active Directory data?

Try the FREE Hyperfish Analyzer
Find out just how bad your Active Directory data really is. In your custom report you will see how you are faring with key attributes including Profile Pictures, Phone Numbers, and Job Titles, as well as learn the value of an up to date Directory.