Problems with Google apps script in add-on. Running script/add-on on laptop works, running same script on Gmailapp (mobile) throws error

I have a function (addEmailsOfStudentsToBCC(e)) which fetches e-mail adresses from a Google sheet pending on the choices of the user on a formInput (select). If gets the e-mailadress of each selected student, pushes in a array and in the end the array gets pushed to the BCC of a draft e-mail.

Everything works like a sharm on the Gmail app on my laptop. When opening the same add-on with the same function on my mobile device (in Gmail-app)… It throws an Type errror:
TypeError: Cannot read properties of undefined (reading 'forEach') at addEmailsOfStudentsToBCC(Main:174:16)

Logs also show that e['formInputs']['studentPicker'] is null on the mobile device but it returns an array with the chosen selection on a laptop.

The crazy thing is i have another function where teacher can select classes which use a similar way of working (e['formInputs'['classPicker'])
and that one works on laptop and mobile.

function addEmailsOfStudentsToBCC(e) {
  let studentsToMail = e['formInputs']['studentPicker']
  let toRecipients = []



studentsToMail.forEach((e) => {
    var listOfEmails = getMaillistFromClass(e)
    toRecipients.push(listOfEmails)
  })

  


 var response = CardService.newUpdateDraftActionResponseBuilder().setUpdateDraftBccRecipientsAction
    (CardService.newUpdateDraftBccRecipientsAction()
      .addUpdateBccRecipients(toRecipients))
    .build();
  return response;

 

}

I tried to check the logs but i’m kind of hopeless at the moment

New contributor

Dennis Verhasselt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Google Add-ons Restrictions

Since it wasn’t stated what type of add-on you’re using, Google actually has two types of add-ons: Google Workspace Add-ons and Editor Add-ons. This information is specified on Types of add-ons where it states that

There are two types of add-ons you can build: Google Workspace Add-ons and Editor Add-ons. For more information about each, see Add-on types.

According to Google Workspace Add-ons Restrictions

For the time being, Google Workspace Add-ons function on desktop web clients. Contextual triggering (that is, Gmail message reading) is also supported from within the Gmail mobile app. Non-contextual homepages are not yet available from the Gmail, Calendar, or Drive mobile apps. Google Workspace Add-ons are not available from mobile web browsers.

While Editor Add-ons states that

Editor Add-ons only function in desktop clients, not Android or iOS.

I’m guessing that you’re using a Google Workspace Add-on. The first statement explains why the studentPicker behaves differently on mobile compared to the classPicker. You mentioned, The crazy thing is I have another function where the teacher can select classes, which uses a similar approach (e['formInputs']['classPicker']), and that one works on laptop and mobile. This highlights that it may not work consistently due to the existing restrictions.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật