Create user or update user

I have a user profile page with a bunch of inputs and a button to save the information.

When I am in the “workflow” editor, I am trying to figure out how to make the “submit” button “create a thing” only if there has never been such data associated with the user before. If the user has already instantiated a profile, I would want the button to merely update the relevant fields.

Can anyone advise?

Hi there, @hi17… one way to do it is to pass a parameter to the user profile page in the URL. Then, you can get the value of that parameter from the URL, and you can do different things on the page and in workflows based on the parameter’s value.

For example, let’s say the parameter is called exists, and it’s value is sent to the page as no when a user has not yet created a profile. When a user clicks the submit button on the profile page, you could have an Only when condition on the workflow step that creates a new thing only when exists is no. You could then have a second workflow step on the submit button that makes changes to a thing (the user’s profile) when exists is yes (with yes being passed to the profile page when a user who already has a profile navigates to the page).

Want to give something like that a shot and see if it works for you? Hope it helps!

Best…
Mike

Mike has a solid answer but you could also use conditionals and ‘only when’ on the button in workflows. Create 2 workflows to the same button one with ‘only when do a search for user contains current user’ and the other workflow would be doesnt contain. Then add the relevant actions. Then using the same conditions create a conditional on the button itself to change wording from create new user to update user based on user being created or not.

1 Like

Create an input field with the initial content as current user’s Xyz value. Then allow auto binding. This way the fields will be auto updated if they’re changed. You won’t need to use a workflow or a button

I am trying to implement your solution, but I am lost.

I am trying to work with this field:
Screen Shot 2020-06-05 at 1.02.24 PM

I am creating two workflows for it.

Workflow 1 (for when the user does have an account but their “first name” field is empty – i.e. populate that field for the first time):


Workflow 2 (for when the user does have an account but their “first name” field is NOT empty – i.e. update that field):


I have a few questions:

  1. Is it correct to do the search for current user in both cases? Seems redundant.
  2. I think Workflow 1 is correct? Am I right to think that?
  3. Why does Workflow 2 give me a “Make changes to text” dialog instead of a “Create a new Profile” dialog"?
  4. Where it says “empty” in Workflow 2’s “only when” box, I had to type it in as a string/text because it did not offer me an “empty” option. Why did this happen?

Overall, I’m pretty lost.