User Name Formatter - UNEXO icon

User Name Formatter - UNEXO

Formats user names based on input conditions

Overview

This node formats user names based on the presence of first and last names in the input data. It appends a specified suffix to the first name if available, or to the last name if the first name is missing but the last name exists. If both are missing, it assigns a default name. This is useful for customizing user display names dynamically, such as personalizing greetings or labels in workflows that process user information.

Practical examples:

  • Appending honorifics or titles to user names depending on which name parts are present.
  • Providing fallback names when user data is incomplete.
  • Formatting user names consistently before sending them to other systems or displaying them in UI elements.

Properties

Name Meaning
First Name Suffix A string suffix appended to the user's first name if it exists. Default: "جان"
Last Name Suffix A string suffix appended to the user's last name if the first name is missing but last name exists. Default: "گرامی"
Default Name The name assigned when both first and last names are missing. Default: "کاربر عزیز"
Users Input users data as JSON string. Leave blank to use users from the previous node's output.

Output

The node outputs an array of items where each item's json contains the original user data plus an additional field:

  • outputResult.name: The formatted name string constructed by appending the appropriate suffix or using the default name.

The output does not include binary data.

Dependencies

  • No external services or API keys are required.
  • The node expects user data to be provided either via the "Users" property or from the previous node's output.
  • No special environment variables or n8n configurations are necessary.

Troubleshooting

  • Empty or malformed user data: If the input user data lacks both firstName and lastName, the node will assign the default name. Ensure input data structure matches expected format (user info inside json.body).
  • Incorrect property paths: The node accesses user names under json.body.firstName and json.body.lastName. If your data uses different paths, the formatting will not work as intended.
  • Empty "Users" input: Leaving the "Users" property blank relies on previous node output. If no prior data exists, the node will process an empty array, resulting in no output.

Links and References

Discussion