Example 3: Insert a record in an external source

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:1分
  • In this example, we create a script to insert an incident record into the external source.

    (function executeInsert(v_record) {
    	var gr = new GlideRecord("incident");
    	gr.setNewGuidValue(v_record.sys_id);
    
    	delete v_record["sys_id"];
    	gr.number = v_record.u_number;
    	gr.short_description = v_record.u_short_description;
    	if (!gr.insert()) {
    		v_record.setLastErrorMessage("Error on insert: " + gr.getLastErrorMessage());
    	}
    })(v_record);