import { actionAddins } from "."; import { IField,IAction,IActionResult, IActionNode, IActionProperty,IContext,IVarName} from "../types/ActionTypes"; //右UI画面propertyのname:型: interface ILoginUserGetterProps{ //変数名にセット:値がオブジェクトの形式 verName:IVarName; } //IActionインタフェースを実装する新しいクラスActionを作成: export class LoginUserGetterAction implements IAction{ name: string; //importから導入顕示定義 actionProps: IActionProperty[]; //上方のinterface Propsから、props受ける属性を定義: props:ILoginUserGetterProps; //関数定義に必要な類名を構築: constructor(){ //pgAdminDBに登録したアクション名(name/subtitle)一致する必要がある: this.name="ログインユーザー取得"; this.actionProps=[]; this.register(); //プロパティ属性初期化: this.props={ verName:{name:''} } //リセット上記登録表: this.register(); } /** * アクションの処理を実装する * @param actionNode アクションノード * @param event Kintoneのイベント * @param context コンテキスト(レコード、変数情報を持っている) * @returns */   //非同期処理ある関数下のある属性: async process(actionNode:IActionNode,event:any,context:IContext):Promise { let result={ canNext:true, result:false }; try{ //属性設定を取得する: this.actionProps=actionNode.actionProps; //プロパティ設定のデータ型は必要な情報含めますか?全部不存在時return: if (!('verName' in actionNode.ActionValue)) { return result } //既定のプロパティのインタフェースへ変換: this.props = actionNode.ActionValue as ILoginUserGetterProps; ////////////////////////////////////////////////////////////////////////////////////// if(this.props.verName&&this.props.verName.name!==''){ context.variables[this.props.verName.name]=kintone.getLoginUser(); // window.alert("変数名"+this.props.verName.name+"の値は"+context.variables[this.props.verName.name]+"です"); // event.record["変数運用先のユーザ選択フィールド"].value= [{code:context.variables[this.props.verName.name].code}]; } ////////////////////////////////////////////////////////////////////////////////////// result= { canNext:true, result:true } return result; ////////////////////////////////////////////////////////////////////////////////////// }catch(error:any){; context.errors.handleError(error,actionNode); return { canNext:false, result:false } } } ////////////////////////////////////////////////////////////////////////////////////// register(): void { actionAddins[this.name]=this; } } new LoginUserGetterAction();