Custom PHP in workflow actions from the user interface

Hello,

I see this over and over again when working with other CRMs:
Having the ability to execute a workflow with custom code, just from the admin / user interface, is really powerful.

When builing up business process automations with the standard workflows, things can get tricky when there are multiple actions that need to happen.
Or if there are requirements for a bit more complex processes / calculations etc.
I know that we can use logic hooks etc. to add PHP code. And there are calculated fields - but why not give the admin the power to write PHP?

I don’t know about you, but adding PHP code inside a text area of a workflow action would make my life much easier.

Besides zoho and SugarCRM, which other CRMs have Custom PHP in Workflow Actions from the User Interface?

Those two and Hubspot - I’m mostly working with Zoho and it’s amazing to see, how far and easy things can be pushed by using Deluge.

Yes, that is possible in SuiteCRM. It’s called custom actions in Workflows.

I’ve done it using this old tutorial:

check also parts 2 and 3 of that.

My PowerReplacer add-on has “generic” custom actions that you can write low-code style stuff in them to do whatever you want.

Some screenshots from Zoho:

Try to look at the whole thing from a persons perspective who can develop a bit of code, but doesn’t want to get into Linux, Deployment, DevOps, etc.
I assume, that there are often situations where the IT takes care of DevOps and won’t give access to anybody in marketing and sales.
But there could be someone, especially in marketing, who knows a bit of JS or PHP.
This person could SO easily just add a bit of PHP code.
The code could be stored in a DB field, upgrade safe - no one has to access an FTP or touch the file system or read about how Suite looks under the hood and what to do.
After all, my business goal is not to learn the file structure of Suite but to execute some if else logic on lead creation - or similar.

I know about logic hooks, custom actions etc.
But specifically NOT touching any files seems to be charming and every efficient.

Open source and compare with High cost software. So, How to developers live?

@pgr I didn’t know you could even do custom workflow actions. Having a look at it, why would you want to do that vs. something like a before save hook, (or one of the other hooks) or like a custom scheduled job?

Seems like an over complication to do it via workflow when custom coding is necessary anway?

@pstevens it really was a game changer for me

  • Now, everytime I need to get customers SSH access.
  • There might be file permission issues.
  • If I take over a project from someone else, it’s usually 100% surprise if there are any customer logic hooks / PHP files or not
  • How do you document these technical details and hand it over to the customer at the end of a project?
  • Working together with another developer becomes so much easier - just share a link to the code
  • Time savings if you have 10 workflows that require some code, you’d create the action and write your x lines of code (compared to creating files, naming conventions, repair and rebuild issues, keeping local code in sync, deployment, versioning, etc.)

Having PHP code directly in a text area inside a workflow would eliminate all those issues at once.

Using Zoho for that, I first found it odd as well - why develop in an odd browser environment - but there are so many advantages to that.
Especially, if you think from a marketing / sales / power user perspective, not from a developer perspective.
All the list items above, don’t really provide business value to the customer - they are just interested in a quick and coste efficient solution.

It’s a different paradigm and doesn’t work well together with more traditional software development / delivery approaches.
But I find software development inside CRM is not as structured / well working as custom software development anyway … (maybe already very off topic now :slight_smile: )

Building on what @BastianHammer wrote…

The custom workflow actions are a building block. They combine with other building blocks (existing actions, conditions, etc) and can be used by end users. This is very different from a custom made logic hook that a developer writes ad-hoc, for a specific purpose.

Then, that extra level that Bastian mentions of being able to do custom things from the UI - definitely powerful and convenient. SuiteCRM doesn’t currently have this, but will soon have with my low-code features.

Hey @pgr @BastianHammer I guess what I’m struggling with is… if you have have developer build the custom workflow actions (I’m talking about the article @pgr shared, not Zoho’s ad hoc PHP scripting). So if I developed a custom workflow action to say “send and email to the assigned to’s boss when an opportunity = won”. How would that be any different if I built a custom workflow action vs. a before save hook. It still required development. I guess the user could select the action in workflow, but presumably the dev would set that up too. I just can’t get my head around where this would be useful. If there is a good business case for it, I’m going to learn and understand how it works and set one up.

I understand what Bastian is asking is different, he wants a workflow action that triggers a custom script specified by the user (which SuiteCRM doesn’t have). Presumably where the workflow action would be “execute php script” and then there would be a text field for “php script”. (Personally I think that’s scary as an admin!).

Allowing executable code from within the app sounds scary, but remember this is from an admin-only area, so…

About the custom actions. Think of how Linux command-line uses simple reusable tools that you can then combine in many ways. It’s the Unix one tool, one job philosophy.

So yes, you develop custom code for custom Workflow actions, but taking your example the “when an opportunity=won” does not go into the action. Because that’s already available in the language of Workflow conditions. So now your action works for that condition, and for any other condition that the user wants.

And your action can be part of a sequence of Workflow actions, even if you as a developer were not aware of the sequence at the time you developed. But the user sees the needs and uses your tool alongside others.

Ok thanks @pgr, starting to see the light. So for example I could have a custom workflow action “send an email to my boss” and then the user could define any actions in the workflow that trigger sending an email to my boss.

* the user could define any conditions

And it would be better to make the action more generic, like simply “send an email” and then the destination address is a field that you can fill; or you can use some field from the current workflow record to fill it.

Examples of other possible Workflow actions:

  • send an SMS
  • log something to a company record
  • send to an external system
  • trigger some “if this, then that” process out on the internet: www.ifttt.com
  • call a web hook
  • create a notification inside SuiteCRM

As you see, these generic things are fit for many use cases. You are extending the expressiveness of the workflows language, and it will combine (exponentially) with all previously existing functionality.

1 Like

sorry to jump in this discussion!

Is it possible to send an email to customers from the power workflow? :thinking:Since, currently we do not have functionality to send email to customer under action in the workflow module.

Sending an email has been an existing workflow action for a long time.

→ https://docs.suitecrm.com/user/advanced-modules/workflow/#_send_email

The new feature will only make that email powerfully templatable.

Okay, I see! I think I need to use related fields to send email to customer using workflow. Thanks!

@pgr You really know how to keep people on the edge of their seats. :wink:

Ha ha you’re right, and I’m sorry for teasing you guys about this for so many months now - it’s going to happen, but as is typical with software projects, there are delays.

It could happen as soon as v8.9, but I can’t promise it; the basic features have been ready since the summer, but these are really big features and there is a long tail of “details” to adjust and things to perfect. And I am only doing this part-time, so…

Lately I’ve been working on something (warning: more teasing coming up to keep you on the edge of your seats) that is about improving the way SuiteCRM v8 is configured for customizations. I am trying to make those bits of PHP adding items to the vardefs, and viewdefs, and container parameters, simpler and more straight-forward for people who don’t have deep PHP knowledge. It also has validations and proper messages telling you what you got wrong when configuring a field_logic entry, for example. I started this for low-code customizations, then extended it to everything, and it’s taking me a while…

1 Like

Wow, adding custom workflow actions are extremely complicated! So far I’ve managed to register the action, label it, get it executed. That’s pretty straight forward. However, adding fields, getting and saving the input, then displaying it in editview, etc. I’m still working through.