Expand my Community achievements bar.

How to get all signature fields?

Avatar

Former Community Member

Hi,

I want to get all (unsigned and signed) signature fields.

I try do something like this:

function GetAllSignatureField(){

var numFields = xfa.numFields;

app.alert(numFields);

for (var i = 0; i < 2; i++){

app.alert(xfa.getNthFieldName(i));

if(xfa.getNthFieldName(i).type=="signature"){

// is signaturefield...

}

}

}

The firtst alert show me undefined and after that, secod alert write to console TypeError: xfa.getNthFieldName is not a function.

Do you know where is problem? In javascript reference there write this.numFields and this.getNthFieldName(i). I create dynamic

form. I tryed using this.numFields, xfa.numFields and xfa.host.numFields. Everytime it do same.

Thanks Jakub.

3 Replies

Avatar

Level 10

Hi,

In Javascript you will need to resolve the node of each iteration of the loop. Something like this:

for (var i = 0; i < 2; i++){

var currentObject = xfa.resolveNode("yourfieldname[" + i + "]");

app.alert(currentObject);

if(currentObject.type=="signature")

There is some examples of SOM expressions here: http://assure.ly/kUP02y.

I haven't checked the syntax of the signature script, but this might help: http://assure.ly/m8mN0m.

Hope that helps,

Niall

Avatar

Former Community Member

There is some problems with this solution. I need universal function where arent path of fields.

Sou I am not able to use something like that

"yourfieldname[" + i + "]"

I did function, which walk thru all nodes and find signature.

If I had some node, then if I do node.type return "undefined".

If I do node.rawValue, it return real rawValue (e.g. "James" for field Firstname).

Is there some reason, why I cant use node.type?

Is some other solution?

Thanks Jakub.

Avatar

Former Community Member
This works
var CurrentObject = xfa.resolveNode("form[0].page1[0].header[0].Button2[0]");
//var currentObject = xfa.resolveNode(" form[0].page1[0].sig[0].signature[0]");
var val= currentObject.ui.signature == null;
app.alert(val);