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 8508505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:10:50+00:00 2026-06-11T03:10:50+00:00

I am using sort of wrapping functions to add widgets to UiApp, like the

  • 0

I am using sort of wrapping functions to add widgets to UiApp, like the sample below

function newButton(text, handler, callBack) {
  var app = UiApp.getActiveApplication();
  return app.createButton(text).addClickHandler(app.createServerClickHandler(handler).addCallbackElement(callBack));
}
  • it works fine when used within the same script like below

    panel.add(newButton(“Submit”, “myHandler”, panel));

  • but when including newButton function within a Library (ex. myLib) and it’s called as myLib.newButton, I would get an error:
    “Error encountered: Unknown macro myLib.myHandler”

    panel.add(myLib.newButton(“Submit”, “myHandler”, panel));

Any way of avoiding this problem, while keeping myHandler in the current script (not in myLib)?
Thanks, Fausto

  • 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-11T03:10:51+00:00Added an answer on June 11, 2026 at 3:10 am

    Yes it can.
    In your current script (wherein you imported the reference to the library)
    create;

    function myLib.myHandler(){
    }
    

    As your handler (string) keep passing the name ‘myHandler’. The above function will be called by the button created in your library script.

    It seems like apps script is using this namespace structure to avoid name collision.

    You should keep in mind that this could purposely be not-documented by google for a reason. Maybe this current structure could be changed in the future. Or maybe im just being paranoid 😉

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

Sidebar

Related Questions

I have an array that I would like to sort using a date field
I want to sort a text file through linux sort , that looks like
I need to implement a simple text reader, sort of like less for unix,
I'm using a code like the following function Basket () { this.items = new
I was looking a way to sort struct using sort() function of STL:Algorithm library.
I'm using the sort() function in C++ to sort a vector of objects of
The other day I saw a colleague of mine using sort to sort a
Basically I'm trying to create a BASIC sorting program in ruby without using .sort
Im using c++ and is using insertion sort Where in the insertion sort algoithm
I want to sort array using Bubble Sort. I an missing a small point

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.