GlideElement - 전역

  • 릴리스 버전: Washingtondc
  • 업데이트 날짜 2024년 02월 01일
  • 읽기59분
  • GlideElement API는 필드와 해당 값을 처리하기 위한 여러 가지 편리한 스크립트 메서드를 제공합니다. 현재 GlideRecord의 필드에 GlideElement 메서드를 사용할 수 있습니다.

    GlideElement - canCreate()

    사용자의 역할이 연결된 필드에 새 항목을 만들 수 있도록 허용할지 여부를 결정합니다.

    표 1. 매개변수
    이름 유형 설명
    없음
    표 2. 반환
    유형 설명
    부울 현재 사용자에게 연결된 필드에 새 항목을 만들 수 있는 권한이 있는지 여부를 나타내는 플래그입니다.
    가능한 값:
    • true: 사용자가 새 항목을 만들 수 있습니다.
    • false: 사용자가 새 항목을 만들 수 없습니다.

    다음 예에서는 사용자에게 문제 [problem] 테이블의 최근 레코드 세 개에 대한 항목을 만들 수 있는 권한이 있는지 확인하는 방법을 보여 줍니다.

    var gr = new GlideRecord('problem');
    
    // Get records in new state in Problem Table
    gr.addQuery('state','101');
    
    // Sort records in order of recent to earlier Created Date
    gr.orderByDesc('sys_created_on');
    
    // Limit the query to three records
    gr.setLimit(3); 
    gr.query();
    
    while(gr.next()){
      if(gr.short_description.canCreate()){ ///check to see if the current user is allowed to create the record
      gs.info("I can create new records for the field Problem statement for - " + gr.number);
      }
    }

    출력:

    I can create new records for the field Problem statement for - PRB0000004
    I can create new records for the field Problem statement for - PRB0001000
    I can create new records for the field Problem statement for - PRB0001001

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 canCreate() 메서드를 사용하려면 해당 범위가 지정된 메서드인 canCreate()를 사용합니다범위가 지정된 GlideElement - canCreate().

    GlideElement - canRead()

    사용자의 역할에 따라 연결된 GlideRecord를 읽을 수 있는지 여부를 결정합니다.

    표 3. 매개변수
    이름 유형 설명
    없음
    표 4. 반환
    유형 설명
    부울 필드를 읽을 수 있으면 True이고, 그렇지 않으면 false입니다.

    다음 예제는 읽을 수 있는 간단한 설명 필드를 사용하여 활성 인시던트 기록 목록을 가져오는 방법을 보여줍니다.

    var grIncident = new GlideRecord('incident');
    grIncident.addEncodedQuery("active=true"); //Query the Incident table for active incidents
    grIncident.orderByDesc('number');
    grIncident.setLimit(3); // limit to three results for example
    grIncident.query();
    
    while (grIncident.next()) {
        if (grIncident.short_description.canRead()) { //check to see if the current user is allowed to read the record
            gs.info('You have permission to read the short description of: ' + grIncident.number + ' ' + grIncident.short_description);
        }
    }

    출력:

    *** Script: You have permission to read the short description of: INC0009009 Unable to access the shared folder.
    *** Script: You have permission to read the short description of: INC0009005 Email server is down.
    *** Script: You have permission to read the short description of: INC0009001 Unable to post content on a Wiki page

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 canRead() 메서드를 사용하려면 해당 범위가 지정된 메서드인 canRead()를 사용합니다범위가 지정된 GlideElement - canRead().

    GlideElement - canWrite()

    사용자의 역할에 따라 연결된 GlideRecord에 쓸 수 있는지 여부를 결정합니다.

    표 5. 매개변수
    이름 유형 설명
    없음
    표 6. 반환
    유형 설명
    부울 사용자가 필드에 쓸 수 있으면 True이고, 그렇지 않으면 false입니다.

    다음 예제에서는 쓰기 가능한 간단한 설명 필드를 사용하여 활성 인시던트 기록 목록을 가져오는 방법을 보여줍니다.

    var grIncident = new GlideRecord('incident');
    grIncident.addEncodedQuery("active=true"); //Query the Incident table for active incidents
    grIncident.orderByDesc('number');
    grIncident.setLimit(3); // limit to three results for example
    grIncident.query();
    
    while (grIncident.next()) {
        if (grIncident.short_description.canWrite()) { //check to see if the current user is allowed to write to the record
            gs.info('You have permission to write to the short description of: ' + grIncident.number + ' ' + grIncident.short_description);
        }
    }

    출력:

    *** Script: You have permission to write to the short description of: INC0009009 Unable to access the shared folder.
    *** Script: You have permission to write to the short description of: INC0009005 Email server is down.
    *** Script: You have permission to write to the short description of: INC0009001 Unable to post content on a Wiki page

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 canWrite() 메서드를 사용하려면 해당 범위 지정 메서드인 canWrite()를 사용합니다범위가 지정된 GlideElement - canWrite().

    GlideElement - changes()

    현재 필드가 수정되었는지 여부를 확인합니다. 이 기능은 저널 필드를 제외한 사용 가능한 모든 데이터 유형에 사용할 수 있습니다.

    주:
    changes() 메서드는 ACL 스크립트 내에서 지원되지 않습니다.
    주:
    이 메서드를 수행 중인 GlideRecord가 초기화되고 읽기만 되었으며 작성되지 않은 경우 기본 전후 값은 동일합니다. 이 경우 메서드는 데이터 저장소가 변경되지 않았으므로 "false"를 반환합니다.
    표 7. 매개변수
    이름 유형 설명
    없음
    표 8. 반환
    유형 설명
    부울 필드가 변경되었으면 True이고, 그렇지 않으면 false입니다.

    비즈니스 규칙의 다음 예제에서는 assigned_to 필드의 값이 변경되는 경우 EventQueue에서 이벤트를 만드는 방법을 보여 줍니다.

    if (!current.assigned_to.nil() && current.assigned_to.changes()) {
      gs.eventQueue('incident.assigned', current, current.assigned_to.getDisplayValue(), previous.assigned_to.getDisplayValue());
    }

    범위가 지정된 등가

    범위가 지정된 애플리케이션에서 changes() 메서드를 사용하려면 해당 범위 지정 메서드인 changes()를 사용합니다. 범위가 지정된 GlideElement - changes()

    GlideElement - changesFrom(객체 값)

    현재 필드의 이전 값이 지정된 객체와 일치하는지 여부를 결정합니다.

    주:
    이 메서드를 수행 중인 GlideRecord가 초기화되고 읽기만 되었으며 작성되지 않은 경우 기본 전후 값은 동일합니다. 이 경우 메서드는 데이터 저장소가 변경되지 않았으므로 "false"를 반환합니다.
    표 9. 매개변수
    이름 유형 설명
    객체 현재 필드의 이전 값에 대해 확인할 객체 값입니다.
    표 10. 반환
    유형 설명
    부울 이전 값이 매개변수와 일치하면 true이고, 일치하지 않으면 false입니다.
    if (theState.changesTo(resolvedState)) {
      operation = 4; //Resolved
    }
    else if (theState.changesTo(closedState)) {
      operation = 11; //Resolution Accepted
    }
    else if (theState.changesFrom(resolvedState) || theState.changesFrom(closedState)) {
      operation = 10; //Re-open
    }
    else {
      operation = 6; //Update
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 changesFrom() 메서드를 사용하려면 해당 범위 지정 메서드인 changesFrom()을 사용합니다범위가 지정된 GlideElement - changesFrom(객체 o).

    GlideElement - changesTo(객체 값)

    변경 후 필드의 새 값이 지정된 객체와 일치하는지 여부를 결정합니다.

    주:
    changesTo() 메서드는 ACL 스크립트 내에서 지원되지 않습니다.
    주:
    이 메서드를 수행 중인 GlideRecord가 초기화되고 읽기만 되었으며 작성되지 않은 경우 기본 전후 값은 동일합니다. 이 경우 메서드는 데이터 저장소가 변경되지 않았으므로 "false"를 반환합니다.
    표 11. 매개변수
    이름 유형 설명
    객체 현재 필드의 새 값에 대해 확인할 객체 값입니다.
    표 12. 반환
    유형 설명
    부울 새 값이 매개변수와 일치하면 True이고, 일치하지 않으면 false입니다.
    if (theState.changesTo(resolvedState)) {
      operation = 4; //Resolved
    }
    else if (theState.changesTo(closedState)) {
      operation = 11; //Resolution Accepted
    }
    else if (theState.changesFrom(resolvedState) || theState.changesFrom(closedState)) {
      operation = 10; //Re-open
    }
    else {
      operation = 6; //Update
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 changesTo() 메서드를 사용하려면 해당 범위 지정 메서드인 changesTo()를 사용합니다범위가 지정된 GlideElement - changesTo(객체 o).

    GlideElement - dateNumericValue()

    기간 필드에 대해 1970년 1월 1일 00:00:00 GMT 이후의 시간(밀리초)을 반환합니다. 기간 필드가 이미 GlideDateTime 객체이므로 GlideDateTime 객체를 생성할 필요가 없습니다.

    표 13. 매개변수
    이름 유형 설명
    없음
    표 14. 반환
    유형 설명
    번호 1970년 1월 1일 00:00:00 GMT 이후의 밀리초 수입니다.
    var inc = new GlideRecord('incident');
    inc.get('17c90efb13418700cc36b1422244b05d');
    gs.info(inc.calendar_duration.dateNumericValue());

    출력: 98000

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 dateNumericValue() 메서드를 사용하려면 해당 범위 지정 메서드인 dateNumericValue()범위가 지정된 GlideElement - dateNumericValue()사용합니다.

    GlideElement - debug(객체 o)

    객체를 디버깅하고 setError(String)를 사용하여 디버그 메시지를 추가합니다.

    표 15. 매개변수
    이름 유형 설명
    O 객체 디버깅할 개체입니다.
    표 16. 반환
    유형 설명
    void

    GlideElement - getAttribute(attributeName 문자열)

    딕셔너리에서 지정된 특성의 값을 반환합니다.

    속성이 부울 속성인 경우 getBooleanAttribute(String) 를 사용하여 값을 문자열이 아닌 부울로 가져옵니다.

    표 17. 매개변수
    이름 유형 설명
    attributeName 문자열 속성 이름
    표 18. 반환
    유형 설명
    문자열 속성 값
    doit();
    function doit() {
      var now_GR = new GlideRecord('sys_user');
      now_GR.query("user_name","admin");
      if (now_GR.next()) {
        gs.print("we got one");
        gs.print(now_GR.location.getAttribute("tree_picker"));
      }
     
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getAttribute() 메서드를 사용하려면 해당 범위 지정 메서드인 getAttribute()를 사용합니다범위가 지정된 GlideElement - getAttribute(attributeName 문자열).

    GlideElement - getBaseTableName()

    필드의 기본 테이블을 가져옵니다.

    표 19. 매개변수
    이름 유형 설명
    없음
    표 20. 반환
    유형 설명
    문자열 기본 테이블의 이름입니다. 이 이름은 필드가 정의된 테이블과 다를 수 있습니다. 제품 설명서에서 테이블 확장 및 클래스를 참조하십시오.

    다음 예제는 인시던트 기록의 할당 그룹 필드에 대한 기본 테이블의 방법을 보여줍니다.

    var gr = new GlideRecord('incident');
    
    //query the Incident Records which have category as Inquiry/Help
    gr.addQuery('category','inquiry');
    
    // sort them in the order of earlier to recent created date
    gr.orderBy('sys_created_on');
    gr.query();
    
    if(gr.next()){ //If at least any one record exists matching this query
    
      //Print the base table for the Assignment Group field
      gs.print("The Base Table for the field Assignment Group is - " + gr.assignment_group.getBaseTableName()); 
    };

    출력:

    The Base Table for the field Assignment Group is - task

    GlideElement - getBooleanAttribute(attributeName 문자열)

    딕셔너리에서 지정된 특성의 부울 값을 반환합니다.

    값을 문자열로 가져오려면 getAttribute(string)를 사용합니다.

    표 21. 매개변수
    이름 유형 설명
    attributeName 문자열 속성 이름
    표 22. 반환
    유형 설명
    부울 특성의 부울 값입니다. 특성이 없으면 false를 반환합니다.

    다음 예제에서는 두 필드에 대한 특성의 ignore_filter_on_new 부울 값을 가져오는 방법을 보여 줍니다.

    var inc = new GlideRecord('incident');
    inc.query();
    
    if (inc.next())
     {
       // opened_by field has attribute "ignore_filter_on_new = true"
       gs.info(inc.opened_by.getBooleanAttribute("ignore_filter_on_new"));
    
      // short_description field does not have attribute ignore_filter_on_new
       gs.info(inc.short_description.getBooleanAttribute("ignore_filter_on_new"));
     }

    출력:

    true
    false

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getBooleanAttribute() 메서드를 사용하려면 해당 범위 지정 메서드인 getBooleanAttribute()범위가 지정된 GlideElement - getBooleanAttribute(attributeName 문자열)사용합니다.

    GlideElement - getChoices(문자열에 따라 다름)

    필드에 대한 선택 목록을 생성합니다. 확장된 테이블이 아닌 기본 테이블에서만 선택 값을 반환합니다.

    표 23. 매개변수
    이름 유형 설명
    종속 문자열 옵션입니다. 선택 목록 필드가 종속된 연결된 기록 내의 필드입니다.
    표 24. 반환
    유형 설명
    배열 목록 필드의 선택 값입니다.
    var glideRecord = new GlideRecord('incident'); 
    glideRecord.query('priority','1'); 
    glideRecord.next(); 
     
    // urgency has choice list: 1 - High, 2 - Medium, 3 - Low, with value: 1, 2, 3
    var choices = glideRecord.urgency.getChoices();

    범위가 지정된 등가

    범위가 지정된 애플리케이션에서 getChoices() 메서드를 사용하려면 해당 범위가 지정된 메서드인 getChoices()를 사용합니다. 범위가 지정된 GlideElement - getChoices(문자열에 따라 다름)

    GlideElement - getChoiceValue()

    현재 선택 값에 대한 선택 레이블을 가져옵니다.

    표 25. 매개변수
    이름 유형 설명
    없음
    표 26. 반환
    유형 설명
    문자열 선택 레이블입니다.

    다음 예제에서는 우선순위 값이 정상인 변경 요청 기록에 대한 선택 레이블을 가져오는 방법을 보여줍니다.

    var gr = new GlideRecord('change_request');
    
    //query for the change records with change type as "Normal"
    gr.addQuery('type','normal');
    
    // sort them in the order of recent to earlier Created Date
    gr.orderByDesc('sys_created_on'); 
    
    // limit the query to 4 records
    gr.setLimit(4); 
    gr.query();
    
    while(gr.next()){
     //Printing the choice label for those records
     gs.print("The label of the current priority '"+ gr.priority+"' for the change request - " + gr.number + " is - "+ gr.priority.getChoiceValue()); 
    }

    출력:

    The label of the current priority '4' for the change request - CHG0000014 is - 4 - Low
    The label of the current priority '4' for the change request - CHG0000013 is - 4 - Low
    The label of the current priority '4' for the change request - CHG0000012 is - 4 - Low
    The label of the current priority '4' for the change request - CHG0000011 is - 4 - Low

    범위가 지정된 등가

    범위가 지정된 애플리케이션에서 getChoiceValue() 메서드를 사용하려면 해당 범위 지정 메서드인 getChoiceValue()를 사용합니다. 범위가 지정된 GlideElement - getChoiceValue()

    GlideElement - getDebugCount()

    debug()에 의해 기록된 디버그 메시지 수를 가져옵니다.

    표 27. 매개변수
    이름 유형 설명
    없음
    표 28. 반환
    유형 설명
    번호 디버그 메시지 수입니다.

    GlideElement - getDependent()

    지정된 필드가 종속된 필드(요소)를 반환합니다.

    표 29. 매개변수
    이름 유형 설명
    없음
    표 30. 반환
    유형 설명
    문자열 현재 필드가 종속된 필드의 이름입니다. 종속성이 없는 경우 Null입니다.

    다음 예제에서는 getDependent() 메서드를 사용하여 구성 항목 필드의 상위 필드를 찾는 방법을 보여 줍니다.

    var inc_gr = new GlideRecord('incident');
    inc_gr.get('985f53d82fab301032e8808cf699b6e8'); // Get a particular Incident
    
    var field_element = inc_gr.getElement('cmdb_ci'); // Get the Configuration Item element
    var dependent_field = field_element.getDependent(); // Read the dependent field
    gs.info("Dependent field: " + dependent_field);
    if(dependent_field)
      {
        var dependent_field_value = inc_gr.getValue(dependent_field);  
        if(!dependent_field_value)
          {
            var base_table = field_element.getRefRecord(); // Retrieve the reference record
            var dependent_field_value = base_table.getValue(dependent_field); // Read the parent field value
          }
        inc_gr.setValue(dependent_field, dependent_field_value); // Update the parent field on the Incident
        inc_gr.update();
      }

    출력:

    company

    GlideElement - getDependentTable()

    현재 테이블이 종속된 테이블을 가져옵니다.

    표 31. 매개변수
    이름 유형 설명
    없음
    표 32. 반환
    유형 설명
    문자열 테이블의 이름입니다.

    GlideElement - getDisplayValue(Number maxChar)

    필드의 형식화된 표시 값을 반환합니다.

    표시 값은 데이터베이스의 실제 값과 사용자 또는 시스템 설정 및 기본 설정에 따라 조작됩니다.

    반환되는 표시 값은 필드 유형에 따라 다릅니다.
    • 선택 필드: 데이터베이스 값은 숫자일 수 있지만 표시 값은 더 설명적입니다.
    • 날짜 필드: 데이터베이스 값은 UTC 형식이고 표시 값은 사용자의 시간대를 기반으로 합니다.
    • 암호화된 텍스트: 데이터베이스 값은 암호화되지만 표시된 값은 사용자의 암호화 컨텍스트에 따라 암호화되지 않습니다.
    • 참조 필드: 데이터베이스 값은 sys_id이지만 표시 값은 참조된 기록의 표시 필드입니다.
    표 33. 매개변수
    이름 유형 설명
    맥스 차르 번호 옵션입니다. 반환할 최대 문자 수입니다.
    표 34. 반환
    유형 설명
    문자열 필드의 표시 값입니다.
    var fields = current.getFields();
    for (var i = 0; i < fields.size(); i++) { 
      var field = fields.get(i);
      var name = field.getName(); 
      var value = field.getDisplayValue(); 
      gs.print(i + ". " + name + "=" + value); 
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getDisplayValue() 메서드를 사용하려면 해당 범위가 지정된 메서드인 getDisplayValue()범위가 지정된 GlideElement - getDisplayValue(maxCharacters 수)사용합니다.

    GlideElement - getDisplayValueExt(number, maxChar, string, nullSub)

    필드의 형식화된 표시 값을 반환하거나, 표시 값이 null이거나 비어 있는 경우 지정된 대체 값을 반환합니다.

    표시 값은 데이터베이스의 실제 값과 사용자 또는 시스템 설정 및 기본 설정에 따라 조작됩니다.

    반환되는 표시 값은 필드 유형에 따라 다릅니다.
    • 선택 필드: 데이터베이스 값은 숫자일 수 있지만 표시 값은 더 설명적입니다.
    • 날짜 필드: 데이터베이스 값은 UTC 형식이고 표시 값은 사용자의 시간대를 기반으로 합니다.
    • 암호화된 텍스트: 데이터베이스 값은 암호화되지만 표시된 값은 사용자의 암호화 컨텍스트에 따라 암호화되지 않습니다.
    • 참조 필드: 데이터베이스 값은 sys_id이지만 표시 값은 참조된 기록의 표시 필드입니다.
    표 35. 매개변수
    이름 유형 설명
    맥스 차르 번호 옵션입니다. 반환될 최대 문자 수입니다.

    기본값: 모두

    nullSub 문자열 표시 값이 null이거나 비어 있는 경우 반환할 값입니다.
    표 36. 반환
    유형 설명
    문자열 필드의 형식화된 표시 값 또는 지정된 대체 값입니다.

    다음 예제에서는 인시던트 [incident] 테이블에서 가장 최근의 두 개의 활성 레코드를 표시하는 방법을 보여 줍니다.

    var gr = new GlideRecord('incident');
    gr.addQuery('active', true);      // get the active records
    gr.orderByDesc('sys_updated_on'); // sort the records from most recent to oldest updated date
    gr.setLimit(2);                   // limit the query to 2 records
    gr.query();
    
    while(gr.next()){ // Printing the Display Value of the Configuration Item field. 
      // If the Display Value is Null/Empty, then it will be substituted with Default value "I with Null/Empty Display Value"
      gs.info("The Display Value of the Configuration Item for the incident - "+ gr.number+ " is " + gr.cmdb_ci.getDisplayValueExt(40, " CI with Null/Empty Display Value"));
    }

    출력:

    The Display Value of the Configuration Item for the incident - INC0007001 is  CI with Null/Empty Display Value
    The Display Value of the Configuration Item for the incident - INC0000069 is NYC RAC

    GlideElement - getDisplayValueLang(문자열 언어)

    매개 변수로 전달된 언어의 필드 표시 값을 가져옵니다.

    결과는 선택 사항, 번역된 필드 및 번역된 텍스트와 같은 번역 가능한 필드 유형에만 적용할 수 있습니다. 다른 필드 유형의 경우 결과는 기본적으로 getDisplayValue()로 설정됩니다.

    번역된 값을 검색하려면 해당 언어 플러그인이 있어야 합니다. 자세한 내용은 Activate a language 문서를 참조하십시오.

    범위가 지정된 GlideElement - getLabelLang(문자열 언어) 또한 참조하십시오.

    표 37. 매개변수
    이름 유형 설명
    language 문자열 IETF BCP-47을 준수하는 언어 태그입니다.
    표 38. 반환
    유형 설명
    문자열 전달된 언어로 된 필드의 표시 값입니다. 번역을 사용할 수 없는 경우 메서드는 현재 사용자의 언어로 번역된 값을 검색합니다. 번역을 사용할 수 없는 경우 결과는 기본적으로 영어로 설정됩니다.

    다음 예제에서는 수락 (UI 뷰) 제목 필드에서 원본 텍스트와 독일어로 번역된 텍스트를 가져오는 방법을 보여 줍니다.

    var uiView = new GlideRecord("sys_ui_view");
    uiView.get("fa776f6d97700100f309124eda2975bc");
    
    gs.info("getDisplayValue: " + uiView.getElement("title").getDisplayValue());
    gs.info("getDisplayValueLang: " + uiView.getElement("title").getDisplayValueLang("de"));

    출력:

    getDisplayValue: Accept
    getDisplayValueLang: Akzeptieren

    범위가 지정된 등가

    범위가 지정된 애플리케이션에서 getDisplayValueLang() 메서드를 사용하려면 해당 범위 지정 메서드인 getDisplayValueLang()범위가 지정된 GlideElement - getDisplayValueLang(문자열 언어)사용합니다.

    GlideElement - getED()

    필드 내부의 데이터가 아닌 특정 필드에 대한 정보를 제공하는 요소 설명자를 반환합니다.

    표 39. 매개변수
    이름 유형 설명
    없음
    표 40. 반환
    유형 설명
    엘리먼트 디스크립터 필드의 요소 설명자입니다.

    이 예는 현재 기록에 대한 필드 및 필드 설명자를 가져옵니다.

    var fields = current.getFields();
    for (i=0; i<fields.size(); i++) { 
      var field = fields.get(i);
      var descriptor = field.getED(); 
      gs.print("type=" + descriptor.getType() + 
        " internalType=" + descriptor.getInternalType()); 
    }

    범위가 지정된 등가

    범위가 지정된 애플리케이션에서 getED() 메서드를 사용하려면 해당 범위 지정 메서드인 getED()를 사용합니다. 범위가 지정된 GlideElement - getED()

    GlideElement - getElementValue(문자열 값)

    지정된 요소의 값을 반환합니다.

    표 41. 매개변수
    이름 유형 설명
    문자열 값을 반환하려는 요소입니다.
    표 42. 반환
    유형 설명
    문자열 요소의 값입니다.
    var fields = current.getFields();
    for (var i = 0; i < fields.size(); i++) {
      var field = fields.get(i);
      var name = field.getName();
    
      // Returns the unformatted value of the element
      var value = field.getElementValue(name);
      var disValue = field.getDisplayValue();
      gs.print(i + ". " + name + " = " + value + ' display value = ' + disValue);
    }

    출력

    1. cmdb_ci = 109562a3c611227500a7b7ff98cc0dc7 display value = Storage Area Network 001
    2. impact = 2 display value = 2 - Medium

    GlideElement - getError()

    지정된 요소와 연결된 모든 오류 메시지를 반환합니다.

    setError() 메서드를 사용하여 특정 필드(요소)에 오류를 설정합니다.

    표 43. 매개변수
    이름 유형 설명
    없음
    표 44. 반환
    유형 설명
    문자열 지정된 요소에 대해 현재 설정된 오류 메시지입니다.

    이 예제에서는 short_description 요소에 오류를 설정한 다음 오류를 다시 읽는 방법을 보여 줍니다.

    var incidentGR = new GlideRecord('incident');
    incidentGR.setLimit(1);
    incidentGR.query();
    if (incidentGR.next()) {
        incidentGR.short_description.setError('The description is too short.');
        gs.info(incidentGR.short_description.getError()); // 'The description is too short.'
    }

    출력:

    The description is too short.

    이 예제에서는 함수 호출에서 사용하는 getError() 방법을 보여 줍니다.

    // Before query business rule (order = 100)
    (function executeRule(current, previous /*null when async*/) {
        var shortDescription = current.getValue('short_description');
        if (shortDescription.length < 10) {
            current.short_description.setError('The description is too short.');
            current.setAbortAction(true);
        }
    })(current, previous);
    
    // Before query business rule (order = 200)
    (function executeRule(current, previous /*null when async*/) {
        var shortDescriptionErrMsg = current.short_description.getError();
        if (shortDescriptionErrMsg) {
            // Some error was set in one of the previous business rules.
        }
    })(current, previous);

    GlideElement - getEscapedValue()

    현재 요소에 대해 이스케이프된 값을 가져옵니다.

    표 45. 매개변수
    이름 유형 설명
    없음
    표 46. 반환
    유형 설명
    문자열 현재 요소의 이스케이프된 값입니다.

    다음 예제에서는 getEscapedValue() 메서드를 사용하여 이스케이프 문자가 포함된 인시던트 간단한 설명 필드의 내용을 표시하는 방법을 보여 줍니다.

    /*** Overview - Update incident short description with escape characters and printing ***/
    var inc = new GlideRecord('incident');
    inc.query();
    inc.next();
    inc.short_description = 'Can\'t log into SAP from my laptop today'; 
    inc.update();
    gs.info("Short Description: "+inc.getElement('short_description').toString()); //without escape characters
    gs.info("Escaped Short Description: "+inc.getElement('short_description').getEscapedValue()); // with escape characters

    출력:

    Short Description: Can't log into SAP from my laptop today
    Escaped Short Description: Can\'t log into SAP from my laptop today

    GlideElement - getFieldStyle()

    필드의 CSS 스타일을 가져옵니다.

    표 47. 매개변수
    이름 유형 설명
    없음
    표 48. 반환
    유형 설명
    문자열 필드의 CSS 스타일입니다.
    var fields = current.getFields();
    for (var i = 0; i < fields.size(); i++) { 
      var field = fields.get(i);
      var css_style = field.getFieldStyle();  
      gs.print("CSS style" + "=" + css_style); 
    }

    GlideElement - getGlideObject()

    Glide 개체를 가져옵니다.

    표 49. 매개변수
    이름 유형 설명
    없음
    표 50. 반환
    유형 설명
    객체 Glide 개체입니다.
    function calcDateDelta(start, end, calendar) {
      var cal = GlideCalendar.getCalendar(calendar);
      if (!cal.isValid())
          return null;
      var realStart = start.getGlideObject();
      var realEnd = end.getGlideObject();  
      var duration = cal.subtract(realStart, realEnd);
      return duration;
    }

    GlideElement - getGlideRecord()

    Glide 기록을 가져옵니다.

    표 51. 매개변수
    이름 유형 설명
    없음
    표 52. 반환
    유형 설명
    GlideRecord Glide 기록 객체입니다.
    var grInc = new GlideRecord('incident');
    grInc.get('sys_id','ef43c6d40a0a0b5700c77f9bf387afe3');
    gs.info("Initial grInc - " + grInc.getDisplayValue());
    
    var caller = grInc.getElement("caller_id");
    doit(caller);
    
    function doit(caller) {
      var now_GR = caller.getGlideRecord();
      gs.info("doit gr is - " + now_GR.getDisplayValue());
    }

    출력

    *** Script: Initial grInc - INC0000050
    *** Script: doit gr is - INC0000050

    GlideElement - getHTMLValue(Number maxChars)

    필드의 HTML 값을 반환합니다.

    표 53. 매개변수
    이름 유형 설명
    maxChars 번호 옵션입니다. 반환할 최대 문자 수입니다.
    표 54. 반환
    유형 설명
    문자열 필드의 HTML 값입니다.

    다음 예제에서는 모임 메모의 HTML 컨텐츠를 가져오는 방법을 보여 줍니다.

    /*
      getHTMLValueExt() This Function is used to get HTML Value of a field. It accepts 2 Parameters
    
    a. maxChar- Number - The maximum number of characters to return.
    b. nullSub - String - The value to return if the HTML value is null or empty.
    
    */
    
    
    // get a cab meeting record by its sys_id
    var gr = new GlideRecord('cab_meeting');
    gr.addQuery('sys_id','7777777b6d2a20100sys70id534330f6');
    gr.query();
    
    if(gr.next()){
      var substituteString = 'Meeting Notes Unavailable';
      var maxLength = 50;
      gs.print(gr.meeting_notes.getHTMLValueExt(maxLength, substituteString));
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getHTMLValue() 메서드를 사용하려면 해당 범위 지정 메서드인 getHTMLValue()를 사용합니다. 범위가 지정된 GlideElement - getHTMLValue(Number maxChars)

    GlideElement - getHTMLValueExt(number, maxChar, string, nullSub)

    필드의 HTML 값을 반환하거나, HTML 값이 null이거나 비어 있는 경우 지정된 대체 값을 반환합니다.

    표 55. 매개변수
    이름 유형 설명
    맥스 차르 번호 반환할 최대 문자 수입니다.
    nullSub 문자열 HTML 값이 null이거나 비어 있는 경우 반환할 값입니다.
    표 56. 반환
    유형 설명
    문자열 HTML 값 또는 지정된 대체 값입니다.

    다음 예제에서는 모임 메모의 HTML 컨텐츠를 가져오는 방법을 보여 줍니다.

    // get a cab meeting record by its sys_id
    var gr = new GlideRecord('cab_meeting');
    gr.addQuery('sys_id','7777777b6d2a20100sys70id534330f6');
    gr.query();
    
    if(gr.next()){
      var substituteString = 'Meeting Notes Unavailable';
      var maxLength = 50;
      gs.print(gr.meeting_notes.getHTMLValueExt(maxLength, substituteString));
    }
    선택한 기록에 대한 회의 메모가 비어 있지 않은 경우의 출력:
    <p>Meeting note content.</p>

    GlideElement - getJournalEntry(Number mostRecent)

    가장 최근의 저널 항목 또는 모든 저널 항목을 리턴합니다.

    표 57. 매개변수
    이름 유형 설명
    가장 최근 번호 1인 경우 가장 최근 항목을 반환합니다. -1인 경우 모든 저널 항목을 리턴합니다.
    표 58. 반환
    유형 설명
    문자열

    가장 최근 항목의 경우, 저널 항목의 필드 레이블, 타임스탬프 및 사용자 표시 이름이 포함된 문자열을 반환합니다.

    모든 저널 항목의 경우, 각 항목이 &quot;\n\n&quot;으로 구분된 단일 문자열로 입력된 모든 저널 항목에 대해 동일한 정보를 리턴합니다.

    //gets all journal entries as a string where each entry is delimited by '\n\n'
    var notes = current.work_notes.getJournalEntry(-1); 
    //stores each entry into an array of strings
    var na = notes.split("\n\n");  
                          
    for (var i = 0; i < na.length; i++)                 
      gs.print(na[i]);

    범위가 지정된 등가

    범위가 지정된 애플리케이션에서 getJournalEntry() 메서드를 사용하려면 해당 범위 지정 메서드인 getJournalEntry()를 사용합니다. 범위가 지정된 GlideElement - getJournalEntry(가장 최근 번호)

    GlideElement - getLabel()

    개체의 레이블을 반환합니다.

    표 59. 매개변수
    이름 유형 설명
    없음
    표 60. 반환
    유형 설명
    문자열 개체의 레이블
    var now_GR = new GlideRecord("sc_req_item");
    now_GR.addQuery("request", current.sysapproval);
    now_GR.query();
    while(now_GR.next()) {
        var nicePrice = now_GR.price.toString();
        if (nicePrice != ) {
            nicePrice = parseFloat(nicePrice);
            nicePrice = nicePrice.toFixed(2);
        }
        template.print(now_GR.number + ":  " + now_GR.quantity + " X " + now_GR.cat_item.getDisplayValue() + " at $" + nicePrice + " each \n");
        template.print("    Options:\n");
        var variables = now_GR.variables.getElements();    
        for (var key in variables) {
          var now_V = variables[key];
          if(now_V.getQuestion().getLabel() != ) {
             template.space(4);
             template.print('     ' +  now_V.getQuestion().getLabel() + " = " + now_V.getDisplayValue() + "\n");  
          }
        }
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getLabel() 메서드를 사용하려면 해당 범위 지정 메서드인 getLabel()을 사용합니다. 범위가 지정된 GlideElement - getLabel()

    GlideElement - getLabelLang(문자열 언어)

    매개 변수로 전달된 언어로 된 필드의 레이블 값을 가져옵니다.

    번역된 값을 검색하려면 해당 언어 플러그인이 있어야 합니다. 자세한 내용은 Activate a language 문서를 참조하십시오.

    표 61. 매개변수
    이름 유형 설명
    language 문자열 IETF BCP-47을 준수하는 언어 태그입니다.
    표 62. 반환
    유형 설명
    문자열 전달된 언어의 필드 레이블 값입니다. 번역을 사용할 수 없는 경우 메서드는 현재 사용자의 언어로 번역된 값을 검색합니다. 번역을 사용할 수 없는 경우 결과는 기본적으로 영어로 설정됩니다.

    다음 예제에서는 원래 레이블 텍스트와 수락 (UI 보기) 제목의 독일어 번역을 가져오는 방법을 보여 줍니다.

    var uiView = new GlideRecord("sys_ui_view");
    uiView.get("fa776f6d97700100f309124eda2975bc");
    
    gs.info("getLabel: " + uiView.getElement("title").getLabel());
    gs.info("getLabelLang: " + uiView.getElement("title").getLabelLang("de"));

    출력:

    getLabel: Title
    getLabelLang: Titel

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getLabelLang() 메서드를 사용하려면 해당 범위 지정 메서드인 getLabelLang()을 사용합니다범위가 지정된 GlideElement - getLabelLang(문자열 언어).

    GlideElement - getName()

    필드의 이름을 반환합니다.

    표 63. 매개변수
    이름 유형 설명
    없음
    표 64. 반환
    유형 설명
    문자열 필드 이름입니다.

    다음 예제에서는 sys_user 기록의 각 필드에 대한 이름 및 기타 값을 가져오는 방법을 보여줍니다.

    var userRec = new GlideRecord("sys_user"); // GlideRecord to sys_user table
    
    userRec.get("5137153cc611227c000bbd1bd8cd2005"); // Sys Id of user: Fred Luddy
    
    var fields = userRec.getFields();
    
    for (var i = 0; i < fields.size(); i++) {
    
        var field = fields.get(i);
        var name = field.getName(); // Name of the field
        var label = field.getLabel(); // Label of the field
        var value = field.getDisplayValue(); // Value of the field
    
        gs.info((Number(i) + 1) + ".\n" + "Field Label: " + label + "\n" + "Field Name: " + name + "\n" + "Field Value: " + value);
    
    };

    출력. 결과에는 62개의 필드가 포함되며 공간을 절약하기 위해 줄임표 점(...)으로 잘렸습니다.

    *** Script: 1.
    Field Label: Country code
    Field Name: country
    Field Value: 
    *** Script: 2.
    Field Label: Calendar integration
    Field Name: calendar_integration
    Field Value: Outlook
    ...
    *** Script: 47.
    Field Label: First name
    Field Name: first_name
    Field Value: Fred
    ...
    *** Script: 54.
    Field Label: Last name
    Field Name: last_name
    Field Value: Luddy
    ...

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getName() 메서드를 사용하려면 해당 범위 지정 메서드인 getName()을 사용합니다범위가 지정된 GlideElement - getName().

    GlideElement - getRefRecord()

    지정된 참조 요소에 대한 GlideRecord 객체를 반환합니다.

    경고:
    참조 요소에 값이 포함되어 있지 않으면 NULL 객체가 아닌 빈 GlideRecord 객체가 반환됩니다.
    표 65. 매개변수
    이름 유형 설명
    없음
    표 66. 반환
    유형 설명
    GlideRecord GlideRecord 객체
    
    var grINC = new GlideRecord('incident'); 
    grINC.notNullQuery('caller_id'); 
    grINC.query(); 
    if (grINC.next()) { 
    
    // Get a GlideRecord object for the referenced sys_user record 
    var grUSER = grINC.caller_id.getRefRecord(); 
    if (grUSER.isValidRecord()) 
      gs.print( grUSER.getValue('name') ); 
    
    } 

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getRefRecord() 메서드를 사용하려면 해당 범위 지정 메서드인 getRefRecord()를 사용합니다. 범위가 지정된 GlideElement - getRefRecord()

    GlideElement - getStyle()

    값에 대한 CSS 스타일을 가져옵니다.

    표 67. 매개변수
    이름 유형 설명
    없음
    표 68. 반환
    유형 설명
    문자열 값의 CSS 스타일입니다.
    // Get string of style field from Field Style record
    var cssStyle = now_GR.state.getStyle();

    GlideElement - getTableName()

    필드의 테이블 이름을 반환합니다.

    표 69. 매개변수
    이름 유형 설명
    없음
    표 70. 반환
    유형 설명
    문자열 테이블의 이름입니다. 이는 레코드가 있는 테이블 클래스와 다를 수 있습니다. 제품 설명서의 Tables and Classes를 참조하십시오.
    if (current.approver.getTableName() == "sysapproval_approver") {
      if (current.approver == email.from_sys_id)  {
         current.comments = "reply from: " + email.from + "\n\n" + email.body_text;
     
       // if it's been cancelled, it's cancelled.
      var doit = true;
      if (current.state=='cancelled')
          doit = false;
     
      if (email.body.state != undefined)
         current.state= email.body.state;
     
       if (doit)
          current.update();
    } else {
       gs.log("Approval for task ("+current.sysapproval.getDisplayValue()+") rejected because user sending 
               email( "+email.from+") does not match the approver ("+current.approver.getDisplayValue()+")");
    }
     
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 getTableName() 메서드를 사용하려면 해당 범위 지정 메서드인 getTableName()범위가 지정된 GlideElement - getTableName()사용합니다.

    GlideElement - getTextAreaDisplayValue()

    연결된 필드의 표시 값을 검색하고 HTML을 이스케이프합니다.

    표 71. 매개변수
    이름 유형 설명
    없음
    표 72. 반환
    유형 설명
    문자열 연결된 필드의 이스케이프된 표시 값 HTML입니다.

    다음 예제에서는 KB 문서의 표시 값을 검색합니다.

    var grh = new GlideRecord('kb_knowledge');
    grh.get('c85cd2519f77230088aebde8132e70c2');  // Knowledge record sys_id
    var t = grh.text.getTextAreaDisplayValue(); // Text is HTML type field
    var d = GlideXMLUtil.parseHTML(t); // Parse the HTML
    var b = d.getDocumentElement().getTextContent().trim();
    gs.info(b);

    출력:

    This article explains how to use automatic replies in Outlook 2010 for Exchange accounts.
    
    Setting Up Automatic Replies
    
    Click the 
    File tab.
    Click 
    Automatic Replies.
    Select 
    Send automatic replies.
    If desired, select the 
    Only send during this time range check box to schedule when your out of office replies are active. If you do not specify a start and end time, auto-replies will be sent until you select the
     Do not send automatic replies check box.
    On the 
    Inside My Organization tab, type the response that you want to send to colleagues while you are out of the office.
    On the 
    Outside My Organization tab, select the 
    Auto-reply to people outside my organization check box, and then type the response that you want to send while you are out of the office. Select whether you want replies sent to 
    My contacts only or to 
    Anyone outside my organization who sends you messages.
    
    NOTE:
    If you select 
    My Contacts only in step 6, replies will be sent 
    only to contacts that exist in your Contacts folder.
    
    
    
    Using Rules With Automatic Replies
    It is also possible to use rules to manage your messages while you are out of office. For example, you can create rules to automatically move or copy messages to other folders, to delete messages, to send custom replies, and so on.
    
    Click the 
    File tab.
    Click 
    Automatic Replies.
    Click 
    Rules, and then click 
    Add Rule.
    Under 
    When a message arrives that meets the following conditions, specify the conditions that the message must meet for the rule to be applied. If you want to specify more conditions, click 
    Advanced, enter or select the options that you want, and then click 
    OK.
    If you want to specify that this rule must be applied last, select the 
    Do not process subsequent rules check box.
    Under 
    Perform these actions, select the actions that you want. You can select more than one action.
    Click 
    OK three times.
    
    NOTES:
    
    Automatic Replies rules can also be edited by following the above procedure.
    To turn Automatic Replies rules on or off, in the Automatic Reply Rules dialog box, select or clear the check box of the rule that you want to turn on or off.
    

    GlideElement - getValue()

    데이터베이스의 필드 값을 반환합니다.

    표 73. 매개변수
    이름 유형 설명
    없음
    표 74. 반환
    유형 설명
    문자열 필드의 값입니다.

    다음 예에서는 데이터베이스에서 지정된 필드의 값을 검색합니다.

    var now_GR = new GlideRecord('incident');
    now_GR.get('9c573169c611228700193229fff72400'); //INC0000001
    gs.info('Display Values');
    gs.info('Opened at ' + now_GR.opened_at.getDisplayValue());
    gs.info('Opened by ' + now_GR.opened_by.getDisplayValue());
    gs.info('Priority ' + now_GR.priority.getDisplayValue());
    gs.info('Values');
    gs.info('Opened at ' + now_GR.opened_at.getValue());
    gs.info('Opened by ' + now_GR.opened_by.getValue());
    gs.info('Priority ' + now_GR.priority.getValue());
    

    출력:

    Display Values
    Opened at 2022-02-01 15:09:51
    Opened by Joe Employee
    Priority 1 - Critical
    Values
    Opened at 2022-02-01 23:09:51
    Opened by 681ccaf9c0a8016400b98a06818d57c7
    Priority 1
    

    GlideElement - getXHTMLValue()

    필드의 XHTML 값을 검색합니다.

    표 75. 매개변수
    이름 유형 설명
    없음
    표 76. 반환
    유형 설명
    문자열 XHTML 값

    GlideElement - getXMLValue()

    필드의 XML 값을 문자열로 가져옵니다.

    표 77. 매개변수
    이름 유형 설명
    없음
    표 78. 반환
    유형 설명
    문자열 XML 값

    GlideElement - hasAttribute(attributeName 문자열)

    필드에 특정 속성이 있는지 여부를 결정합니다.

    표 79. 매개변수
    이름 유형 설명
    attributeName 문자열 검사할 속성
    표 80. 반환
    유형 설명
    부울 필드에 속성이 있으면 True이고, 그렇지 않으면 false입니다.
    var totalCritical = 0;
     
    var filledCritical = 0; var fields = current.getFields(); gs.print(fields); for (var num = 0; num < fields.size(); num++) { 
     
        gs.print("RUNNING ARRAY VALUE " + num);
       var ed = fields.get(num).getED();
       if(ed.hasAttribute("tiaa_critical")) {
           gs.print("CRITICAL FIELD FOUND");
           totalCritical ++;
           if (!fields.get(num).isNil()) {
               filledCritical ++;
           }
       }
     
    } var answer = 0; gs.print("TOTAL - " + totalCritical); gs.print("FILLED - " + filledCritical); if (filledCritical > 0 && totalCritical > 0){ 
     
        var pcnt = (filledCritical/totalCritical)*100;
       answer = pcnt.toFixed(2);;    
     
    } answer;

    GlideElement - hasRightsTo(operationName 문자열)

    사용자에게 특정 작업을 수행할 수 있는 권한이 있는지 여부를 결정합니다.

    표 81. 매개변수
    이름 유형 설명
    운영 이름 문자열 검사할 운영의 이름
    표 82. 반환
    유형 설명
    부울 사용자에게 작업을 수행할 수 있는 권한이 있으면 true이고, 그렇지 않으면 false입니다.

    사용자에게 작업을 수행할 수 있는 권한이 있는지 여부를 나타내는 플래그입니다.

    유효한 값은 다음과 같습니다.
    • true: 사용자에게 권한이 있습니다.
    • false: 사용자에게 권한이 없습니다.

    다음 예제에서는 사용자에게 특정 테이블을 읽을 수 있는 권한이 있는지 확인하는 방법을 보여 줍니다.

    // Pass table name and userId to check if user has read access against given table name
    checkAccess('incident', 'adela.cervantsz');
    
    function checkAccess(tableName, userID) {
    
        var inc = new GlideRecordSecure(tableName);
        inc.get('$[sys_id]');
    
        var secureManager = GlideSecurityManager.get();
    
        //fetch a different user, using user_name field on the target user record
        var userObj = gs.getUser().getUserByID(userID); 
        secureManager.setUser(userObj);
    
        var access = 'record/incident/read';
    
        //check if user has right to access
        var canRead = secureManager.hasRightsTo(access, inc); 
        gs.info('canRead: ' + canRead);
    }

    출력:

    canRead: false

    GlideElement - hasValue()

    필드에 값이 있는지 여부를 결정합니다.

    표 83. 매개변수
    이름 유형 설명
    없음
    표 84. 반환
    유형 설명
    부울 필드에 값이 있으면 True이고, 그렇지 않으면 false입니다.

    GlideElement - nil()

    필드가 null인지 여부를 확인합니다.

    표 85. 매개변수
    이름 유형 설명
    없음
    표 86. 반환
    유형 설명
    부울 필드가 null이거나 빈 문자열이면 True이고, 그렇지 않으면 false입니다.
    if (current.start_date.changes() || current.end_date.changes() || current.assigned_to.changes()) { 
      if (!current.start_date.nil() && !current.end_date.nil() && !current.assigned_to.nil()) {
     gs.eventQueue("change.calendar.notify", current, current.assigned_to, previous.assigned_to);
     
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 nil() 메서드를 사용하려면 해당 범위 지정 메서드인 nil()을 사용합니다범위가 지정된 GlideElement - nil().

    GlideElement - setDateNumericValue(밀리초 수)

    기간 필드에 대해 1970년 1월 1일 00:00:00 GMT 이후의 기간 필드를 밀리초 단위로 설정합니다. 기간 필드가 이미 GlideDateTime 객체이므로 GlideDateTime 객체를 생성할 필요가 없습니다.

    표 87. 매개변수
    이름 유형 설명
    밀리초 번호 기간별로 스팬된 밀리초 수입니다.
    표 88. 반환
    유형 설명
    void
    var inc = new GlideRecord('incident');
    inc.get('17c90efb13418700cc36b1422244b05d');
    var timems = inc.calendar_duration.dateNumericValue();
    timems = timems + 11*1000; 
    inc.calendar_duration.setDateNumericValue(timems)
    gs.info(inc.calendar_duration.getValue());

    출력: 1970-01-01 00:01:38

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 setDateNumericValue() 메서드를 사용하려면 해당 범위 지정 메서드인 setDateNumericValue()를 사용합니다. 범위가 지정된 GlideElement - setDateNumericValue(밀리초 수)

    GlideElement - setDisplayValue(객체 displayValue)

    필드의 표시 값을 설정합니다.

    표 89. 매개변수
    이름 유형 설명
    displayValue 객체 표시할 값입니다.
    표 90. 반환
    유형 설명
    void

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 setDisplayValue() 메서드를 사용하려면 해당 범위 지정 메서드인 setDisplayValue()범위가 지정된 GlideElement - setDisplayValue(객체 값)사용합니다.

    GlideElement - setError(문자열 메시지)

    연결된 필드(요소)에 오류 메시지를 추가합니다.

    getError() 메서드를 사용하여 오류 메시지를 검색할 수 있습니다.

    표 91. 매개변수
    이름 유형 설명
    없음
    표 92. 반환
    유형 설명
    없음
    if ((!current.u_date1.nil()) && (!current.u_date2.nil())) {
      var start = current.u_date1.getGlideObject().getNumericValue();
      var end = current.u_date2.getGlideObject().getNumericValue();
      if (start > end) {
        gs.addInfoMessage('start must be before end');
        current.setAbortAction(true);
        current.u_date1.setError('start must be before end');
      }
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 setError() 메서드를 사용하려면 해당 범위 지정 메서드인 setError()를 사용합니다범위가 지정된 GlideElement - setError(errorMessage 문자열).

    GlideElement - setInitialValue(객체 값)

    필드의 초기 값을 설정합니다.

    이 메서드는 더 이상 사용되지 않습니다. 이 기능에 사용합니다 GlideElement - setValue(객체 값) .

    표 93. 매개변수
    이름 유형 설명
    객체 필드의 초기 값입니다.
    표 94. 반환
    유형 설명
    void

    GlideElement - setJournalEntry(String entry, String userName)

    저널 항목 및 작성자를 작업 메모 또는 코멘트 필드로 추가합니다.

    표 95. 매개변수
    이름 유형 설명
    항목 문자열 저널 항목의 내용입니다.
    userName 문자열 옵션입니다. 저널 항목의 특성을 지정할 사용자입니다. 저널 항목의 작성자 필드를 설정하지 않습니다.
    표 96. 반환
    유형 설명
    없음

    다음 예제에서는 작업 메모와 작성자를 기록에 추가하는 방법을 보여줍니다.

    var now_GR = new GlideRecord("incident");
    
    now_GR.addQuery("sys_id", "<sys_id_value>");
    now_GR.query();
    
    if(now_GR.next()){
      now_GR.work_notes.setJournalEntry("Content of the journal entry.", "abel.tuter");  
      now_GR.update();
    }

    GlideElement - setValue(객체 값)

    필드의 값을 설정합니다.

    주:
    이 메서드를 호출하기 전에 기존 레코드를 쿼리하거나 now_GR.initialize() 메서드를 사용하여 새 레코드를 초기화하여 요소가 이미 존재해야 합니다.
    표 97. 매개변수
    이름 유형 설명
    객체 필드를 설정할 값입니다.
    표 98. 반환
    유형 설명
    void

    문자열을 전달하는 값을 설정합니다.

    var glideRecord = new GlideRecord('incident');
    glideRecord.query('priority','1');
    glideRecord.next();
    glideRecord.short_description.setValue('Network failure');

    객체를 전달하는 값을 설정합니다.

    var now_GR  = new GlideRecord('student');
    now_GR.initialize();
    now_GR.setValue('first_name', 'Joe');
    now_GR.setValue('last_name', 'Smith');
    now_GR.insert();

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 setValue() 메서드를 사용하려면 해당 범위 지정 메서드인 setValue()를 사용합니다범위가 지정된 GlideElement - setValue(객체 값).

    GlideElement - toString()

    필드의 값을 문자열로 변환합니다.

    표 99. 매개변수
    이름 유형 설명
    없음
    표 100. 반환
    유형 설명
    문자열 필드의 값(문자열)입니다.
    doit();
     
    function doit() { 
     
      var now_GR = new GlideRecord('sys_user');
      now_GR.query();
      while (now_GR.next()) {
      if ((now_GR().length != now_GR.first_name.toString().trim().length) || (now_GR.last_name.toString().length 
             != now_GR.last_name.toString().trim().length)) {
          now_GR.first_name = now_GR.first_name.toString().trim();
          now_GR.last_name = now_GR.last_name.toString().trim();
          now_GR.autoSysFields(false);
          now_GR.update();
        }
      }
     
    }

    범위가 지정된 등가

    범위가 지정된 응용 프로그램에서 toString() 메서드를 사용하려면 해당 범위 지정 메서드인 toString()을 사용합니다범위가 지정된 GlideElement - toString().