Forum Discussion

MeganLatulippe's avatar
MeganLatulippe
Qrew Trainee
6 years ago

File Attachments, Documents, Fields

I'm trying to figure out a script to copy files from table that are associated with a certain description to the other table that is linked to said description. I already have an automation  set to copy the record made in table 1 to the designated user in table 2 but Quickbase doesn't have the feature available for having file attachments copies over. 
I found this script from user _anomdiebolt   https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=574

Here:
 https://community.quickbase.com/communities/community-home/digestviewer/viewthread?MessageKey=db2c28cd-0b87-47dd-afb0-b7f2ff474ea1&CommunityKey=d860b0f8-6a48-487b-b346-44c47a19a804&tab=digestviewer

but whenever I enter my information into the script I get this: 
Saying "Invalid Expression" note * This image was posted by another user who had the same exact script problem as me but it was unanswered.
Does anyone know how to fix the script or another script I could use 


------------------------------
Me
------------------------------
  • There is much easier syntax to create a link to the original file which is clickable to view/download. 


    Would that work for you?



    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------
    • MeganLatulippe's avatar
      MeganLatulippe
      Qrew Trainee
      Would there be a way to make that link available to only the user that it is assigned to ? I work for in insurance sales so the app I'm building is for the backend to put in the lead inventory and "assign" them to agents. The lead inventory would be the files, and the files can only be viewed by the agents they are assigned to for security reasons. I'm sorry I'm awful as describing things.

      ------------------------------
      Workingforagents
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        Yes, the link is a formula, so it can have an IF Statement in the formula to only show the formula for users in certain Roles or the user assigned to that record.

        for example

        URLRoot() & "up/" & [_DBID_PROJECTS] & "/a/r" & [Related project] & "/e30/v0"

        The above formula would be a link to the most current (version 0) file attachment stored in field ID# 30 on the record ID# of [Related Project] in the Projects table.

        I suggest that you get that working first and then work on a IF to limit to where the user is Aassigned to the record.

        You can also make use of the new UserRoles() function to detect what Roles the Current User is in, so that higher level Roles are unrestricted.

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        markshnier2@gmail.com
        ------------------------------
  • AustinK's avatar
    AustinK
    Qrew Commander
    Where are you trying to use that code that it is giving you that error? From what I'm reading in the post you linked that script is something to just put into the console and run but it kind of looks like you have in in a native QuickBase field. 
    • MeganLatulippe's avatar
      MeganLatulippe
      Qrew Trainee
      Oh my God, I can't believe I didn't notice it needed to put into the console. You're right, I was putting it in a field !  Another dumb question ( I'm incredibly new to API all around) How do I enter it into the console? I'm not sure where the console is in Quickbooks .

      ------------------------------
      Workingforagents
      ------------------------------
      • AustinK's avatar
        AustinK
        Qrew Commander
        It is referring to the console of the browser you are using. So in Chrome you would hit f12 and you get access to the developers console in the window that opens.

        A word of warning though. Make sure you fully understand what a piece of code is going to do before running it. I don't mean read what the people posting it say it does, but understand the code itself. The people on this forum are generally pretty good and I would say anything Dan Diebolt posts or has on his QuickBase reference pages is legit and will not harm your records. However, sometimes the code is old and doesn't work exactly as you would expect it to or things have changed over the years. So it is still a good idea to at the very least test the code on a copy of the app that you make. That way you are not going to cause a big problem if it fails.

        If you cannot get it to work or are not great with code you can always explore the way QuickBase Coach said he could do it. They generally prefer more native solutions so if you want to do it without code they can get you there.