Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 2 of 2

Thread: Error Saving Attachment by JavaScript in SC6.1

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Location
    Johannesburg
    Posts
    4

    Default Error Saving Attachment by JavaScript in SC6.1

    Howzit,
    Has anyone come up against this problem before. I am starting to think it may be a SpiderMonkey version problem but can't certain at this stage, since I have no way of determining said version. I am rambling... the code I am using is
    Code:
    function saveAttachment(app,topic) {
        var att = new SCFile("SYSATTACHMENTS");
        var rc = att.doSelect("application=\""+app+"\" and topic=\""+topic+"\"");
        if (rc == RC_SUCCESS) {
            var path = "d:\\temp\\"+att.filename;
            var binary = "b";
                    
            function getAttachmentByteString(strSCFile, strId, strUID)
            {
                var fAttachments = new SCFile("SYSATTACHMENTS");
                var rc = fAttachments.doSelect("application=\""+strSCFile+"\" and topic=\""+ strId  +"\" and uid=\""+strUID+"\"");
                var bCompressed;
                if( rc == RC_SUCCESS )
                {
                    var binaryStr = "";
                    rc = fAttachments.getFirst();
                    bCompressed = fAttachments.compressed;        
                    while( rc == RC_SUCCESS)
                    {
                        binaryStr += fAttachments.data;
                        rc = fAttachments.getNext();            
                    }
                }
                return bCompressed ? uncompress(binaryStr) : binaryStr;
            }
            
            var output = writeFile(path,binary,getAttachmentByteString(app,topic,att.uid));
            //print("The file written was: "+output+" large.");
        }
    }
    This code works like a charm on SC6.2 thanks to the getAttachmentByteString function from the KMUtils library in SC6.2. In SC6.1 this library function fails complaining about 'uncompress' being unrecognised.

    Any thoughts?

  2. #2

    Default

    Hello warrenf,

    do you have a solution for your Problem? I have related Problem! I want to add an attachment to the SYSATTACHMENT file.

    May be your solution could give me a hint!


    Thanks in advance!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts