0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

プリザンターのサーバースクリプトで項目で選択されたユーザーがグループに所属しているかどうか調べる

Posted at

はじめに

今回の記事では、ClassRで設定されているユーザーが事前に指定したグループに所属しているかどうかを調べるものになります。今回はユーザーがグループに所属している場合の処理を実装していきます。

ソースコード

try {
    // ClassRに入力されているユーザーのユーザーIDを取得
    let classR = model.ClassR;
    // グループIDが「1」のgroupオブジェクトを取得
    let group = groups.Get(1);
    // グループIDが「1」のグループメンバーの情報を取得する
    let menbers = group.GetMembers();
    // グループIDが「1」のグループに所属しているメンバー分処理
    for (let menber of menbers) {
        // ClassRのユーザーがグループIDが「1」のグループに所属していればtrue
        if (classR == menber.UserId) {
            // 所属している場合の処理を記載
            context.Log('グループに所属しています。');
            // 処理を抜ける
            break;
        }
    }
} catch (ex) {
    context.Log(ex.stack);
}

おわりに

最近はサーバスクリプトの実装をするサポートが多い印象です。入社当初に比べたらサポートの回答速度も上がり、スクリプトの実装も少しずつきれいになった来たのかなと思っています。この調子で頑張ります。ユーザー様が私の記事を読んで少しでも実装ができるようになってくれると嬉しいです。自分の書いたコードで動いているシステムなんて素敵ですよね!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?