9 Replies Latest reply on Mar 31, 2016 7:38 AM by kalabal

    Reading CheckMark State

    kalabal

      Hi everyone,

       

      I'm trying to get the state of CheckMark in JavaScript. As per JS API reference, code as below should be used and it works fine.

       

      annots = this.getAnnots()

         for ( var i= 0; i< annots.length; i++) {

            states = annots[i].getStateInModel("Marked");

            if ( states.length > 0 ) {

               for(j = 0; j < states.length; j++)

               {

                  var s = states[j].state;       

                  console.println(s );

               }

        

            }  

         }

       

      But as you know, CheckMark is also a part of an annotation( Sticky Note, Highlight, etc.). When I try to read the same state under the related annotation with InReplyTo, I get nothing.

       

      annots = this.getAnnots()

      mark = this.getAnnots()

         for ( var i= 0; i< annots.length; i++) {

               for ( var j= 0; j< mark.length; j++) {

                       if(mark[j].inReplyTo == annots[i].name){

                       states = mark[j].getStateInModel("Marked");

                         if ( states.length > 0 ) {

                            for(k = 0; k < states.length; k++)

                                {

                                 var s = states[k].state;

                                 console.println(s)

                                 }  

                            }

                       } 

                  }

         }

       

      I couldn't figure out what is wrong with this code? Any help is appreciated.

       

      Regards

        • 1. Re: Reading CheckMark State
          try67 MVP & Adobe Community Professional

          Are you talking about a check-box? If so, it's not an annotation at all. It's a field, and you access its value like this (let's say its name is "CheckBox1"):

          this.getField("CheckBox1").value

          • 2. Re: Reading CheckMark State
            kalabal Level 1

            Nope, I'm talking about CheckMark inside a comment. Please see picture below

            CheckMark.png

            • 3. Re: Reading CheckMark State
              try67 MVP & Adobe Community Professional

              I see what you mean. Unfortunately, I don't think you can access that information using a script.

              • 4. Re: Reading CheckMark State
                kalabal Level 1

                Dear try67, it is possible to access that info. It is stored under statemodel array of the annotation.

                 

                If you check the exported xfdf file of annotations, you can see something like that as below;

                 

                "inreplyto="03edbc7f-2608-462d-a1ee-0ce95d03e9ab" name="765594c1-0f1d-4456-9cdf-bdb184afb3c8" state="Marked" statemodel="Marked""

                 

                I can read this value with the first code above, but cant read it with the second code above which doesn't make sense at all.

                • 5. Re: Reading CheckMark State
                  try67 MVP & Adobe Community Professional

                  That's interesting. I wasn't aware do the "Marked" model-state... I'm looking into your second code now.

                  • 6. Re: Reading CheckMark State
                    try67 MVP & Adobe Community Professional

                    Can you explain a bit what you're trying to achieve with this code? You should be getting all the annotations, including the replies, when you use getAnnots... Are you trying to find annots that are both replies and checked?

                    • 7. Re: Reading CheckMark State
                      kalabal Level 1

                      My main goal is to export all the comments into an excel file.

                       

                      If a comment is checked, in the same row of the excel file user will see his comment and see if it is checked.

                       

                      So I need to get all the annotations and check if it is checked or not. Thats why I need to use second code above

                      • 8. Re: Reading CheckMark State
                        try67 MVP & Adobe Community Professional

                        You don't need to do that. The thing is, though, that checking the reply itself seems to generate an new, separate reply annotation...

                        I create a file with a comment and a reply and then checked the box of the reply. I then ran this version of your first code on it:

                         

                        this.syncAnnotScan();
                        var annots = this.getAnnots()
                        for ( var i= 0; i< annots.length; i++) {
                            console.println(i+1);
                            console.println("Type:"+annots[i].type);
                            console.println("Text:"+annots[i].contents);
                            console.println("Reply:"+(annots[i].inReplyTo=="" ? "false" : "true"));
                            states = annots[i].getStateInModel("Marked");
                            if ( states.length > 0 ) {
                                for(j = 0; j < states.length; j++) {
                                    var s = states[j].state;     
                                    console.println("State:"+s);
                                }
                            } 
                            console.println("-----");
                        }
                        

                         

                        The results were:

                         

                        1
                        Type:Text
                        Text:master comment
                        Reply:false
                        -----
                        2
                        Type:Text
                        Text:reply to master comment
                        Reply:true
                        State:Marked
                        -----
                        3
                        Type:Text
                        Text:Marked set by Gilad
                        Reply:true
                        -----
                        

                         

                        As you can see there are now two "reply" annotations, one that has the actual text I added, and another one that contains an automatic text that is generated when you check the box.

                        The weird thing is that only the first one has its state set as "Marked"... Another weird thing is that if I delete the master comment and the reply, that third one still remains, even though the Comments list is now empty.

                        • 9. Re: Reading CheckMark State
                          kalabal Level 1

                          Now I see the problem in my code.

                           

                          Since the state="marked" can be seen in automatic generated check box text annotation in the .xfdf file, I tought that I need to read this state from that check box annotation, but it is still stored in the master comment.

                           

                          Thank you so much try67, everything is clear now. I am aware of the weird behaviour of this CheckBox. I gotta figure out a way to filter them in the script if the master comment is deleted.

                           

                          Regards

                          Emre