Jump to content

Clear Paragraph Element for Updated JSON


Recommended Posts

I have a timer trigger function...

function createTimeDrivenTriggers() {  // Trigger every 1 hour.  ScriptApp.newTrigger('createDoc')      .timeBased()      .everyHours(1)      .create();}

that calls createDoc function, which inserts JSON to paragraph:

  parasub = body.insertParagraph(3, "Subscribers: " + viewsb);  paraview = body.insertParagraph(4, "Total Views: " + views);

So every hour I'm getting 2 new paragraphs/lines added to the doc. Instead, I need to have the previous paragraphs cleared, so that only the latest JSON data shows. I'm trying to use clear() function, but if I put it above parasub/paraview, clear() is undefined, and if I put it below parasub/paraview, the data is deleted. That all makes sense. So how to clear previous parasub/paraview content before inserting new data?

  parasub.clear();   paraview.clear(); 


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...