Cannot return a card markup from the callback function of a universal actionGmail add-on - any way to hide universal actions?Google App Script Get Form Data From Card ActionHow do I alter the UI of a Gmail Add On from a callback?Gmail.Users.Threads.get with metadata scope and metadata format not workingTypeError: Cannot read property “messageMetaData” from undefinedGmail add-on - callback from newOpenLink is not calledGetting “Google Apps Script” “The script doesn't have permission to perform that action.” randomlyCannot get authorization dialog to show with Google Apps ScriptHow can I trigger a search from a Gmail add-on card without refreshing the whole page?How to update my Card after Callback successful in Gmail add-on

How do I rename a LINUX host without needing to reboot for the rename to take effect?

Opposite of a diet

Why are on-board computers allowed to change controls without notifying the pilots?

Do I need a multiple entry visa for a trip UK -> Sweden -> UK?

Select empty space and change color in vector

Is it okay / does it make sense for another player to join a running game of Munchkin?

Coordinate position not precise

How do I keep an essay about "feeling flat" from feeling flat?

Applicability of Single Responsibility Principle

How to be diplomatic in refusing to write code that breaches the privacy of our users

Will it be accepted, if there is no ''Main Character" stereotype?

Curses work by shouting - How to avoid collateral damage?

Can I convert a rim brake wheel to a disc brake wheel?

Can I Retrieve Email Addresses from BCC?

Is there any reason not to eat food that's been dropped on the surface of the moon?

The Riley Riddle Mine

Is there an Impartial Brexit Deal comparison site?

How does it work when somebody invests in my business?

How does a character multiclassing into warlock get a focus?

Is it correct to write "is not focus on"?

Your magic is very sketchy

There is only s̶i̶x̶t̶y one place he can be

Displaying the order of the columns of a table

Go Pregnant or Go Home



Cannot return a card markup from the callback function of a universal action


Gmail add-on - any way to hide universal actions?Google App Script Get Form Data From Card ActionHow do I alter the UI of a Gmail Add On from a callback?Gmail.Users.Threads.get with metadata scope and metadata format not workingTypeError: Cannot read property “messageMetaData” from undefinedGmail add-on - callback from newOpenLink is not calledGetting “Google Apps Script” “The script doesn't have permission to perform that action.” randomlyCannot get authorization dialog to show with Google Apps ScriptHow can I trigger a search from a Gmail add-on card without refreshing the whole page?How to update my Card after Callback successful in Gmail add-on













1















I'm just trying to get started with the sample addon Google describes here for extending the compose UI:
https://developers.google.com/gsuite/add-ons/gmail/extending-compose-ui



However when I run it I'm getting this error:




Error with the add-on. Run time error. Cannot return a card markup
from the callback function of a universal action.




I have not setup any universal actions in my manifest file:




"timeZone": "America/New_York",
"oauthScopes":[
"https://www.googleapis.com/auth/script.send_mail",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose"
],
"gmail":
"name": "My Mail Merge",
"logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/label_googblue_24dp.png",
"composeTrigger":
"draftAccess": "METADATA",
"selectActions": [

"text": "show UI",
"runFunction": "buildImageComposeCard"

]
,
"openLinkUrlPrefixes": [
"https://mail.google.com/"
],
"primaryColor": "#42585F4",
"secondaryColor": "#42585F4"
,
"exceptionLogging": "STACKDRIVER"



Below is Code.gs:



function getInsertImageComposeUI(e) 
return [buildImageComposeCard()];


function buildImageComposeCard()
// Get a list of image URLs to display in the UI.
// This function is not shown in this example.
var imageUrls = [
"https://mail.google.com/1",
"https://mail.google.com/2",
"https://mail.google.com/3"
];

var card = CardService.newCardBuilder();
var cardSection = CardService.newCardSection().setHeader('My Images');
for (var i = 0; i < imageUrls.length; i++)
var imageUrl = imageUrls[i];
cardSection.addWidget(
CardService.newImage()
.setImageUrl(imageUrl)
.setOnClickAction(CardService.newAction()
.setFunctionName('applyInsertImageAction')
.setParameters('url' : imageUrl)));

return card.addSection(cardSection).build();


function applyInsertImageAction(e)
var imageUrl = e.parameters.url;
var imageHtmlContent = '<img style="display: block" src="'
+ imageUrl + '"/>';
var response = CardService.newUpdateDraftActionResponseBuilder()
.setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction()
.addUpdateContent(
imageHtmlContent,
CardService.ContentType.HTML)
.setUpdateType(
CardService.UpdateDraftBodyType.IN_PLACE_INSERT))
.build();
return response;










share|improve this question






















  • I couldn't get this working either. I'd move on to something else if I were you. Perhaps someone here will have a better answer but this example harkens to the days a decade ago when it was pretty much impossible for one with average intelliigence to even consider having a chance at figuring out how an example actually works.

    – Cooper
    Mar 21 at 17:55











  • Haha. Well, I would find a Gmail addon quite useful to my employer so am motivated to find a way to work. Will reach out to Google directly and see if they can help. Stackoverflow is their 1st line of support for apps script stuff, but not the last.

    – Michael
    Mar 21 at 18:01











  • By no means do I know as much as many other volunteers here so all is not lost yet. I have written Gmail Addons but not composer addons.

    – Cooper
    Mar 21 at 18:03












  • I too was able to get the sidebar stuff to work, just not the compose stuff.

    – Michael
    Mar 21 at 18:13















1















I'm just trying to get started with the sample addon Google describes here for extending the compose UI:
https://developers.google.com/gsuite/add-ons/gmail/extending-compose-ui



However when I run it I'm getting this error:




Error with the add-on. Run time error. Cannot return a card markup
from the callback function of a universal action.




I have not setup any universal actions in my manifest file:




"timeZone": "America/New_York",
"oauthScopes":[
"https://www.googleapis.com/auth/script.send_mail",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose"
],
"gmail":
"name": "My Mail Merge",
"logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/label_googblue_24dp.png",
"composeTrigger":
"draftAccess": "METADATA",
"selectActions": [

"text": "show UI",
"runFunction": "buildImageComposeCard"

]
,
"openLinkUrlPrefixes": [
"https://mail.google.com/"
],
"primaryColor": "#42585F4",
"secondaryColor": "#42585F4"
,
"exceptionLogging": "STACKDRIVER"



Below is Code.gs:



function getInsertImageComposeUI(e) 
return [buildImageComposeCard()];


function buildImageComposeCard()
// Get a list of image URLs to display in the UI.
// This function is not shown in this example.
var imageUrls = [
"https://mail.google.com/1",
"https://mail.google.com/2",
"https://mail.google.com/3"
];

var card = CardService.newCardBuilder();
var cardSection = CardService.newCardSection().setHeader('My Images');
for (var i = 0; i < imageUrls.length; i++)
var imageUrl = imageUrls[i];
cardSection.addWidget(
CardService.newImage()
.setImageUrl(imageUrl)
.setOnClickAction(CardService.newAction()
.setFunctionName('applyInsertImageAction')
.setParameters('url' : imageUrl)));

return card.addSection(cardSection).build();


function applyInsertImageAction(e)
var imageUrl = e.parameters.url;
var imageHtmlContent = '<img style="display: block" src="'
+ imageUrl + '"/>';
var response = CardService.newUpdateDraftActionResponseBuilder()
.setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction()
.addUpdateContent(
imageHtmlContent,
CardService.ContentType.HTML)
.setUpdateType(
CardService.UpdateDraftBodyType.IN_PLACE_INSERT))
.build();
return response;










share|improve this question






















  • I couldn't get this working either. I'd move on to something else if I were you. Perhaps someone here will have a better answer but this example harkens to the days a decade ago when it was pretty much impossible for one with average intelliigence to even consider having a chance at figuring out how an example actually works.

    – Cooper
    Mar 21 at 17:55











  • Haha. Well, I would find a Gmail addon quite useful to my employer so am motivated to find a way to work. Will reach out to Google directly and see if they can help. Stackoverflow is their 1st line of support for apps script stuff, but not the last.

    – Michael
    Mar 21 at 18:01











  • By no means do I know as much as many other volunteers here so all is not lost yet. I have written Gmail Addons but not composer addons.

    – Cooper
    Mar 21 at 18:03












  • I too was able to get the sidebar stuff to work, just not the compose stuff.

    – Michael
    Mar 21 at 18:13













1












1








1








I'm just trying to get started with the sample addon Google describes here for extending the compose UI:
https://developers.google.com/gsuite/add-ons/gmail/extending-compose-ui



However when I run it I'm getting this error:




Error with the add-on. Run time error. Cannot return a card markup
from the callback function of a universal action.




I have not setup any universal actions in my manifest file:




"timeZone": "America/New_York",
"oauthScopes":[
"https://www.googleapis.com/auth/script.send_mail",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose"
],
"gmail":
"name": "My Mail Merge",
"logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/label_googblue_24dp.png",
"composeTrigger":
"draftAccess": "METADATA",
"selectActions": [

"text": "show UI",
"runFunction": "buildImageComposeCard"

]
,
"openLinkUrlPrefixes": [
"https://mail.google.com/"
],
"primaryColor": "#42585F4",
"secondaryColor": "#42585F4"
,
"exceptionLogging": "STACKDRIVER"



Below is Code.gs:



function getInsertImageComposeUI(e) 
return [buildImageComposeCard()];


function buildImageComposeCard()
// Get a list of image URLs to display in the UI.
// This function is not shown in this example.
var imageUrls = [
"https://mail.google.com/1",
"https://mail.google.com/2",
"https://mail.google.com/3"
];

var card = CardService.newCardBuilder();
var cardSection = CardService.newCardSection().setHeader('My Images');
for (var i = 0; i < imageUrls.length; i++)
var imageUrl = imageUrls[i];
cardSection.addWidget(
CardService.newImage()
.setImageUrl(imageUrl)
.setOnClickAction(CardService.newAction()
.setFunctionName('applyInsertImageAction')
.setParameters('url' : imageUrl)));

return card.addSection(cardSection).build();


function applyInsertImageAction(e)
var imageUrl = e.parameters.url;
var imageHtmlContent = '<img style="display: block" src="'
+ imageUrl + '"/>';
var response = CardService.newUpdateDraftActionResponseBuilder()
.setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction()
.addUpdateContent(
imageHtmlContent,
CardService.ContentType.HTML)
.setUpdateType(
CardService.UpdateDraftBodyType.IN_PLACE_INSERT))
.build();
return response;










share|improve this question














I'm just trying to get started with the sample addon Google describes here for extending the compose UI:
https://developers.google.com/gsuite/add-ons/gmail/extending-compose-ui



However when I run it I'm getting this error:




Error with the add-on. Run time error. Cannot return a card markup
from the callback function of a universal action.




I have not setup any universal actions in my manifest file:




"timeZone": "America/New_York",
"oauthScopes":[
"https://www.googleapis.com/auth/script.send_mail",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose"
],
"gmail":
"name": "My Mail Merge",
"logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/label_googblue_24dp.png",
"composeTrigger":
"draftAccess": "METADATA",
"selectActions": [

"text": "show UI",
"runFunction": "buildImageComposeCard"

]
,
"openLinkUrlPrefixes": [
"https://mail.google.com/"
],
"primaryColor": "#42585F4",
"secondaryColor": "#42585F4"
,
"exceptionLogging": "STACKDRIVER"



Below is Code.gs:



function getInsertImageComposeUI(e) 
return [buildImageComposeCard()];


function buildImageComposeCard()
// Get a list of image URLs to display in the UI.
// This function is not shown in this example.
var imageUrls = [
"https://mail.google.com/1",
"https://mail.google.com/2",
"https://mail.google.com/3"
];

var card = CardService.newCardBuilder();
var cardSection = CardService.newCardSection().setHeader('My Images');
for (var i = 0; i < imageUrls.length; i++)
var imageUrl = imageUrls[i];
cardSection.addWidget(
CardService.newImage()
.setImageUrl(imageUrl)
.setOnClickAction(CardService.newAction()
.setFunctionName('applyInsertImageAction')
.setParameters('url' : imageUrl)));

return card.addSection(cardSection).build();


function applyInsertImageAction(e)
var imageUrl = e.parameters.url;
var imageHtmlContent = '<img style="display: block" src="'
+ imageUrl + '"/>';
var response = CardService.newUpdateDraftActionResponseBuilder()
.setUpdateDraftBodyAction(CardService.newUpdateDraftBodyAction()
.addUpdateContent(
imageHtmlContent,
CardService.ContentType.HTML)
.setUpdateType(
CardService.UpdateDraftBodyType.IN_PLACE_INSERT))
.build();
return response;







google-apps-script gmail-addons






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 21 at 15:01









MichaelMichael

168111




