This topic contains 3 replies, has 0 voices, and was last updated by david.smith 7 years, 4 months ago.

  • Author
    Posts
  • #5824 Score: 0

    k_dunc
    • Contributions: 0
    • Level 1

    Hi all,

    I’m trying to allow an Employee Centre user to view a file from the File Cabinet whereby the Employee Centre role has no File Cabinet permissions. Because of payroll, we are unable to set Employee Centre users up with the File Cabinet permissions, so I was hoping that through a Suitelet (set to run as Administrator), I could allow given Employees to see certain files. I’m running into a couple of issues: I can’t really run a File search. I have used the undocumented (and perhaps risky) ‘nlapiSearchRecord(‘file’…)’ search, so that’s okay for now.
    So I have the file’s URL in my Suitelet, but I cannot seem to open the file to view (i.e. preview) in Employee Centre. It works just fine for Full Access users.

    Is there a way I can get around this such that they can see the file? Note also, all files are NOT ‘available without login’.

    Thanks in advance,

    Kirk.
    This is a cached copy. Click here to see the original post.

  • #5825 Score: 0

    david.smith
    • Contributions: 0
    • Level 1

    I’ve used the search for files in my solutions before. I think that’s OK.

    If you want them to just be able to see the list, use your search to display on screen of your suitelet. Run your suitelet deployment as admin. When they click on the file they want to look at, load the file, get the contents and send it back to them as a download.

  • #5826 Score: 0

    k_dunc
    • Contributions: 0
    • Level 1

    Thanks David. Appreciate that. Yes, I certainly need the ability for the user to view the file contents, not a list.

    So to make this work, what do I pass back to the Suitelet, or rather, what should my Suitelet actually do? Clearly I’m able to get the URL of the file I need, but simply passing the URL to the user still does not allow them to open the file to view its contents. So how do I physically achieve that, and must I do something different for each file type that could be used (e.g., TXT, Word, Excel, PDF etc.)?

    Thanks again.

  • #5827 Score: 0

    david.smith
    • Contributions: 0
    • Level 1

    Code:
    // set content type, file name, and content-disposition (inline means display in browser)
    response.setContentType(‘PDF’,’Pricing List.pdf’, ‘inline’);

    // write response to the client
    response.write( file.getValue() );
    setContentType(type, name, disposition)

    Sets the content type for the custom responses (and an optional file name for binary output). This API is available in Suitelet scripts only. Parameters

    type {string} [required] – The content/file type. For a list of supported file types, see Supported File Types in the NetSuite Help Center.
    name {string} [optional] – Set the name of the file being downloaded (for example ‘name.pdf’)
    disposition {string} [optional] – Content disposition to use for file downloads. Available values are inline or attachment. If a value is not specified, the parameter will default to attachment. What this means is that instead of a new browser (or Acrobat) launching and rendering the content, you will instead be asked if you want to download and Save the file.


    k_dunc replied on 05/18/2017, 12:32 AM: I got this working David. Really appreciate your input. Well done, and thanks for helping out.

You must be logged in to reply to this topic.