Run Google Sheets script without being the owner [closed]

1

I have a sheet in which you must enter dates in column A. These must be entered by running a script that is in the menu bar.

Column A is protected for all users except for my who created it . I do not want the dates to be entered by hand but only by running the script.

Date the copy of another sheet and paste it as "value" so that it does not change when the sheet is updated.

When I execute it, it does not give any problem, but when it is executed by another person to whom I have shared the sheet, it gives the warning that the column is protected.

How do I temporarily remove the protection with the script, or how does a user execute the script under my name?

This is the code:

function onOpen() {
    var ui = SpreadsheetApp.getUi();
    ui.createMenu('OTROS DATOS')
    .addItem('Ingresa Fecha Actual', 'getRangeValue')
   .addToUi();
 }

//******************** INGRESA FECHA ACTUAL EN CELDA ACTUAL *************************
function getRangeValue() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var range = sheet.getRange('Validadores!A2');
  var cell = sheet.getActiveCell();
  var R = cell.getRow();
  var C = cell.getColumn();
  range.copyTo(sheet.getRange(R,C), {contentsOnly:true}); 
 }
    
asked by Pvaldez 21.03.2017 в 21:54
source

1 answer

1

Short answer

The way to temporarily remove the protection is that you do it yourself manually, using an installable trigger or a web application. An alternative that the update of data on the protected range, is made through a web application configured to be executed with the owner's permission.

Explanation

In this case it is a project of command sequences (scripts) "tied to a container", in English to "container bounded script". In this type of projects, the scripts are executed with the permissions that the user has on the document, so the user does not have permission to edit a range, nor can he do it through a script that is part of the container bounded script .

It is worth mentioning that to execute a script with the owner's permission, what is usually done is to create a web application (web app) since in these it is possible to determine if they will be executed with the user's or the owner's permissions of the script Obviously, in this case you would have to configure the web app to be executed as the owner's permissions.

Unfortunately, integrating the web app with the user interface of the spreadsheet is not entirely appropriate, because although it is possible to include the link to the web application, clicking on it opens a new window or the content of the modal dialogue is modified, which is not very intuitive.

    
answered by 22.03.2017 в 03:41