Simple update google sheet data

@TIMAI2
My dear,
I am Uploaded your aia file and change only 2 factor

  1. Sheet Script and Sheet ID
  2. Text box Name & Quantity

facing any problem?

@Spicy_Topics
I humbly request to you Please see my Above massage.
I am facings 2 problem.

  1. Update Record Not working
  2. Create New Record Not Working

when I click updateRecord or Create new button showing this massage. but Google sheet data not updated or not create new records. but When I click delete button This button are working, deleted data from Google sheet, & ReadAll Record Are working Properly.
What is the problem only for updating data?

I have tested my original project, the one I used to make the video. This still works fine, I can create and update records. There is nothing wrong with the script or the blocks with the spreadsheet data layout I have shown

You also changed the SHEETNAME (as seen in your blocks), and your spreadsheet is quite different.

You should start again, run a test using the data I supplied, if only to prove to yourself that everything works. Make a backup of your working project for reference.

Then change one thing at a time, testing as you go, until you find what it is you have changed that breaks things. My guess is your spreadsheet layout. Reorganise the columns so that they are in a similar order to my example data.

If any extra single text or comma or semi col added in the above scripts then it will report the bive error.

If possible share your script code..

Because unnoticed single hyphen will cost much

@Spicy_Topics

function doGet(e) {

var ss = SpreadsheetApp.openById(e.parameter.SHEETID);
var sh = ss.getSheetByName(e.parameter.SHEETNAME);
var rg = sh.getDataRange().getValues();


  //READ ALL RECORDS
  if ( e.parameter.FN == "ReadAll" ) {
    return ContentService.createTextOutput(JSON.stringify(rg)).setMimeType(ContentService.MimeType.JSON);
  }

  //READ SINGLE RECORD
   else if ( e.parameter.FN == "ReadRecord" ) {
    var ref = sh.getRange(parseInt(e.parameter.ROWID)+1,1,1,rg[0].length).getValues();
    return ContentService.createTextOutput(JSON.stringify(ref)).setMimeType(ContentService.MimeType.JSON);
  }
  
  //DELETE SINGLE RECORD
   else if ( e.parameter.FN == "Delete" ) {
    sh.deleteRow(parseInt(e.parameter.ROWID) + 1);  
    return ContentService.createTextOutput("Record Deleted");  
 } 

  //UPDATE SINGLE RECORD
   else if ( e.parameter.FN == "Update" ) { 
    var data = JSON.parse('[' + e.parameter.DATA + ']');
    sh.getRange(parseInt(e.parameter.ROWID) + 1,1,1,data[0].length).setValues(data);
    return ContentService.createTextOutput("Record Updated");
  }

  //CREATE NEW RECORD  
  else if ( e.parameter.FN == "Create" ) { 
    var data = JSON.parse(e.parameter.DATA);
    sh.appendRow(data);
    return ContentService.createTextOutput("New Record Appended");
  }

}

This is my Sheet Script. I am only Copy this Script from @TIMAI2 Simple CRUD with Google Sheets and Apps Script (fixes Hay Kel flaws...)
post And paste in my sheet.

Dear Sir, I Start again, I am just upload your aia file, Copy Script and pest my new Sheet, Change Script link, Sheet ID & Sheet Name Like as your sheet. But I facing Same Problem. ReadAll DataAnd Read Record only working But Update & Create new Data Not working show same error massage.

Have you correctly published your script, are you using the correct script Url, can the script be used by Anyone?

It is difficult to debug without access to / and full details of:

Your aia project
Your google apps script
Your spreadsheet

I will private message you with my working project, you can test that.

1 Like

Did you get it all working ?

What was the problem ?

yes All working Properly. Maybe Its My Mobile Network Problem. I Change my mobile For connect appinventor. Its Working Good. Thank you Everyone.
But I have need One More Help.
I want to edit Single Cell in my Google sheet. Like as I want to only "P2" or "R2" or.... Edit any single Cell in Sheet. Its Possible?

As mentioned in my PM

// enter A1 notation reference to write cell value
  else if ( fn == 'writeCell' ) {
    sh.getRange(e.parameter.REF).setValue(e.parameter.DATA);
    return ContentService.createTextOutput('Value: ' + e.parameter.DATA + ' written to cell ' + e.parameter.REF);
  }
2 Likes

Thanks @TIMAI2 For your Help. Dear @TIMAI2 I have need on your one more help.
It's possible to use this project are offline.

Example: When I will open this project Shows welcome massage is "Update your data from online" (yes/ No button )
If I will click Yes button then All data update to sheet & Collect Update data from sheet and store in my mobile.
If I click No Button then Apps do not update data & its show old data before click update button.

You will need to ensure that you store the "old data" to tinydb or other persistent local storage, and load this if you are offline.

Please tell me details how can I do this. And if it's possible please do this your project on this system.

If you want to save updates offline and consolidate them online, you will need to organize them as increments, like dollar withdrawals or deposits, and add those as rows to a transaction detail table.

Timestamp your transactions in TinyDB to avoid duplicate uploads.

@ABG Can you send any example with blocks?

On button click to save the details, just call whether the network is connected or not.

If connected send to gsheet
Else save into existing tinydb as a list
Once all stored clear the tinydb

Once net connected or screen init. Just call the data present in tinydb

If the data is empty list then no work
Else again push the data to gsheet then clear the tag

Very simple

1 Like

On further thought, you are asking for two contradictory things:

  • a simple approach
  • offline operation with catch up when online.

Even my Marathon examples gets complicated when I try to introduce offline data capture.

For example, when I register a new runner with a name and bar code, how am I to know if that runner has already registered with another bar code, without checking my sheet of runners and bar codes? I suppose I could have an offline copy, but what if another registrar has his own offline copy too, and they get out of sync? How do I check if that runner has registered at another registrar that has not yet uploaded his new runners?

If you want it simple, detect when you are offline and tell the user to come back later.

Dear @ABG Thanks for your suggestion. But I have Already completed my new project followed by @TIMAI2, Now I have need to Use this project offline. but I don't know how can I do this. @Spicy_Topics was reply to me its very simple but I don't understand how it's very simple, please Share any demo aia file or block.
@ABG
Its possible to give me Logging Marathon Runner Checkpoints in Google Sheets project demo .aia file?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.