Comments

  • Patricia Harvath

    From my email archive:

    The contents of the file are dynamic, so I don't know how to answer your question.  The 'contents' of these files is the word TEXT.  How do you strip a file of it's content?
    
    My apologies if this should be evident.
    
  • Patricia Harvath

    From my email archive:

                                                                $fp = $fa->makeFile();
    
                                                                $fp = "test.doc";
    
                                        //                      fwrite( $fp, __FUNCTION__ );
    
                                                                fclose( $fp );
    
    Like that?  I get error:
    
     'RightNow\Connect\v1_2\ConnectAPIError' with message 'Minimum file size is 1 byte'
    
  • Patricia Harvath

    From my received email:

    Allan,
    
    You are the BEST!  Thanks for helping!!
    
    Ok, so what do you mean by 'real file contents?'
    
  • Patricia Harvath

    "Word cannot start the converter mswrd632.wpc"

    Adobe Reader could not open "test"_F634.pdf" because it is either not a supported file type or because the file has been damaged.

  • Patricia Harvath

    $mime_types = array(
                'txt' => 'text/plain',
                'pdf' => 'application/pdf',
                'doc' => 'application/msword',
                'xls' => 'application/vnd.ms-excel');

    if($fileName){
                        $idata->FileAttachments = new RNCPHP\FileAttachmentIncidentArray();
                        $fa = new RNCPHP\FileAttachmentIncident();        

                        $fp = $fa->makeFile();
                        fwrite( $fp, __FUNCTION__ );
                        fclose( $fp );                
                        
                            $ext = strtolower(array_pop(explode('.',$fileName)));
                            if (array_key_exists($ext, $mime_types)) {
                                $fa_mime = $mime_types[$ext];
                            }
                            elseif (function_exists('finfo_open')) {
                                $finfo = finfo_open(FILEINFO_MIME);
                                $mimetype = finfo_file($finfo, $fileName);
                                finfo_close($finfo);
                                $fa_mime = $mimetype;
                            }
                            else {
                                $fa_mime = 'application/octet-stream';
                            }
                            
                        $fa->ContentType = $fa_mime;
                        $fa->FileName= $fileName;
                        $idata->FileAttachments[] = $fa;    
                    }

    So, I am trying to catch probable mime types.  But this doesn't work either.  In Chrome, the request payload shows as :

    ------WebKitFormBoundaryNDiZ8si3vmYoFn5t Content-Disposition: form-data; name="file"; filename="TEST.doc" Content-Type: application/msword

    and the Preview is:

    {"name":"TEST.doc","type":"application\/msword","tmp_name":"TeA1kD.custhelp.com","error":0,"size":19968}


    Thanks once again for your help!!!

     

     

  • Patricia Harvath

    I just tried a PDF and a Word doc.  I got corrupt messages on these too.

    Any idea what could be causing that?

     

  • Patricia Harvath

    Thanks Alan.  I don't have much experience with MAGIC constants...

    I got the file to upload and that worked great!

    What file extensions are supported?  We need to be able to upload excel spreadsheets and when I download it from the RN console and try to open it, I get an error that the file extension might not be valid.

     

    Here's my code that worked:

    if($fileName){
                        $idata->FileAttachments = new RNCPHP\FileAttachmentIncidentArray();
                        $fa = new RNCPHP\FileAttachmentIncident();
                        $fa->ContentType = "text/plain";
                        $fp = $fa->makeFile();
                        fwrite( $fp, __FUNCTION__ );
                        fclose( $fp );
                        $fa->ContentType = "text/plain";
                        $fa->FileName= $fileName;
                        $idata->FileAttachments[] = $fa;    
                    }

  • Patricia Harvath

    Nothing is in the tmp folder

  • Patricia Harvath

    Ryan,

    Thanks for your help.  I see what I did and the code you provided works perfectly.

    A couple quick questions regarding File Attachments:

    When dealing with CO and file attachments what are the best practices for associating the files?  I had this attachment related to the incident because I had nothing to go on to indicate it should be related to the CO. 

    If the attacment is related to the incident, what happens to it if I delete the incident?  If the attachment is related to the CO, what happens to it if I delete the CO?

    How do I delete files that were attached to old incidents?  Where are they stored? 

    Once again, I appreciate your help.

    Thanks,
    Patricia

  • Patricia Harvath

    No one knows the best practices for File Attachments?  Should it be associated with the incident or the CO?

  • Patricia Harvath

    Thanks Tracy.  I will check it out.  I've used Hooks before, but not with a non-widget items.  I'll let you know how it all works out.

  • Patricia Harvath

    Hi Tracy,

    In the end, as long as the fields are concatenated into the thread, I don't care if it is done before the incident is created, or after.  I just assumed it would be easier to do before it was created.

    Thanks,

    Patricia

     

     

  • Patricia Harvath

    Sorry, I was trying several different things and in the end, I got my code switched.  I am doing an ajax call in javascript :

    Here's the javascript:
    function conNotes(notes){
        
        var notes = document.getElementById("notes").value;    
            $.ajax({
                            type: "POST",
                            url: "/ci/ajaxCustom/conNotes",
                            cache: false,
                            data: "notes="+notes,
                            success: function myInfo(data){
                            alert(data);
                            }
            });
        
        }

     PHP:
    function conNotes()
        {
          
            $data = json_decode($this->input->post('form'));       
            $notes = $this->input->post('notes');
            
            echo json_encode($notes);
        }  

    $combineNotes = $_GET['notes'];

     

    And I get an alert when I fill in the input field.

    <label>Notes</label>
          <input name="notes" type="text" id="notes" onblur="conNotes()"/>

     

    Now I would like to grab the 'notes' variable and add it as the default value for the input/FormInput widget. 

     <rn:widget path="input/FormInput" name="incidents.thread" table="incidents" label_input="Notes" default_value="#rn:php:$combineNotes#" />

     

    This doesn't work.  Is that because the value $combineNotes is already set by the time I do the ajax call?

     

    Thanks again!

  • Patricia Harvath

    Currently, I have two input fields:

    <label>Notes</label>
          <input name="notes" type="text" id="notes" onblur="conNotes()"/>
    <label>RA</label>
          <input name="ra" type="text" id="ra" onblur="conRA()" />

    that send a response via a json:

     function conNotes()
        {
          $data = json_decode($this->input->post('form'));      
          $notes = $this->input->post('notes');       
          echo json_encode($notes);
        }    
            
        function conRA()
        {   
            $data = json_decode($this->input->post('form')); 
            $ra = $this->input->post('ra');               
            echo json_encode($ra);
        }  
     

    The next step is concatenate the fields?  And how do I slip that info into the incident as a thread?

  • Patricia Harvath

    Thank you!