# UpsertIf Function for MySQL

**URL:** <https://community.openfn.org/t/upsertif-function-for-mysql/444>\
**Category:** Adaptors & Templates\
**Created:** [June 3, 2024, 11:03am UTC](https://community.openfn.org/t/upsertif-function-for-mysql/444 "2024-06-03T11:03:42Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![joe](https://community.openfn.org/user_avatar/community.openfn.org/joe/32/75_2.png) [@joe](https://community.openfn.org/u/joe)\
**Post date:** [June 6, 2024, 2:43pm UTC](https://community.openfn.org/t/upsertif-function-for-mysql/444/21 "2024-06-06T14:43:45Z")

</div>

I don’t want to get into detail on this this right now, but if your transformations get very complicated, you might consider using conditional expressions in the workflow to create more steps.

You’d have one step to do the basic setup (converting the form into that fields object and doing any generic transformations) then another step for each form type, which makes any special transformations and then upserts.

You can specify a condition on the edge like `state.data.form.survey_type === "Partner Registration"`, and the step at the end of that edge will only fire if the condition is true.

I’ve mocked something up in Lightning and taken a screenshot to show you what I mean (I haven’t implemented any of these steps)

 ![image](https://community.openfn.org/uploads/default/original/1X/d4c60ea84c30c0e6e2e8abd8804ec2a468ad68e3.png)

[Previous page](https://community.openfn.org/t/upsertif-function-for-mysql/444.md?page=1)
