Hi AppSheet Community,
Im encountering an issue with a webhook data action in my AppSheet app. When I trigger a webhook to update certain fields in my table, I receive the following error:
Error encountered in step with name [New step]: Error: ‘Set Column Values’ Data action ‘‘Set Column Values’ Data action ‘New step Action - 1’’ failed with exception ‘Set Column Values’ Data action ‘New step Action - 1’ failed because field ‘[Field Name]’ in table ‘[Table Name]’ could not be computed due to exception Error: Failed Webhook type translation: Conversion error.
The fields that I’m trying to update are of the Price type. The webhook successfully triggers a Google Apps Script function, which processes an image and returns a JSON response. However, it seems there’s an issue with converting the returned data to the Price type fields in AppSheet.
Here is the structure of my webhook response:
{ “Field1”: 468, “Field2”: 60, “Field3”: 9565, “Field4”: 273, “Field5”: 30, “Field6”: 5870, “NetSales”: 575.6 }
Each field in the response is intended to update a corresponding Price type field in my table.
Has anyone encountered a similar issue, or does anyone have suggestions on how to resolve this conversion error? Any help would be greatly appreciated.
EDITED: Note I successfully updated a price column [c_price] with the expression [Step 01].[a] + [Step 01].[b] which totals to 30. with the above setting.
I would assume your data needs to be formatted in the same way Google formats currency before it is returned in the JSON response. Clark over in this Groups thread shows how to do the formatting in GAS. Not sure if this will fix it, but it’s where I would start.
Well , that requires license for Appsheet Core , which I dont have yet.
However i have a few apps script runinng from webhook , without any issues , but did not return a value yet to Appsheet.
thanks , not sure how to implement it on appsheet.
I tried adding the row number only on http headers and then figure all the rest from there , but seems like apps script is not getting it.
function doPost(e) {
let cache = CacheService.getScriptCache();
cache.put('postData', e.postData.contents);
return true; // this does not matter cause no return value is used from the POST step
}
function doGet(e) {
let cache = CacheService.getScriptCache();
const output = ContentService.createTextOutput(cache.get('postData')); //here the content of the cache is read
output.setMimeType(ContentService.MimeType.JSON);
return output
}
As far as I understand, you cannot call a webhook endpoint that requires redirect, as the App Sheet will not follow redirects. Unfortunately, that rules out Apps Script get/post endpoints.