Workflow Automation: PHP Calculation & Regex Examples

*There is a lot of information on this page - use FIND (CTRL+F)*.

Contact Support if you have any questions.**

Here are some real-life examples of PHP Calculations used by other Workflow Automation members. Since most field types in Podio handle the data differently, we have separated our calculations by field type. Scroll to the end for Parsing examples. If you would like to add to this list to help other users, please contact our Support team.

(Note: Podio field tokens, as shown highlighted in blue, must be dropped into the calc field using the token selector.)

PHP Regex 1

For a list of PHP Functions available for use in Workflow Automation, see this Article


AVAILABLE TOKENS AND CALCULATION EXAMPLES

Podio Item ID

Returns the Podio Item ID When searching the App for a duplicate, check that the Referenced ID is found

(Ref)Podio Item ID != ""

Created (App) Podio Item ID:

Returns the nine-digit Item number that can be used in the old format for a Podio link

Create a URL link to the item created in the flow: 'https://ORGANIZATION.podio.com/APP-NAME/item'.Created (App) Podio ID

Actions Left per Hour:

Returns the value of the actions left per hour at that current moment

Check if there are more than 50 actions available in the hour:

Actions left this Hour> 50

Actions Left per Month:

Returns the value of the actions left in the month at that current moment

Check if there are more than 1000 actions available in the hour:

Actions left this Month> 1000

Current Date(Y-m-d):

Returns the current date

Format theCurrent Datefrom YYYY-MM-DD to be MM-DD-YYYY:

date("m-d-Y", strtotime(current-date))

Current Date & Time(Y-m-d H:i:s):

Returns the current date and time

Item Created Date & Time:

Returns the date and time of when the Item was created, in the format above

Check if the Current Date is greater than a specific date: strtotime(Item Created Date & Time) > strtotime(2016-02-16)

Item Last Updated Date & Time:

Returns the date and time of when the Item was last updated, in the format above

Item Creator Name:

Returns the name of the User who created the Item

Check if the App created the Item:

Item Creator Name=="App-Name"

Revision Creator Name:

Returns the name of the User who made the last Update to the Item

Check if Reviser is a particular user

Revision Creator Name== "John Doe"

Item Creator @mention:

Use in a comment to @mention the Item Creator

Use this token in a comment

Item Creator @mention

Revision Creator @mention:

Use in a comment to @mention the Revision Creator

Use this token in a comment

Revision Creator @mention

Podio App Item ID:

Returns the Unique Item ID

Podio App Item ID (Formatted):

Returns the Unique Item ID as set up in thePodio App Settings

Podio Item Email Address:

Returns the Trigger Items email address for use in Podio’sEmail to Item.This token is collected by the MAIN Account holder and therefore must be a member of the workspace.

To check if a token is empty or null, we recommend using empty() instead of comparing to an empty string or zero:

empty(field-token)

Create an email list from a Contact field Email and the the Podio Email Address:

Contact (Email). "," .Podio Item Email Address

All Comments:

Provides a list of all comments and when they occurred

Copy All Comments to a Multi-line Text field retaining previous field value

Field-Token. "\n" .All Comments. "\n"

