Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8072325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:59:06+00:00 2026-06-05T13:59:06+00:00

I just started using gApps scripts and I have run into two problems with

  • 0

I just started using gApps scripts and I have run into two problems with my code (below) while trying to set up my UI to disable the submit button while a task is processing.

  1. When trying to load the script I occasionally get the following error: “Error Encountered: Unexpected Error Occurred”. This error is not consistent in that all I need to do is refresh the script and then it will load for me. It really bothers me that it sometimes works, and sometimes doesn’t, when I haven’t changed the code at all.

  2. When the 3rd last line //button_submit.setEnabled(true); is un-commented the error occurs every time I try to load the script.

I while trying to figure out what was wrong I noticed that getElementById() didn’t seem to be assigning the correct UI type to the submit button. I’m unsure if this is the cause of the problem, but I suspect it isn’t as I saw the same behavior in the test script I made to see if I could replicate the issue from a simpler foundation.

I’d appreciate any feedback you might have as to what’s causing this issue.

Thanks

Chris B-P

Logging output

populate_assign_list spinner.getId():spinner
populate_assign_list spinner.getType():Image
populate_assign_list button_submit.getId():button_submit
populate_assign_list button_submit.getType():Generic
doGet button_submit.getId():spinner
doGet button_submit.getType():Image
doGet button_submit.getId():button_submit
doGet button_submit.getType():SubmitButton 

.

//define global script property variables
var prop_home_folder_id;       //String - Contains the home folder's ID string
var prop_subject_folder_names; //Array of Strings - Listing of folder names
var prop_subject_folder_ids;   //Array of Strings - Listing of folder IDs associated with folder names
var prop_submisison_ss_ids;    //Array of Strings - Losting of sumission spreadsheet IDs
var prop_allow_anon_submit;    //Flag - Allow manual entry of email address (ie. non domain access) Default to FALSE

function save_script_prop_(home_folder_id, subject_folder_names, subject_folder_ids, submisison_ss_ids, allow_anon_submit) {
  //array values must be sent to this function as comma separated strings ie   <array>.join(',')
  if (home_folder_id != null) ScriptProperties.setProperty("home_folder_id", home_folder_id);
  if (subject_folder_names != null) ScriptProperties.setProperty("subject_folder_names", subject_folder_names);
  if (subject_folder_ids != null) ScriptProperties.setProperty("subject_folder_ids", subject_folder_ids);
  if (submisison_ss_ids != null) ScriptProperties.setProperty("submisison_ss_ids", submisison_ss_ids);
  if (allow_anon_submit != null) ScriptProperties.setProperty("allow_anon_submit", allow_anon_submit);
}

function load_script_prop_() {
  /*
  prop_home_folder_id = ScriptProperties.getProperty("home_folder_id");
  prop_subject_folder_names = ScriptProperties.getProperty("subject_folder_names").split(",");
  prop_subject_folder_ids = ScriptProperties.getProperty("subject_folder_ids").split(",");
  prop_submisison_ss_ids = ScriptProperties.getProperty("submisison_ss_ids").split(",");
  prop_allow_anon_submit = ScriptProperties.getProperty("allow_anon_submit");
  //*/
  prop_home_folder_id = "";
  prop_subject_folder_names = ["1","2","3"];
  prop_subject_folder_ids = ["1","2","3"];
  prop_submisison_ss_ids = ["a","b","c"];
  prop_allow_anon_submit = false;
}




function doPost(e) {
  var app = UiApp.getActiveApplication();
   app.add(app.createLabel("Form submitted"));
   return app;
}

