ashtonfei / google-apps-script-projects

My Google Apps Script projects shared on YouTube.
https://youtube.com/ashtonfei/
100 stars 49 forks source link

[GAS-070] Error _onFormSubmit when have the new request #2

Open tuanngocptn opened 1 year ago

tuanngocptn commented 1 year ago

Hello I have some problem when running on GAS-070 (https://github.com/ashtonfei/google-apps-script-projects/tree/GAS-070). . Some user missing additional value like _uid, _status, _response_id, _approver_1, _approver_2.

So I found the reason. Sometimes, the additional value inserted wrong area. That inserted in the before line.

image

Like the image above UID-00059 must fill in the next line. But it replace the UID-00058 area.

That will make some error of system when we run the application in flow.

Thanks for read. And hope that will fix soon.

tuanngocptn commented 1 year ago

Hello @ashtonfei. Did you read this issue. Thanks

ashtonfei commented 1 year ago

@tuanngocptn Is it always replace the line above the actual response line? If it only happens to some responses, we'll need more investigation.

tuanngocptn commented 1 year ago

Hello Ashtonfei I'm apply this form for my team. And hope that will fix soon. Thanks @ashtonfei for response.

ashtonfei commented 1 year ago

@tuanngocptn Were the responses 58 and 59 submitted very closely? Like almost the same time?

tuanngocptn commented 1 year ago

This problem happens quite often.

image

.

.

And this is error is showing on the Executions report.

image

Thanks @ashtonfei

tuanngocptn commented 1 year ago

Nope. I don't think so, Cus I checked in the timestamp column. Most of them are not in the same time.

image
ashtonfei commented 1 year ago

I updated the onOpen function to fix the permission issue on creating triggers. You will need to install the trigger manually.

function onOpen() {
  // const trigger = createTrigger(); // removed
  const ui = FormApp.getUi();
  const menu = ui.createMenu("Approval");
  menu.addItem("Reset UID", "resetUid");
  menu.addItem("Install trigger", "createTrigger"); // added
  menu.addToUi();
}
tuanngocptn commented 1 year ago

I updated the onOpen function to fix the permission issue on creating triggers. You will need to install the trigger manually.

function onOpen() {
  // const trigger = createTrigger(); // removed
  const ui = FormApp.getUi();
  const menu = ui.createMenu("Approval");
  menu.addItem("Reset UID", "resetUid");
  menu.addItem("Install trigger", "createTrigger"); // added
  menu.addToUi();
}

Hello.

I just added this trigger after changed the code.

image

I will send you the result after several days.

Really thanks @ashtonfei

tuanngocptn commented 1 year ago

Hi @ashtonfei

after several day running.

Seem like problem still there

Do you have any idea for fix that.

image

Thanks

tuanngocptn commented 1 year ago

Hello @ashtonfei. Are you still following this issue. Thanks

ashtonfei commented 1 year ago

@tuanngocptn I checked the code, I think there is a defect with the logic in my original design that the script is always checking the last row when there is a submission. Is response edit allowed in your form? In current logic, the response edit could trigger the script to overwrite the last row in the sheet.

tuanngocptn commented 1 year ago

@tuanngocptn I checked the code, I think there is a defect with the logic in my original design that the script is always checking the last row when there is a submission. Is response edit allowed in your form? In current logic, the response edit could trigger the script to overwrite the last row in the sheet.

Hello @ashtonfei

Is response edit allowed in your form? => sorry I don't get the point of this question. I just configure like your video in youtube.

I think there is a defect with the logic in my original design that the script is always checking the last row when there is a submission => Can we change to update by timestamp column instead of "last row". I think timestamp column is unique column now.

Thanks

ashtonfei commented 1 year ago

If form response edit is enabled, we have will have the issue on the last row when an edit submission happens. We'll need to change the trigger to Spreadsheet On Form Submit, in this type of trigger, we can access the row number which the response is saved to.

image
tuanngocptn commented 1 year ago

I just checked the Responses setting and It all have off already before. Seem like that is not the core problem As you mention we need to change the trigger. For updating exactly the row. So, Can I help you for do something? For dealing with this problem faster. Thanks @ashtonfei

prateek21865 commented 1 month ago

Hey @ashtonfei I want to import some other data from a sheet1 which is in the same spreadsheet having form responses 1. I want add 2 -3 data values in the task object. What I have to do.. please suggest me..and after approving the email the data gets reflected to that sheet only where the data is been Imported...