Updating an Email via Flow Designing using Replace Function

Maurice Murphy
Tera Guru

Hi Community, I've got a weird ask but I'm trying to create a Flow which will automatically run each day and check certain user's emails and update them if they don't match what they should be representing.

 

The problem I'm running into is that when I attempt scripting the Email field on the Flow, I get an internal system error and the logs are not being helpful for what the issue is.

 

Currently I'm only drafting my Flow, so I'm testing with a single user. It will:

  • Look up a specific user by their user ID.
  • Attempt to update their email with the following script:
//Grabs the current email on the User Record.
var currentEmail = fd_data._1__look_up_record.current.email;
//Replaces the end of the string with the updated information.
var updatedEmail = currentEmail.replace("@email.com","2@email.com");
//Return the updated value.
return updatedEmail;
  • Return that value and push the update.

Am I being silly trying to use replace in this way, or am I attempting to grab the Flow variable incorrectly? Any help is appreciated.

1 ACCEPTED SOLUTION

Maurice Murphy
Tera Guru

Managed to figure out my problem with the help of Now Support.

 

I was following the example script that shows up when you start creating a script in Flow Designer, but it turns out that different actions can have different ways to access those Flow variables.

 

For example, a record lookup would utilize:

var currentEmail = fd_data._1__look_up_record.record.email;

Meanwhile, a "For Each" loop would use:

var currentEmail = fd_data._1__for_each.item.email;

 Seems like the best way is to just use the auto-suggest when typing your script, as it will know what is correct for that specific action.

MauriceMurphy_0-1709232620613.png

 

View solution in original post

1 REPLY 1

Maurice Murphy
Tera Guru

Managed to figure out my problem with the help of Now Support.

 

I was following the example script that shows up when you start creating a script in Flow Designer, but it turns out that different actions can have different ways to access those Flow variables.

 

For example, a record lookup would utilize:

var currentEmail = fd_data._1__look_up_record.record.email;

Meanwhile, a "For Each" loop would use:

var currentEmail = fd_data._1__for_each.item.email;

 Seems like the best way is to just use the auto-suggest when typing your script, as it will know what is correct for that specific action.

MauriceMurphy_0-1709232620613.png