javascript - What is a more elegant way to overcome Error: Expecting object specifier. Argument has no object specifier when sending an SMS via Messages via JXA -


this fails work

    (application("messages")) {              send(text, {to: services["sms"].buddies[phone]})      } 

with error: expecting object specifier. argument has no object specifier.

text valid , not null. phone valid , not null. if hard code values works. decided try 'dynamic' hard coding worked.

    command = 'with (application("messages")) { send("' + text + '", {to: services["sms"].buddies["' + phone + '"]}) } ;' ;     eval(command) ; 

is there more elegant way of overcoming this? why eval work code variables not?

breaking code out smaller pieces helps me.

var text="foo" var phone="+14159999999" var messages = application('messages') var service = messages.services[0] var recipient = service.buddies.byname(phone, {     of: service })  messages.send(text  , {     to: recipient }) 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -