Request Approval UI Action をクライアントで実行するように設定し (Client チェックボックス)、Onclick フィールドを requestApproval(); に設定できます。次に、スクリプト本体のガイドラインとして次のコードを使用します。これにより、UI アクションを 2 段階で実行できます。検証ロジックを記述できるクライアントと、検証ロジックが成功したときのサーバー (gsftSubmit によってトリガーされる)。
システムには、この種のコードを使用するデフォルトの UI アクションがいくつかあります。「スクリプトに gsftSubmit が含まれる」UI アクションを検索して、他の例を参照してください。
function requestApproval(){
// Do your client side validation here
if (g_form.getValue('comments') == '') {
return false; //Abort submission if your validation fails
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'request_approval');
// MUST call the 'Action name' set in this UI Action.
// Make sure this name doesn't conflict with an existing
// UI Action if this is a custom action.
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
function serverResolve(){
change_request.state = 1;
// other server side actions you wish to take
}