Classic file types are no longer available for use as of January 2021. You can transition your classic files or download a PDF. Learn More

Run Chain via Button withing Spreadsheet

Answered
1

Comments

3 comments

  • Wade Hays

    Hi JP,

     

    I am actually working on a project that would provide this exact service. I'd be happy to share more when I get a little closer to launch.

     

    Wade

    --

    Wade Hays - https://towerturn.com/services/dedicated-expert 

    0
  • Andrew McKenzie

    JP Thomas - I would try something like the following:

    1. Put a Yes/No drop-down in a spreadsheet cell next to a field name like "Re-run [name of chain]?"
    2. Nearby, you could add a field to hold the timestamp of the last time this chain was run.
    3. Create a utility chain whose sole purpose is to retrieve a value from a particular sheet cell.
    4. Create another utility chain whose sole purpose is to update the value of a particular sheet cell.
    5. Add a node at the beginning of the chain you want users to be able to easily run where you will first call the utility chain to retrieve a value and get the value in the Yes/No "trigger" field returned from the sheet (i.e., step 1).
    6. Add nodes at the end of the chain to update the "trigger" field back to "No" (or whatever) and update the timestamp field in the sheet (the other field referenced in step 1).
    7. Add a conditional node following the first node to evaluate the value returned. If it's "Yes" then proceed with the rest of the chain. Otherwise, terminate the chain early.
    8. Schedule the chain you want to run to run every minute.

    I *think* that all of the above should work; I created a chain a while back that used a very similar pattern, although there were a few differences. For example, in my version of step 3, the data I wanted read in the sheet was highly structured, so I had actually used an SQL query to ID the values of interest for me. But I believe you can just use Get Sheet Data to get this.

    A few notes:

    • Depending on your approach, if you're worried about people mucking with your trigger field, you might have to lock down the sheet where this is located and/or have a second sheet (fully locked down) that references the field via a formula. This could reduce brittleness if people e.g. add rows to the sheet where your trigger is located since you may be using something as simple as a column:row ID to pull the trigger value.
    • For step #4 above, I did something a bit different, so I was writing values in a certain sheet that were referenced by a lookup on the sheet where the "trigger" occurred. The reason for this was that, depending on how the sheet where the trigger is located is being used, you have to be super careful writing data back to a sheet as you could easily overwrite existing data or user input. For me, it was easier (or necessary? I can't remember the details) to have the chain write back data in its very own sheet that users didn't have access to and then use lookups to pull relevant values back into other sheets.
    • Ideally, you could add further nodes at the start of the chain to check whether the spreadsheet has been updated since the last time the chain was run. This way, if the spreadsheet hasn't even been modified, you can instantly exit the chain; if the spreadsheet *has* been modified, you can then proceed to check if that particular "trigger" value has been updated.

    Hope the above is all clear. I know a similar approach has been used by other organizations in patterns I've seen, although I don't know details on the implementation. But I'm also interested because maybe there is a far better way of doing this....

    0
  • JP Thomas

    Andrew McKenzie Thanks for this detailed write up. I knew the best approach was probably something along these lines but I had  not even attempted to create the utility chains you mentioned. This gives a clear picture and I will try this approach. I agree that it is probably the best option we have right now.

    0

Please sign in to leave a comment.