I've been struggling with performance issues due to using a spreadsheet formula that makes an API call to the NHTSA database to retrieve VIN information on a vehicle and populates in the app to provide techs in the field with vin decoding services used in automotive diagnostics, invoice document generation, as well as automated email to our clients.
The current system is working as designed but I did not account for the cost of processing using spreadsheet formulas opposed to virtual columns and AppSheet formulas.
Everything works fine until {{VIN}} reaches about [50] rows or so then the {{VIN}} bottlenecks and the API formulas populate {{CELL}} with "Loading..." on random rows of {{VIN}} causing blank output in the app due to every time one of our (8) technicians are actively syncing the app, multiple times a day, the spreadsheet formula is calling out (50) VIN#'s every sync and if (3) techs sync at the same time that's (150) api calls at once being made to the API causing cells in {{VIN}} not populate or display the Return Response in the Sheet or the App.
I setup a bot to delete finalized tickets once a week to maintain the sheets to stay around (50) rows but when the lines are deleted from {{SERVICE}} it deletes the {{CELL}} formulas as well and the AutoFill feature creates a referencing nightmare due to it not updating the cell references to append from to the new order of the rows.
Find an App Script function that can be called to accommodate the API Call and Return the .csv values from the API response by appending the results to [VIN] and using AppSheet reference formulas to display in the app.
I use a mirror column to keep {{VIN}} in sync with {{SERVICE}} so that any time a row is deleted or finalized and/or archived it will remove the row from {{SERVICE}} and the row with matching [_row_number] from {{VIN}}.
[START]
EVENT: A VIN Barcode is scanned in the app using form and Submitted
PROCESS:
Any help or direction on converting, and/or provisioning, an economical workaround would be greatly appreciated.
Spreadsheet
=IF(NOT(ISBLANK(${T}!${C}), QUERY(IMPORTDATA("https://vpic.nhtsa.dot.gov/api/vehicles/decodevinvalues/" & ${T}!${C} & "?format=csv"), "SELECT * OFFSET 1", 0), "")
AppSheet
IF(NOT(ISBLANK(${T}!RC[8])), QUERY(IMPORTDATA("https://vpic.nhtsa.dot.gov/api/vehicles/decodevinvalues/" & ${T}!RC[8] & "?format=csv"), "SELECT * OFFSET 1", 0), "")
Spreadsheet
=ARRAY_CONSTRAIN(ARRAYFORMULA(IF(NOT(ISBLANK(${T}!${C})), ROW(${C})-1, "")), 1, 1)
AppSheet
=ArrayFormula(IF(NOT(ISBLANK(${T}!RC[9])), ROW(RC)-1, ""))
Spreadsheet
=IF(NOT(ISBLANK(${T}!${C})),CELL("CONTENTS", ${T}!${C}), "")
AppSheet
APPENDVINFO(VINDecoder!RC[-7]),//[VID] (Ref)
APPENDVINFO(VINDecoder!RC[-7]),//[VinID] (Number)
APPENDVINFO(VINDecoder!RC[16]),//[Year] (Number)
APPENDVINFO(VINDecoder!RC[12]),//[Make] (Text)
APPENDVINFO(VINDecoder!RC[13])//[Model] (Text)
Solved! Go to Solution.
@jdtyler-dev wrote:
WOW nothing? man i figured at least one person would take a crack at it
Your question is too long to read ๐
You may want to simplify it and focus on one step at a time. We all volunteers in helping here, and that means we want to understand quickly and help you quickly as well.
I didn't took the time to read it thoroughly, but basically, here is what I can tell:
1) if you are using ARRAYFORMULA is your Sheets ==> forget about it and use AppSheet expression indeed. You may benefit from using virtual columns in some cases.
For reference:
Use virtual columns - AppSheet Help
Expressions: The Essentials - AppSheet Help
2) You may have to consider changing your data structure if you have too many complex expressions.
3) for query expression, you may benefit from using Slices. This is the AppSheet equivalent of a SQL View.
For reference:Slices: The Essentials - AppSheet Help
4) When regenerating a table structure from a datasource on Google Sheets, formula expressions are written automatically in the Formula field. Normally you don't have to figure a way to translate an expression from Sheets to AppSheet if you use formulas in every cell of your Sheets. AppSheet recognizes it, and copy it the same way using RC references.
EDIT: please remember I didn't take time to read your whole post thoroughly, my apologies in advance.
For consideration, you may want to read this: Guide on How To Create a Community Post - Google Cloud Community
Have you told your bot that your appscript function is returning an Object or a Text?
If it's an object, then you will get the value for each cell by using [decodeVIN].[ObjectValue] where [ObjectValue] will be one of the headers in your returned object.
{Fieldname1:"A value",
Fieldname2:"A value",
Fieldname3:"A value"...}
In your Appscript that returns a CSV list back to you, do the following
Convert the CSV to an array.
myArray = csvtext.split(",")
Then place the array values into an object which is named accordingly to their contents.
const appsheetobject = {fieldname1:myArray[0],fieldname2:myArray[1],fieldname3:myArray[2]}
finally at the end of your script, return the object you have constructed from the csv array
return appsheetobject;
In Appsheet you can then get those values by using your [decodeVIN].[fieldname1] etc
That's great!
So your text string is now delimitted with a comma space so you can split like this
const myValues = myString.split(", ")
You will then be able to build your object
const returnToAppsheet = {fieldname1:myValues[0],fieldname2:myValues[1]...etc}
Then your final line of script to pass back to appsheet
return returnToAppsheet
All as before...and hopefully....you can pick those values up and write them to your VIN table and trigger other bots to do various things.
SUCCESS!!!
was super tedious adding formulas for 2 x 121 return values in appsheet but it worked. one set to define the return object and one set to add data to row after return was received but IT WORKED! app is running super fast, no spreadsheet formulas used, THANK every1 that took the time to assist me on this despite its complex nature. I intend on adding collaborators section of the tips and tricks guide i will be making shortly to show how to create integrate a free, process friendly, fully automated vin decoder in your appsheet application. My way of giving back to the community that helped me through this learning experience.
That's great!
So your text string is now delimitted with a comma space so you can split like this
const myValues = myString.split(", ")
You will then be able to build your object
const returnToAppsheet = {fieldname1:myValues[0],fieldname2:myValues[1]...etc}
Then your final line of script to pass back to appsheet
return returnToAppsheet
All as before...and hopefully....you can pick those values up and write them to your VIN table and trigger other bots to do various things.
so would the output im looking for be like this?
User | Count |
---|---|
44 | |
31 | |
29 | |
14 | |
14 |