# 「ユーザーをグループに追加…」スクリプトには、2つのトリガーで異なるフィールド入力があります

**URL:** <https://meta.discourse.org/t/add-user-to-group-script-has-different-field-input-for-the-two-triggers/281813>\
**Category:** UX\
**Tags:** automation, completed, user-custom-fields\
**Created:** [2023 年 10 月 10 日午後 8:48 UTC](https://meta.discourse.org/t/add-user-to-group-script-has-different-field-input-for-the-two-triggers/281813 "2023-10-10T20:48:49Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [2023 年 10 月 10 日午後 8:48 UTC](https://meta.discourse.org/t/add-user-to-group-script-has-different-field-input-for-the-two-triggers/281813/1 "2023-10-10T20:48:49Z")

</div>

「ユーザーカスタムフィールド経由でユーザーをグループに追加する」スクリプトについて、問題があるようです。「ユーザーが最初にログインした」トリガーが選択されている場合、「ユーザーカスタムフィールド名」入力は、たとえば「Native Language」のようなユーザーフィールドの **名前** に設定する必要があります。しかし、「Recurring」トリガーが選択されている場合、「ユーザーカスタムフィールド名」入力は、たとえば「user\_field\_5」のようなユーザーフィールドの`id`に基づいて設定する必要があります。

Recurringトリガーで使用する名前を見つける方法に関する詳細は、こちらにあります: [Finding Userfield Custom Name for 'Add user to group through User Custom Field' - #2 by leonardo](https://meta.discourse.org/t/finding-userfield-custom-name-for-add-user-to-group-through-user-custom-field/241608/2?u=simon).

理想的には、フレンドリ名（たとえば「Native Language」）が、利用可能な両方のトリガーの正しい値として使用されるべきです。関連するコードは次のとおりです: [https://github.com/discourse/discourse-automation/blob/main/lib/discourse\_automation/scripts/add\_user\_to\_group\_through\_custom\_field.rb](https://github.com/discourse/discourse-automation/blob/main/lib/discourse_automation/scripts/add_user_to_group_through_custom_field.rb). 「ユーザーが最初にログインした」トリガーが、`id`ではなくフィールド名から正しいユーザーカスタムフィールドを見つける方法は次のとおりです:

[https://github.com/discourse/discourse-automation/blob/main/lib/discourse\_automation/scripts/add\_user\_to\_group\_through\_custom\_field.rb#L54-L67](https://github.com/discourse/discourse-automation/blob/main/lib/discourse_automation/scripts/add_user_to_group_through_custom_field.rb#L54-L67)

おそらく、そのロジックをRecurringトリガーに適用できる後方互換性のある方法があるかもしれません。

---

_[View the full topic](https://meta.discourse.org/t/add-user-to-group-script-has-different-field-input-for-the-two-triggers/281813)._
