Forum Academy Marketplace Showcase Pricing Features

API workflow to update all datatypes

Dear All,

Just had to add another contactType field because I’ve swithed to an Option Set.

If I want to mass update all my new contactType fields in all my datatype Contacts (just copying over the existing value), what parameter would I set? See screenshots… I keep getting red issues :frowning:

Firstly, unless all your contact’s are going to have the same ‘contactType’ value (which presumably they’re not), you don’t want to use a ‘make changes to a list of things’ action, but rather just a ‘make changes to thing’ (which will be an individual contact) in your backend workflow.

So first, make sure your endpoint has a parameter for contacts, of type ‘Contacts’.

Then add a ‘make changes to a thing’ action in the backend workflow, and select your ‘contact’ parameter as the thing to change.

Set the field to change to the new option set contact type field, then you’ll need to match the desired option to the previously existing contact type field (which I’m guessing was a text type - in which case you’ll need to ‘get all options’, then filter it by the option’s display to match the contact’s original text value).

That’s the backend workflow set up.

Then, to run that workflow on all your contacts, you can either set up a temporary page in your app with a workflow action to ‘schedule an API workflow on a list’, with the type of things set to ‘Contact’, the list set to all your contacts (presumably), so search for contacts, and the contact set to ‘this contact’.

Or (the easier way) just go to your app data tab and click on the ‘bulk’ button when viewing your contacts to run an API workflow directly on all the entries (you need to do this in dev and live databases separately).

Adam,

I got so close… I followed your advice as close as I could. Got stuck on…

“then filter it by the option’s display to match the contact’s original text value).” see screenshots.

help most appreciated.

Without seeing exactly how your data is set up, and the API endpoint settings, I can’t say exactly what you need to do.

If you want to include include a screenshot of the Endpoint property window, as well as your ‘contact type’ options set and ‘contacts’ datatype fields I can probably talk you through it.

Thx Adam, herewith…

Ok great…

Firstly, not that it matters much, but you don’t need to have the ‘Expose as a public endpoint’ option checked - that’s only need if you’re triggering the workflow from an external source via the API.

Secondly, although it doesn’t really matter what name you give your keys, calling it ‘contactType’ could be confusing, as it relates to an individual ‘Contact’, not a contactType.

So I’d rename it, either ‘Contact’, or even something like ‘Contact To Change’. That way it will be clearer exactly what you’re doing, and be less likely to cause any confusion.

image

Then in the workflow add an action to ‘Make Changes to Thing’ and the thing to change is the ‘Contact To Change’ (referring to an individual contact).

The field to change is the ‘contactType’ (the new, currently empty, option set field).

You need to add an option from you option set here, so start with setting the value to get an option; contactType; all options so you end up with contactType = All contactType(More...)which evaluates to the full list of contactTypes…

image

Then you need to add a filter to match the specific contactType you need to the old text contact type value.

Assuming that your new ‘Option Set’ contactTypes have the same name (Display) as the old text values, then you just need to match an option set’s Display to the old text value…

So next add the filter, with the following constraint…

This contactType’s (referring to the option from the option set)
Display (the name of the option)
Is
Contact To Change’s (the particular contact who’s record is being modified)
Contact type (the old ‘text’ value)

image

That will match the new Option that you want to set to the old text value.

Then you need to add ‘first item’ to make it into a single option…

image

Then you just need to run that workflow on your list of contacts.

The simplest way to do it is from your App Data tab, just select a view of your contacts and click the ‘Bulk’ button in the top right corner. Then you can run the workflow on your entire list of contacts (you’ll need to do it separately for the dev and live database, so you’ll need to make sure you publish the workflow to your live app before it’s available to run on the live database).

I’d run it on your dev database and check it has worked correctly before running it on your live data.

2 Likes

Ah, clever. Worked a treat. After several re-reads I think I’ve got the gist of it so I can apply it again in other areas.

You’re an absolute gent Adam, thx.

1 Like

Wow Thanks a lot for this very detailed explanation.

I had the exact same problem :slight_smile: