“Second Act” should have been called “Second Try,” and not just because that title fits better for the Jennifer Lopez comedy-drama, about a 40-year-old woman who fakes her way into a new career.

It’s because Peter Sagal’s film itself takes a second try about halfway through. It forgets about its own workplace comic premise and tries to reinvent itself, with a plot twist that is truly bizarre, as a weepy melodrama. The metamorphosis doesn’t work, and “Second Act” feels adrift between comedy and drama, sometimes within the same scene.

But Lopez remains the rare multi-platform mega-celebrity who can pull off playing a working-class character with heart and grit (see also “Maid in Manhattan” and the underrated “Angel Eyes”). Her presence almost holds the thing together.

Lopez plays Maya Vargas, a Queens woman who has made the most of her job as assistant manager of a big-box store. I’m not sure, in real life, a store the size of Wal-Mart would allow a local assistant manager to implement her own innovations, like a mobile shopping app or a café for harried moms, but we more or less buy it. When the boss brings in a corporate drone to take over the manager’s position Maya coveted, as she lacks a high school diploma, she’s crushed. “I wish we lived in a world where street smarts counted as much as book smarts.”

When she said that, I thought some kind of magic spell would come into play, “Big”-style, but this isn’t that kind of movie. Instead, the hacker teenage son of her best friend (a delightfully potty-mouthed Leah Remini) overhears her plea and decides to help. He sets up an entire new online persona for her, including a degree from Harvard and a stint in the Peace Corps, and applies in her name for high-powered corporate jobs.

To her utter surprise, she gets hired, working for a large company that makes skincare products. Turns out her time on the store floor has made her more well-versed in the market than the execs in Manhattan, and she’s tasked with coming up with a revolutionary new product to save the company brand.

There are a few comic moments as Maya tries to hide her real resume (all of which are in the trailer). But, tellingly, she never has any problem doing the actual job. This is a story of wish fulfillment for working-class America, telling them they really could do the job the big boys do if given a chance.

Maya charms both the company’s widowed CEO (Treat Williams) and his daughter (Vanessa Hudgens), and it’s here where “Second Act” takes an abrupt and hard-to-believe turn into melodrama, pushing the workplace narrative into the background.

Of all the things “Second Act” is, it isn’t, believe it or not, a romantic comedy. There is a subplot about Maya’s relationship with her boyfriend Trey (Milo Ventimiglia of “This is Us”), but that’s only given a few scenes at the beginning and end of the movie. Maya’s real romance in “Second Act” is with her corner office.

Rob Thomas is the features editor and social media editor for the Capital Times, as well as its film critic. He joined the Cap Times in 1999 and has written about movies, music, food and books.