Comment Count(#):

This token gives a total count of all comments on the Podio Item

Use this token in text or calculations

Comment Count (#)

Item All File(s) List:

Returns a list of the files names located on the Podio Item. (Not uploaded via third party providers)

Returns a comma separated list of links to the files uploaded to the Podio Item via third part providers

Workflow Automation Most Recent Error:

Returns the error generated when the flow tried to perform actions


BASIC FILTER CALCULATIONS

Determine if a Podio Field is empty:

empty(field-token)

Determine if a Podio Field is NOT empty:

!empty(field-token)!= ""

Great for flows that Trigger By Day or Date

Determine if it’s an odd-numbered week when the flow triggers:

(date ("W")/2) != (intval(date("W")/2))

Determine if the triggered day of the month is equal to 1:

date("j") == "1"

Determine if the day of the week that the trigger happened is equal to Monday:

date("D") == "Mon"

Determine if the time of day the trigger happened is between 10:00AM and 6:00PM:

intval(date("H")) > 10 && intval(date("H")) < 18 && intval(date("N")) < 6date("H") > 10 && date("H") < 18 && date("N") < 6


PODIO CALCULATION FIELD

Format a Calculation field to remove HTML:

strip_tags( Calc-Field )OR remove HTML and an extra space:trim( strip_tags( Calc-Field )


CATEGORY FIELD

Multi-choice category fields return a comma-separated list.

To unset a Category field:

NULL

or select Unset from the drop down menu

Count number of selected options within a Category field:

sizeof(explode( ",", Category-Field ))

Assigning multiple values to a Category field:

"option1,option2,option3"

Add commas between Category Options when using this field in a PDF or Email:

str_replace ( ",", ", ", Category-Field )

If Category is equal to A, add relationship but if not, do nothing:

( Category-Field == "A"? Relationship-Field : "")

Create an IF Statement using a Category field: (if statement == true) ? (true) : (false)

( Category-Field == A) ? (A) : (( Category-Field == B) ? (B) : (( Category-Field == C) ? (C) : (false)))

If Category is equal to A, add relationship A, if equal to B, add relationship B but if other, do nothing:

( Category-Field == "A"? Relationship-A-Field : ( Category-Field == "B"? Relationship-B-Field : ""))

Check if a Multiple choice Category field contains a value:

stristr( Category-Field ,"value")

Add a space between values from a Multiple choice Category field:

str_replace ( ",", ", ", Category-Field )

Add checkbox to each value from a Multiple choice Category field:

!empty(Category-Field) ? “

” . str_replace ( “,”, “

”, Category-Field ) : “”


CONTACT/MEMBER FIELD

Get only the First Name of a Contact field:

(strpos( Contact-Field , " ")) ? (substr( Contact-Field , 0, strpos( Contact-Field , " "))) : ( Contact-Field )

Get only the Last Name of a Contact field:

substr( trim( Contact-Name-Field ) , strpos(trim ( Contact-Name-Field), " ") +1)

Get the Whole Name of a Contact field:

(strpos( Contact-Field , "(email:")) ? (substr( Contact-Field , 0, strpos( Contact-Field , " (email:"))) : ( Contact-Field )

Get the email address from a Contact field:

substr(substr( Contact-Field , strpos( Contact-Field , "(email: ")+7 ), 0, strpos(substr( Contact-Field , strpos( Contact-Field , "(email: ")+7 ), ")" ))

Add the Contact field “Assigned To” Workspace User initials to beginning of a Text field:

substr( Contact-Field ,0,1) . substr( Contact-Field , strpos( Contact-Field , " ")+1,1) . " " . Text-Field

Get a Profile ID from the user drop down menu:

Right Click on the user drop down menu, select Inspect to view the source code, click on Value5_ and select the Profile/Workspace ID

PHP Regex 2

PHP Regex 3

Assign multiple Contacts using profile IDs separated by commas:

profile-id#1,profile-id#2for example: “9834623,9834572”


DATE FIELD

Get items with February in a “Due Date” Date field:

date("m", strtotime( Date(Start)-Field )) == "02"

Check if a Date Field is in the current week:

date("W") == date("W", strtotime( Date-Field ))

Format A Date field as YYYY-MM-DD and remove the time stamp:

( Date(End)-Field == "") ? (date("Y-m-d")) : (date("Y-m-d", strtotime( Date(End)-Field )))

Get time from a Date field in a 12 hour format (ex. 9:30am):

date("g:ia", strtotime( Date(Start)-Field ))

Get the number of days between 2 Date fields with 1 decimal point:

round(intval(strtotime( Date-Field-A ) - strtotime( Date-Field-B ))/(60 * 60 * 24), 1)

Calculate the difference between two Date fields using a “Custom Variable”:

intval(strtotime( Custom Variable ) - strtotime( Date(Start)-Field ))/(60 * 60 * 24)

Add 10 business days to a Date field including the time stamp:

date("Y-m-d", strtotime( Date-Field . " +10 weekdays"))." 00:00:00"

Add a number of days value in a Number field to a Date Field:

date("Y-m-d", strtotime( Date-Field . " + " . Number-Field . "days"))

Add Number field days value to a Date Field even when blank:

Note: Does not work with Start End dates*

date("Y-m-d", strtotime( Date-Field ."+".(( Number-Field =="")?(0):( Number-Field )). "days"))

For other Date formats, have a look at php.net


DURATION FIELD

Returns the duration in number of seconds.

Format a Duration field from seconds to exact hours and mins:

intval( Duration-Field /3600) ."h". intval(( Duration-Field - (intval( Duration-Field /3600) * 3600))/60) . "m"


EMAIL FIELD

Returns a comma separated list of emails.

Remove Email Headers from Address:

preg_replace("/(other|work|home):/ism", "", email-field )


"<a href=" . Link-Field . ">Custom Text" . "</a>"

Add multiple URLs to the field:

Link-A-Field . "," . Link-B-Field


MONEY FIELD

Returns the value in the field, excluding zeros. Use the Money(currency) field to display the selected Currency.

Add a $ to the beginning of a Money field:

" $ " . number_format ( Money-Field , 2 )

Add commas for thousands separator to Money field for use in Variables

number_format( Money-Field , 2, '.' , ',' )

Create an IF Statement using a Money field:

(floatval(Money-Field) > 0) ? (floatval(Money-Field)) : ("N/A")


NUMBER FIELD

Format a Number field to 2 decimal places:

number_format( Number-Field , 2)

Calculate the average of 3 different Number fields:

( Number-A-Field + Number-B-Field + Number-C-Field ) / 3

Calculate a percentage from 2 Number fields and round to 2 decimal places:

round((intval(Number-A-Field) / intval(Number-B-Field)) * 100, 2)


PHONE FIELD

Returns a comma separated list of phone numbers.

Easily Update using “Value” from the dropdown:

"Value" = "work:Field-Token,mobile:Field-Token"

Strip Phone TYPE from the number to be used in a Search:

current(array_slice( explode( ":", Phone-Field ), 1))

Send a SMS to the “Mobile” phone number in the list:preg_match_gf("/mobile:(^+)/", Phone-Field, 1)

Or see Below for more parsing help with preg_match_gf.


PROGRESS FIELD

Returns numeric value only


RELATIONSHIP FIELD

Add a new item to the field without losing the existing references:

Relationship-Field(Previous Value) . "," . Podio-Item-ID

Remove an Item from the Relationship field, retaining others:

str_replace ( Podio-Item-ID, "", Relationship-Field )

Count items in a Relationship field:( Relationship-Field == "") ? (0) : (substr_count( Relationship-Field ,",")+1)


TAGS

Returns a comma separated list of the Items tags ________________________________________________________________________________________________________________

FILE PATH:

Issue: File path escaping characters

Solution: You can solve this by wrapping the field token with single quotes. This returns the string wrapped in double quotes.


TEXT FIELD

Podio adds HTML to multi-line text fields.

Get the 3rd word from a Text field:

current(array_slice( explode( " ", Text-Field ), 2))

Get the last word from a Text field:

substr( Text-Field , strrpos( Text-Field , " " ))

Remove HTML from Multi-Line Text field:

strip_tags_gf( Text-Field )

Add the Current Date, Time and Item Headline Text to another Text field:

date("d/m/Y H:i") . " - " . Text-Field

Determine if a referenced Text field is equal to a current Items’:

( Text-Field == (Ref)Text-Field )

Determine if 2 (two) referenced Text field are equal to the current Items’:

( (Ref)Text-Field-A == Text-Field-A ) && ( (Ref)Text-Field-B == Text-Field-B )

Determine if Text field contains a particular word

strpos( Text-Field,'word') !== false

Join 2 Text fields together (separate by space):

Text-Field-A . " " . Text-Field-B

Join 2 Text fields together (separate by carriage return):

Text-Field-A . "\n" . Text-Field-B

Add the Contact field “Assigned To” Workspace User initials to beginning of a Text field:

substr( Contact-Field ,0,1) . substr( Contact-Field , strpos( Contact-Field , " ")+1,1) . " " . Text-Field


PARSING TEXT WITH PREG_MATCH_GF()

Common character matches

\n = New Line

s = Any White Space Character

0-9] = Numbers only

0-9-] = Numbers and dashes

a-z] = Lower case letters only

A-Z] = Upper case letters only

a-zA-Z0-9] = Alphanumeric matches.

All characters (wild card)\

Parsing a phone number (See Regex Example):

This will strip out most formats of phone numbers (123-4567, 123.4567, 123 4567 etc)

preg_match_gf("/CallerID:\n([0-9-\s.]+)/ism", strip_tags_gf(Text-Field), 1)

Parsing text between 2 words (See Regex Example):

This will parse out any text between words

preg_match_gf("/Voice (.*) Message/ism", strip_tags_gf(Text-Field), 1)

Parsing text on a single line (See Regex Example):

Notice that the expression doesn’t end in /ism, but only /i

preg_match_gf("/Address\s:\s(.*)/i", strip_tags_gf(Text-Field), 1)

Parsing text between multiple lines (See Regex Example): Using strip_tags_gf will turn paragraph tags into \n. This means you’ll need to account for these new line breaks.

preg_match_gf("/Date:\n(.*)\n\nNumber/ism", strip_tags_gf(Text-Field), 1)

Workflow Automation: PHP Calculation & Regex Examples