Hugo França
Hugo França

Reputation: 21

Invalid argument: permission.value

Script keeps giving me this error message. "Invalid argument: permission.value" This is the part of the code the error points out to:

var buyer   = threads[i].getMessages()[0].getReplyTo();
var subject = "Thank you for your purchase";
var body    = "Please download the file using the link below.\n\n";

if (size > 20) {
    file.addViewer(buyer); <---- It specifically points to this line

Any idea of what might be wrong?

Upvotes: 2

Views: 2913

Answers (2)

Drew O&#39;Connors
Drew O&#39;Connors

Reputation: 1

If you replace the buyer variable with an email address, it works fine.

.getReplyTo() pulls a name and an email address from <>. ie "Name""< [email protected]>"

Upvotes: 0

sifferman
sifferman

Reputation: 3112

You will get the error Invalid argument: permission.value if the referenced item doesn't exist. In your code, this might be the case if the index i is out of range, or threads[i] doesn't reference an object, or getMessages()[0] returns no object.

Run your script in debug mode, and when the error occurs, you can view the contents of your variables to see what the problem is.

See also: this question.

Upvotes: 0

Related Questions