Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Global Formula and If Conditions Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Lenny
Groupie
Groupie


Joined: January 06 2008
Online Status: Offline
Posts: 94
Posted: August 01 2019 at 08:10 | IP Logged Quote Lenny


A long time ago I updated all my PH Formula's to use a "global formula". I came across one today that still was directly sending emails and I tried to update it and I can't seem to get the syntax correct. I attached the formulas in a text file since the forum tends to add spaces randomly to them.



The Global Formula is named "EMAILME"

ph_sendsmtpemailasync(0,"","smtp-server.domain.com",25,"Powe rHome Alert <HomeAlerts@somedomain.com>","me@mydomain.com",ph_getv ar_s(1,1),"Timestamp: " + string(today(),"yyyy-mm-dd hh:mm:ss.fff") + "~r~n~r~n" + ph_getvar_s(1,2))




Calling this formula this way works fine passing Formula, subject, and body
ph_formulabtnparm (1,"EMAILME","OVERHEAD DOOR OPEN!","VACATION MODE ACTIVE - OVERHEAD DOOR OPEN!",0,0,0)


As soon as I update the if condition with the new PH Function I get Syntax Error. Anyone see my mistake?

if ("{MODE}" = "VACATION" AND "{OHDSTATUS}" = "CLOSED", ph_formulabtnparm (1,"EMAILME","OVERHEAD DOOR OPEN!","VACATION MODE ACTIVE - OVERHEAD DOOR OPEN!",0,0,0),0)

2019-08-01_080956_formula.txt
Back to Top View Lenny's Profile Search for other posts by Lenny
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4302
Posted: August 01 2019 at 09:14 | IP Logged Quote dhoward

Lenny,

The return value from the ph_formulabtnparm() function is a string (even if the ultimate result is a number). You need to make both the true and
false conditions evaluate to the same return type.

Changing your statement to this should make it work for you:

Code:
if ("{MODE}" = "VACATION" AND "{OHDSTATUS}" = "CLOSED", ph_formulabtnparm(1,"EMAILME","OVERHEAD DOOR OPEN!","VACATION MODE ACTIVE - OVERHEAD DOOR OPEN!",0,0,0),"")


Hope this helps,

Dave.


Edited by dhoward - August 01 2019 at 09:15
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
Lenny
Groupie
Groupie


Joined: January 06 2008
Online Status: Offline
Posts: 94
Posted: August 02 2019 at 08:08 | IP Logged Quote Lenny

Dave,
Thanks for the explanation and quick response it works as expected.
Lenny
Back to Top View Lenny's Profile Search for other posts by Lenny
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum