Search code examples
google-apps-scriptgoogle-slides-api

Check String equality of Slide textbox


I'm using SlidesApp.getActivePresentation.getSlides[0].getPageElements()[0].asShape().getText().asString() to get the text of the title of the slide. However, when I try to check the text in an equality statement like SlidesApp.getActivePresentation.getSlides[0].getPageElements()[0].asShape().getText().asString() == "XYZ Company" it returns false. What do I need to do to accurately check that a given Slide page element textbox contains certain text?


Solution

  • It seems the type of textbox was adding a trailing line break, so s.getPageElements()[0].asShape().getText().asString().trim() == "XYZ Company" evaluates true