Monday, July 28, 2008

Programmatically remove InfoPath digital signature

This code will need to be placed within the backed InfoPath code, although just like before I'm going to try doing this with a web part. Speaking of which, I was able to remove the Excel digital signatures using a web part however it prompted for each signature that was to be removed and there is no way to get rid of that prompt so that sucked.

Anyway, here is how to do it in InfoPath. Basically get the signature node, go to the signature child of that node and delete it.

XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

if(this.Signed) //then unsign it
{
XPathNavigator xSignedSection = xnDoc.SelectSingleNode("my:myFields/my:signatures1/my:signatures2", this.NamespaceManager);

if (xSignedSection.HasChildren)
{
xSignedSection.MoveToChild(XPathNodeType.Element); xSignedSection.DeleteSelf();
}

}

3 comments:

Anonymous said...

This removes the link to add new signatures. Any way of bringing that bak?

Cheers

Brad said...

I do not experience that. For me it simply removes the person's signature but leaves the link to add a new signature.

e signature said...

Like brad i too didnot experience any
such problems but a friend of mine is facing such a problem in infopath.I will refer this post to her.