# addUserToRole 메서드

### 메서드&#x20;

Forguncy.addUserToRole(userName, roleName, successCallback, failCallback)

### 설명&#x20;

이 메서드를 사용하여 지정 된 그룹에 지정 된 사용자를 추가하여 사용자에 대한 역할을 지정합니다.

### 매개 변수&#x20;

| 매개변수            | 형식       |                                   |
| --------------- | -------- | --------------------------------- |
| userName        | string   | 사용자 이름입니다.                        |
| roleName        | string   | 그룹 이름, 즉 역할 이름입니다.                |
| successCallback | function | 함수를 성공적으로 콜백했습니다.                 |
| failCallback    | function | 매개 변수에 오류 메시지가 포함된 콜백 함수가 실패했습니다. |

### 반환값&#x20;

없음&#x20;

### 예제&#x20;

다음 예제 코드에서는 addUserToRole 메서드를 통해 지정된 사용자를 지정된 그룹에 추가합니다.

```javascript
//지정된 그룹에 지정된 사용자 추가
Forguncy.addUserToRole(
  //사용자 지정
  "장산",
  //그룹 지정
  "Administrator",
  //추가에 성공하면 추가 성공을 알리는 경고 상자가 팝업됩니다.
  function () {
    alert("성공적으로 추가되었습니다.")
  },
  //추가 실패시 경고창이 뜨면서 실패 정보를 보여줍니다.
  function (error) {
    alert(error)
  }
);
```

1. 페이지에서 범위를 선택하고 셀 유형을 로그인한 사용자로 설정하고 사용자 정보 보기를 테이블에 바인딩합니다.

<figure><img src="/files/b9yUin4haBx1xvcLEfcA" alt=""><figcaption></figcaption></figure>

2. 셀 범위를 선택하고 셀 유형을 버튼으로 설정하고 명령을 \[JavaScript 명령]으로 편집하고 JavaScript 코드를 입력합니다.

<figure><img src="/files/Zz41st2BAkeVZiloviFw" alt=""><figcaption></figcaption></figure>

3. 편집이 완료되면 \[확인]을 클릭하여 대화 상자를 닫습니다.\
   \
   페이지를 실행하고 관리자를 사용하여 로그인한 후 페이지에서 그룹에 추가 버튼 클릭하면 성공적으로 추가했다는 알림창이 나타납니다.

<figure><img src="/files/lR7epPNeJpuU9td2T1jF" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.forguncy.co.kr/command/javascriptprogramming/javascript-api/forguncymethod/addusertorole.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