168111












  • I couldn't get this working either. I'd move on to something else if I were you. Perhaps someone here will have a better answer but this example harkens to the days a decade ago when it was pretty much impossible for one with average intelliigence to even consider having a chance at figuring out how an example actually works.

    – Cooper
    Mar 21 at 17:55











  • Haha. Well, I would find a Gmail addon quite useful to my employer so am motivated to find a way to work. Will reach out to Google directly and see if they can help. Stackoverflow is their 1st line of support for apps script stuff, but not the last.

    – Michael
    Mar 21 at 18:01











  • By no means do I know as much as many other volunteers here so all is not lost yet. I have written Gmail Addons but not composer addons.

    – Cooper
    Mar 21 at 18:03












  • I too was able to get the sidebar stuff to work, just not the compose stuff.

    – Michael
    Mar 21 at 18:13

















  • I couldn't get this working either. I'd move on to something else if I were you. Perhaps someone here will have a better answer but this example harkens to the days a decade ago when it was pretty much impossible for one with average intelliigence to even consider having a chance at figuring out how an example actually works.

    – Cooper
    Mar 21 at 17:55











  • Haha. Well, I would find a Gmail addon quite useful to my employer so am motivated to find a way to work. Will reach out to Google directly and see if they can help. Stackoverflow is their 1st line of support for apps script stuff, but not the last.

    – Michael
    Mar 21 at 18:01











  • By no means do I know as much as many other volunteers here so all is not lost yet. I have written Gmail Addons but not composer addons.

    – Cooper
    Mar 21 at 18:03












  • I too was able to get the sidebar stuff to work, just not the compose stuff.

    – Michael
    Mar 21 at 18:13
















I couldn't get this working either. I'd move on to something else if I were you. Perhaps someone here will have a better answer but this example harkens to the days a decade ago when it was pretty much impossible for one with average intelliigence to even consider having a chance at figuring out how an example actually works.

– Cooper
Mar 21 at 17:55





I couldn't get this working either. I'd move on to something else if I were you. Perhaps someone here will have a better answer but this example harkens to the days a decade ago when it was pretty much impossible for one with average intelliigence to even consider having a chance at figuring out how an example actually works.

– Cooper
Mar 21 at 17:55













Haha. Well, I would find a Gmail addon quite useful to my employer so am motivated to find a way to work. Will reach out to Google directly and see if they can help. Stackoverflow is their 1st line of support for apps script stuff, but not the last.

– Michael
Mar 21 at 18:01





Haha. Well, I would find a Gmail addon quite useful to my employer so am motivated to find a way to work. Will reach out to Google directly and see if they can help. Stackoverflow is their 1st line of support for apps script stuff, but not the last.

– Michael
Mar 21 at 18:01













By no means do I know as much as many other volunteers here so all is not lost yet. I have written Gmail Addons but not composer addons.

– Cooper
Mar 21 at 18:03






By no means do I know as much as many other volunteers here so all is not lost yet. I have written Gmail Addons but not composer addons.

– Cooper
Mar 21 at 18:03














I too was able to get the sidebar stuff to work, just not the compose stuff.

– Michael
Mar 21 at 18:13





I too was able to get the sidebar stuff to work, just not the compose stuff.

– Michael
Mar 21 at 18:13












1 Answer
1






active

oldest

votes


















0














In the manifest file, runFunction has to be set to "getInsertImageComposeUI",



Also, in the code file, CardService.ContentType.HTML has to be one of



CardService.ContentType.MUTABLE_HTML


or



CardService.ContentType.IMMUTABLE_HTML





share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283414%2fcannot-return-a-card-markup-from-the-callback-function-of-a-universal-action%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    In the manifest file, runFunction has to be set to "getInsertImageComposeUI",



    Also, in the code file, CardService.ContentType.HTML has to be one of



    CardService.ContentType.MUTABLE_HTML


    or



    CardService.ContentType.IMMUTABLE_HTML





    share|improve this answer





























      0














      In the manifest file, runFunction has to be set to "getInsertImageComposeUI",



      Also, in the code file, CardService.ContentType.HTML has to be one of



      CardService.ContentType.MUTABLE_HTML


      or



      CardService.ContentType.IMMUTABLE_HTML





      share|improve this answer



























        0












        0








        0







        In the manifest file, runFunction has to be set to "getInsertImageComposeUI",



        Also, in the code file, CardService.ContentType.HTML has to be one of



        CardService.ContentType.MUTABLE_HTML


        or



        CardService.ContentType.IMMUTABLE_HTML





        share|improve this answer















        In the manifest file, runFunction has to be set to "getInsertImageComposeUI",



        Also, in the code file, CardService.ContentType.HTML has to be one of



        CardService.ContentType.MUTABLE_HTML


        or



        CardService.ContentType.IMMUTABLE_HTML






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 22 at 1:07









        tehhowch

        5,72241227




        5,72241227










        answered Mar 21 at 23:49









        MichaelMichael

        168111




        168111





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55283414%2fcannot-return-a-card-markup-from-the-callback-function-of-a-universal-action%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해