Using JavaScript, is there a way to get the version of the document being edited when you have a topic open in Create?

Using JavaScript, is there a way to get the version of the document being edited when you have a topic open in Create? We have code that requires the topic version.

Parents
  • Yes, this should be possible. The document contains a processing-instruction with this information. You can retrieve this for example in the following way:

    function getVersion(doc) {
      if (!doc) return false;
      var ish = doc.selectSingleNode("processing-instruction('ish')");
      if (!ish) return false;
      var result = ish.getTextContent().match("version=\"(.*?)\"");
      if (!result || result.length < 2) return false;
      return result[1];
    }
    
    getVersion(Editor.getActiveDocument());

     

Reply
  • Yes, this should be possible. The document contains a processing-instruction with this information. You can retrieve this for example in the following way:

    function getVersion(doc) {
      if (!doc) return false;
      var ish = doc.selectSingleNode("processing-instruction('ish')");
      if (!ish) return false;
      var result = ish.getTextContent().match("version=\"(.*?)\"");
      if (!result || result.length < 2) return false;
      return result[1];
    }
    
    getVersion(Editor.getActiveDocument());

     

Children