Automation Loop

Hi,

is there a way of setting a clause in the automation, so that it stops when an automation is the reason it got triggered?

sounds weird, here is my challange:

I have contacts in my DB.
these have a FirstName.field and a LastName.field.and an Entity Name field (“LastName, FirstName”).
the entity.name is set by an automation and not with a formula, because this way I can create new contacts from within other documents and entites.
this works great BUT

I have an automation that takes this “LastName, FirstName” and splits it into the corresponding fields. but also the entity name field gets updated if the first or last name gets edited. And of course this creates a loop.

How can I tell the automation just to be triggered when a manual edit is made and not when the automation is changing the fields?

You could try checking the [User who triggered Rule] on both automations, e.g.

for the automation that sets the name:

If(
  IsEmpty([User who triggered Rule]),
  [Step 1 Xxx].Name,
  [Step 1 Xxx].LastName + ", " + [Step 1 Xxx].FirstName
)

and for the automation that sets the name parts:

If(
  IsEmpty([User who triggered Rule]),
  [Step 1 Xxx].FirstName,
  Middle([Step 1 Xxx].Name, Find([Step 1 Xxx].Name, ",") + 2, 999)
)

and

If(
  IsEmpty([User who triggered Rule]),
  [Step 1 Xxx].LastName,
  Left([Step 1 Xxx].Name, Find([Step 1 Xxx].Name, ",") - 1)
)

This way, changes will only occur if a user is involved.
Hope this works.

so this way it does not start a loop, because the “updated” is just triggering when something actually changes, correct?

awesome @Chr1sG , it seems to work flawless. you are really a master!

Weirdly, I wrote the above before checking the behaviour you described, but now I’ve set it up and tested myself, I can’t actually reproduce getting the loop detection to trigger even without my precautionary ‘if’ statements !!!

For example, if I just use

[Step 1 Xxx].LastName + ", " + [Step 1 Xxx].FirstName
Middle([Step 1 Xxx].Name, Find([Step 1 Xxx].Name, ",") + 2, 999)
Left([Step 1 Xxx].Name, Find([Step 1 Xxx].Name, ",") - 1)

in the respective automations, it works without error for me.
Perhaps you can clarify what your automations looked like that were causing problems.

i had it exactly like this. triggered on update. and it lead to the loop error. (i was wondering when i set it up if it would cause a loop and where i would find a log of the never stopping updates - but it just threw the error in the notifications and put a red light on one of the automations.)
even though after one run through it should stop in any case, because there is no change in the fields anymore, isnt it?
anyway - with your if, the loop does not even start and that safes cpu … i am happy :slight_smile:

i took the if statement out, but after a short time the errors did show up again.

i also did a script for the case people enter name in “FirstName Lastname” instead of “Lastname, Firstname”. (with a blank-page help from gpt)

const fibery = context.getService('fibery');

for (const entity of args.currentEntities) {

    const fullName = entity['Name']; // Assuming the name is stored in the 'Name' field
    if(fullName != ""){
    const commaIndex = fullName.indexOf(',');

    if (commaIndex !== -1) {
        // Name is in "Last Name, First Name" style
        const lastName = fullName.substring(0, commaIndex).trim();
        const firstName = fullName.substring(commaIndex + 1).trim();

        await fibery.updateEntity(entity.type, entity.id, {
            'First Name': firstName,
            'Last Name': lastName
        });
    } else {
        // Name is in "First Name Last Name" style
        const nameParts = fullName.split(/\s+/);

        if (nameParts.length >= 2) {
            const firstName = nameParts[0];
            const lastName = nameParts.slice(1).join(' ');

            await fibery.updateEntity(entity.type, entity.id, {
                'First Name': firstName,
                'Last Name': lastName,
                'Name': lastName + ", " + firstName
            });
        }
        }
    }
}