Marco
Marco

Reputation: 13

onEdit(e) is not working

I created the following onEdit function on Google Scripts to trigger the pullJobIDS function. The pullJobIDS function is working properly but the problem is with the onEdit function. I don't know why is not triggering. Can you see any syntax mistake?

The goal is to run the pullJobIDS function when any value in the Column with index 2 is modified different from NULL and in the Organisational Structure sheet only.

function onEdit(e) {
  if (e.source.getActive().getName() == 'Organisational Structure' && e.range.getColumn() == 2 && e.range.getValue() != "") { pullJobIDS() }
 }

I would appreciate any help with this. Thanks

Upvotes: 0

Views: 3266

Answers (1)

Tanaike
Tanaike

Reputation: 201683

The reason is that your script occurs an error at e.source.getActive().getName(). You can see the error by Execution transcript. In order to remove this error, please modify as follows.

From :

e.source.getActive().getName()

To :

e.source.getActiveSheet().getName()

Note :

  • In this modification, when column 2 in the sheet with the sheet name of 'Organisational Structure' is edited, if the edited cell is not empty, pullJobIDS() is run.
  • For your script, if some methods which are required to authorize are included in pullJobIDS(), please use the installable trigger.

Reference :

If I misunderstand your question, I'm sorry.

Upvotes: 1

Related Questions