Wednesday, 15 July 2015

javascript - Troubleshoot script to maintaining/updating Google Calendar with Google Spreadsheet including automatically changing colors -


I am trying to write Google app scripts to complete the following:

  • Update a Google Calendar based on a few columns in a Google Spreadsheet that indicates:

  • a what event has a specified date (column "date"! = "")

  • b. Whether that event has already been posted to the calendar ("in column" "column" = "").
  • Once the event has been added to the calendar, then I want to add "Yes" to the column spreadsheet ("Columns" in the column).
  • If possible, the color of the event automatically changes based on the attributes in a particular column (i.e. if "state" = NM column, then the color of the event is blue, if "state "= MT, then the color of the event is purple, etc.)

I have seen various postings (mainly and) on the web,

I have the following script Has been hobbled with:

  var IN_CAL =" yes "; Function caltest () {var sheet = SpreadsheetApp.getActiveSheet (); Var startRow = 2; // the first line of the data process var data = sheet.getDataRange (). GetValues ​​(); // Process any rows with data cal = CalendarApp.getCalendarsByNa me ("Oil and Gas Test 3") [0]; (In data i) {var row = data [i]; Var state = line [2] // column 3, call state with desc desc = line [5]; // column 6 column, with strap description var date = row [4]; // 5 column, date with column var title = state + ":" + desc; Var inCalendar = line [1]; // The second column, indicating whether or not in the calendar, if ((inCalendar! = IN_CAL) & amp; amp; (date! = "")) {// prevents adding duplicates in calendar cal. All data events created (title, new date (date)) var v = parseInt (i) +1; Sheet.Getrenz (V, 2, 1) .setValue (IN_CAL); SpreadsheetApp.flush (); // Make sure that the cell is updated immediately when the script is interrupted}}}  

If it helps, then the column My spreadsheet is in the following order:

Project Number | In the calendar | State | Lease date Date | " State ", " Date ", and " Details " in my script

It seems that most of the work is done that adds an event to the calendar, except that:

  1. For scripting "All these calendars" in the column "Yes "Whether or not the" Date "column has a date; And
  2. I have not even tried to adjust the colors.

Do anyone in the "Calendar" and "Date" column decide when an event should be created and the "Calendar" column should be updated in "Yes" ? I know that an event probably will not be created without a date, but I do not want a date without the lines to read "yes" in the "calendar" column. I read the script in the entire "In Calendar" column Want, in which a predetermined There are no rows.

Also, how can the colors of personal events change automatically?

Please tell me if you need additional information.

Add a breakpoint, by clicking on a line number, your code. You will get a red dot, see Line 12.

breakpoint

Then click the icon of a bug.

b C

You will see all the variable values ​​being displayed in a window at the bottom of the screen.

debug breaks

Click on the 'step in' icon :

in phase

if the date in your spreadsheet cell Formatted as a date, then the date value should be something like this:

Thursday 12 March 2015 19:01:08 GMT -0400 (EDT)

If the cell is formatted as a string, then the test should be like this:

  if (date! = "") {<>>  

But, any In the situation, take the steps through the code, and see the data type and value of the date variable. (And inCalendar variable), depending on what exactly is being received, will determine what you need to do with the condition.

I think:

<< code> = <">

always True


No comments:

Post a Comment