Ajax呼び出しがdbupdate/ save操作を実行している場合は、after_save
ロジックフックの使用を調べることができます。
編集:例えば:あなたはこのコードを試すことができます、のコードを見てください<sugar_root>/modules/Notes/Note.php
$note = new Note();
$note->modified_user_id = $current_user->id;
$note->created_by = $current_user->id;
$note->name = 'New';
$note->parent_type = "Accounts";
$note->parent_id = $bean->parent_id;
$note->description = $bean->description;
$note->save();
アタッチメントに関しては、少し注意が必要です。Sugarは、添付ファイルがupload_fileオブジェクトであることを想定しています。<sugar_root>/modules/Notes/controller.php
関数のコードを見てaction_save()
、<sugar_root>/include/upload_file.php
ハック:これは正しい方法ではありませんが、機能します。上記のコードを少し変更し、move
関数を巧妙に使用することで、添付ファイルを機能させることができます。Sugarは、cache/upload
作成されたメモのIDを使用して添付ファイルをフォルダーに保存します。
$note->filename = "Yourfilename.txt" //your file name goes here
$note->file_mime_type = "text/plain" // your file's mime type goes here
$new_note_id = $note->save();
move(your_file_location, cache/upload/$new_note_id)
//don't add a extension to cache/upload/$new_note_id
HTH
PS:テストされていないコード