Topic
  • 10 replies
  • Latest Post - ‏2013-02-27T08:37:02Z by SystemAdmin
raghava1239
raghava1239
35 Posts

Pinned topic getting filename from Document attatchment control

‏2012-03-29T13:16:01Z |
hi friends,
can we bind variable to document attatchment control,bcoz i have requirement to capture the file name when the document is attatched
regards,
raghava
Updated on 2013-02-27T08:37:02Z at 2013-02-27T08:37:02Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-29T13:29:51Z  
    Raghava,

    Please provide more details like you need the name on the same coach where document attachment control is used or later in some nested activity. Assuming that you need the name afterwards, you can use the tw.system.currentProcessInstance.documents javascript api and use name attribute of TWDocument. The TWDocument has a modificationDate attribute also which you can use to identify the latest added document.

    If you need the name on the same coach to show something else, please do view source of the coach and check the id field of the table row where document is getting added and use dojo to read the value.

    Hope this helps

    Regards,
    Manish
  • raghava1239
    raghava1239
    35 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-29T15:04:42Z  
    Raghava,

    Please provide more details like you need the name on the same coach where document attachment control is used or later in some nested activity. Assuming that you need the name afterwards, you can use the tw.system.currentProcessInstance.documents javascript api and use name attribute of TWDocument. The TWDocument has a modificationDate attribute also which you can use to identify the latest added document.

    If you need the name on the same coach to show something else, please do view source of the coach and check the id field of the table row where document is getting added and use dojo to read the value.

    Hope this helps

    Regards,
    Manish
    thanks manish, its working :-)
  • LuisTiago
    LuisTiago
    11 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-29T19:43:03Z  
    thanks manish, its working :-)
    have exemple for this? i try this but recive a error: TypeError: Cannot read property "documents" from null
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-29T19:55:28Z  
    • LuisTiago
    • ‏2012-03-29T19:43:03Z
    have exemple for this? i try this but recive a error: TypeError: Cannot read property "documents" from null
    LuisTiago,

    This option will only work for a running on a processinstance. For non-task activity, you can set a hidden variable on coach and use the method tw.system.findDocumentByID

    http://wiki.lombardi.com/display/tw7/tw.system.findDocumentByID

    Hope this helps
    Manish
  • LuisTiago
    LuisTiago
    11 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-29T20:24:21Z  
    LuisTiago,

    This option will only work for a running on a processinstance. For non-task activity, you can set a hidden variable on coach and use the method tw.system.findDocumentByID

    http://wiki.lombardi.com/display/tw7/tw.system.findDocumentByID

    Hope this helps
    Manish
    the document dont have a bind to variable, how i can do it? what type of hidden variable? how i can bind my document to this variable?
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-30T15:32:38Z  
    • LuisTiago
    • ‏2012-03-29T20:24:21Z
    the document dont have a bind to variable, how i can do it? what type of hidden variable? how i can bind my document to this variable?
    LuisTiago,

    Sorry for the delay. My understanding of the document attachment was wrong of assuming it is saved in the filesystem and I will be able to get the filepath from TWDocument object. It is actually directly saved in DB and I am working on a POC to read it from the table.

    As per your question about getting the document id, below is one way of doing it. There may be better and cleaner way of getting the id.
    You can call this in the validation script of any button or any other way.

    var table = document.getElementById("control0");
    var href = table.getElementsByTagName("tr")[1].getElementsByTagName("td")[1].innerHTML;
    var index = href.split("docId=");
    document.getElementById("InputText0").value = index[1].substring(0,1);
    return true;

    Then you can use the document id received and get all the details of the document using
    var doc = tw.system.findDocumentByID(tw.local.documentId);
    tw.local.docName = doc.name;

    Hope this helps,
    Manish
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-30T16:27:47Z  
    LuisTiago,

    Sorry for the delay. My understanding of the document attachment was wrong of assuming it is saved in the filesystem and I will be able to get the filepath from TWDocument object. It is actually directly saved in DB and I am working on a POC to read it from the table.

    As per your question about getting the document id, below is one way of doing it. There may be better and cleaner way of getting the id.
    You can call this in the validation script of any button or any other way.

    var table = document.getElementById("control0");
    var href = table.getElementsByTagName("tr")[1].getElementsByTagName("td")[1].innerHTML;
    var index = href.split("docId=");
    document.getElementById("InputText0").value = index[1].substring(0,1);
    return true;

    Then you can use the document id received and get all the details of the document using
    var doc = tw.system.findDocumentByID(tw.local.documentId);
    tw.local.docName = doc.name;

    Hope this helps,
    Manish
    LuisTiago,

    Attached is the example of getting the contents of the Document attachment as string. As I mentioned before, this is one way of doing it and there may be better ways of doing this. Also currently I have developed for 1 attachment in the upload coach and you can enhance this to read all attached documents. The import is for v7.5.1

    Hope this helps
    Manish
  • LuisTiago
    LuisTiago
    11 Posts

    Re: getting filename from Document attatchment control

    ‏2012-03-30T20:06:06Z  
    LuisTiago,

    Attached is the example of getting the contents of the Document attachment as string. As I mentioned before, this is one way of doing it and there may be better ways of doing this. Also currently I have developed for 1 attachment in the upload coach and you can enhance this to read all attached documents. The import is for v7.5.1

    Hope this helps
    Manish
    Thanks Manish you save my work. :-)
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: getting filename from Document attatchment control

    ‏2013-02-27T08:33:11Z  
    • LuisTiago
    • ‏2012-03-30T20:06:06Z
    Thanks Manish you save my work. :-)
    Hello,

    I am trying to upload a document to the repository. If the upload fails, it creates a new instance to upload the document some later point of time.But the document remains attached to the first instance ID.

    Later when I upload the document through a newly created instance, I succed.
    But for the previous instance I want to delete the document from the process DB .

    I am using tw.system.findDocumentByID(String documentID) to find the same document from the process DB.
    Its giving the following error " Internal Script error: com.lombardisoftware.core.TeamWorksException: Bad long value as document Id "
  • SystemAdmin
    SystemAdmin
    7615 Posts

    Re: getting filename from Document attatchment control

    ‏2013-02-27T08:37:02Z  
    LuisTiago,

    Attached is the example of getting the contents of the Document attachment as string. As I mentioned before, this is one way of doing it and there may be better ways of doing this. Also currently I have developed for 1 attachment in the upload coach and you can enhance this to read all attached documents. The import is for v7.5.1

    Hope this helps
    Manish
    Hello,

    I am trying to upload a document to the repository. If the upload fails, it creates a new instance to upload the document some later point of time.But the document remains attached to the first instance ID.

    Later when I upload the document through a newly created instance, I succed.
    But for the previous instance I want to delete the document from the process DB .

    I am using tw.system.findDocumentByID(String documentID) to find the same document from the process DB.
    Its giving the following error " Internal Script error: com.lombardisoftware.core.TeamWorksException: Bad long value as document