function doGet() {
  load_script_prop_();
  var testing_message = "";

  //create ui app and panels
  var app = UiApp.createApplication().setTitle("Assignment Submission");
  var v_panel = app.createVerticalPanel();
  v_panel.setSpacing(20);
  var layout_grid = app.createGrid(5,2);
  var form_panel = app.createFormPanel();
  var tab_panel_upload = app.createTabPanel().setId("tab_panel_upload");
  var v_panel_upload_file = app.createVerticalPanel().setTag(0); //Tag refrenced the number of upload elements currently in the tab
  var v_panel_upload_gdoc = app.createVerticalPanel().setTag(0); //Tag refrenced the number of gdoc elements currently in the tab


  //create menu objects
  var spinner = app.createImage("http://www.worldmsday.org/1000-faces/images/whatami/spinner.gif").setVisible(false).setId("spinner");
  var datebox_submission = app.createDateBox().setId("submission_datebox").setValue(new Date()).setEnabled(false);
  var textbox_user = app.createTextBox().setId("textbox_user").setName("textbox_user").setValue(Session.getUser().getEmail()).setEnabled(false);

  var lb_subject_folder = app.createListBox().setId("lb_subject_folder").setName("lb_subject_folder");
  lb_subject_folder.setVisibleItemCount(1);
  for (var i in prop_subject_folder_names) lb_subject_folder.addItem(prop_subject_folder_names[i], i);
  lb_subject_folder.setSelectedIndex(0);

  var lb_assign_list = app.createListBox().setId("lb_assign_list").setName("lb_assign_list");
  lb_assign_list.setVisibleItemCount(1);
  populate_assign_list();
  lb_assign_list.setSelectedIndex(0);

  var button_submit = app.createSubmitButton("Submit").setId("button_submit");
  Logger.log("doGet button_submit.getId():"+spinner.getId());
  Logger.log("doGet button_submit.getType():"+spinner.getType());
  Logger.log("doGet button_submit.getId():"+button_submit.getId());
  Logger.log("doGet button_submit.getType():"+button_submit.getType());


  //button_submit.setEnabled(false);
  //button_submit.setEnabled(true);

  var upload_1 = app.createFileUpload().setName("upload_1");
  var gdoc_1 = app.createLabel("Not Yet Implemented");




  //create menu handlers
  var handler_lb_subject_folder_spinner = app.createClientHandler().forTargets(spinner).setVisible(true);
  handler_lb_subject_folder_spinner.forTargets([lb_assign_list, tab_panel_upload]).setVisible(false);
  handler_lb_subject_folder_spinner.forTargets(button_submit).setEnabled(false);

  var handler_lb_subject_folder = app.createServerHandler("populate_assign_list").addCallbackElement(v_panel);
  lb_subject_folder.addChangeHandler(handler_lb_subject_folder_spinner);
  lb_subject_folder.addChangeHandler(handler_lb_subject_folder);
  //need to add an onchange handler for subject folder listbox which updates the assignment selection listbox.


  //add ui objects to ui
  layout_grid.setText(0,0, "Date: ");
  layout_grid.setWidget(0, 1, datebox_submission);
  layout_grid.setText(1,0, "Name: ");
  //layout_grid.setWidget(1, 1, "");  
  layout_grid.setText(2,0, "Email Address: ");
  layout_grid.setWidget(2, 1, textbox_user);
  layout_grid.setText(3,0, "Course: ");
  layout_grid.setWidget(3, 1, lb_subject_folder);
  layout_grid.setText(4,0, "Assignment: ");
  layout_grid.setWidget(4, 1, lb_assign_list);
  v_panel.add(layout_grid);

  v_panel.add(spinner);

  v_panel_upload_file.add(upload_1);
  tab_panel_upload.add(v_panel_upload_file, "Upload File");

  v_panel_upload_file.add(gdoc_1);
  tab_panel_upload.add(v_panel_upload_gdoc, "Share gDoc");
  tab_panel_upload.selectTab(0);
  v_panel.add(tab_panel_upload);


  v_panel.add(button_submit);

  form_panel.add(v_panel);
  app.add(form_panel);



  var testing_label = app.createLabel("No Test Output").setStyleAttribute("textAlign", "center");
  if (testing_message != "") debug_label.setText(testing_label);
  app.add(testing_label);

  return(app);
 }

function populate_assign_list(e) {
  load_script_prop_();

  if (e == null) subject_id=0;
    else subject_id = e.parameter.lb_subject_folder;

  var app = UiApp.getActiveApplication();
  var lb_assign_list = app.getElementById("lb_assign_list");
  lb_assign_list.clear();

  var assign_list = ["x","y","z" ];

  for (var i = 1; i < assign_list.length; i++) {
    lb_assign_list.addItem(assign_list[i]  );
  }


  lb_assign_list.setVisible(true);
  var spinner = app.getElementById("spinner").setVisible(false);
  Logger.log("populate_assign_list spinner.getId():" + spinner.getId());
  Logger.log("populate_assign_list spinner.getType():" + spinner.getType());
  app.getElementById("tab_panel_upload").setVisible(true);

  var button_submit = app.getElementById("button_submit");
  Logger.log("populate_assign_list button_submit.getId():"+button_submit.getId());
  Logger.log("populate_assign_list button_submit.getType():"+button_submit.getType());
  //button_submit.setEnabled(true);

  return app; 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:59:07+00:00Added an answer on June 5, 2026 at 1:59 pm

    Divide and conquer –

    I have had this error a few times, the only way I could track down
    the cause was “Divide and conquer”.

    …

    Causes I know of …

    A) same object ID used for different types of object, even if the old object has been removed.

    B) invalid color value

    C) Creating the app object twice with createApplication

    The error looks to be a kind of catch all error message.
    It also looks to be a client side error, so not sure logging will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started using fadein/fadeout - it's functioning but with problems. I have a set
I just started using SASS and I am trying to figure out how to
Just started using Blueprint CSS and now playing with the grids but have a
I´ve just started using ASIHTTPRequest for iOs and I have a small issue with
Just started using log4net and trying to get my head around the config and
I just started using Log4Net and was looking to see what you have found
I just started using GIT yesterday and i was trying to do something but
I just started using PrimeFaces and cannot figure what is wrong with my code.
I just started using the latest build of ffmpeg into which ffmpeg-mt has been
I just started using PyGI (on Ubuntu Natty), although I have never used pygtk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.