2017年3月30日木曜日

FileMaker PowerShell と連携、戻り値取得。cmdコマンドを実行。プラグイン不要

FileMaker PowerShell と連携、戻り値取得。cmdコマンドを実行。プラグイン不要。
OS:Windows

FileMaker 12以降?

フィールド:Command
値:
$Rsult=cmd /C dir /b "c:\" ;
$return=$Rsult -join "%0A" ;

フィールド:CallBack
値:
Start-Process ('fmp://$/{ファイル名}?script=FireCommand&$Return='+$return);

FileMakerから実行
以下のようにすると送信結果の戻り値の取得が取得出来ます。
スクリプト名:FireCommand
If [ not IsEmpty ( $Return )]
フィールド設定 [PS::Result; $return]
フィールドへ移動 []
現在のスクリプト終了 []
Else If [Get ( スクリプト引数 ) = 1]
変数を設定 [$Script; 値:Quote ( Substitute ( PS::Command & PS::CallBack ; ¶ ; "" ) )]
Event を送信 [「aevt」; 「odoc」; "powershell -windowstyle hidden -Command " & $Script]
End If



※戻り値が多いと全部は、取得できません。
そんなときは、以下を使えば、解決します。
ProcessMakerTL(プロセス メーカー ティー エル)
FileMaker補助アプリケーション

FileMaker PowerShell と連携、戻り値取得。dirコマンドっぽく使う。プラグイン不要


FileMaker PowerShell と連携、戻り値取得。dirコマンドっぽく使う。プラグイン不要。
OS:Windows

FileMaker 12以降?

フィールド:Command
値:
$Rsult=Get-ChildItem "C:\" | Select-Object Fullname;
$return=$Rsult.FullName -join "%0A" ;

フィールド:CallBack
値:
Start-Process ('fmp://$/{ファイル名}?script=FireCommand&$Return='+$return);

FileMakerから実行
以下のようにすると送信結果の戻り値の取得が取得出来ます。
スクリプト名:FireCommand
If [ not IsEmpty ( $Return )]
フィールド設定 [PS::Result; $return]
フィールドへ移動 []
現在のスクリプト終了 []
Else If [Get ( スクリプト引数 ) = 1]
変数を設定 [$Script; 値:Quote ( Substitute ( PS::Command & PS::CallBack ; ¶ ; "" ) )]
Event を送信 [「aevt」; 「odoc」; "powershell -windowstyle hidden -Command " & $Script]
End If

2017年3月29日水曜日

ChatWork へ新しいタスクを追加|PowerShell|FileMaker

ChatWork へ新しいタスクを追加
http://developer.chatwork.com/ja/endpoint_rooms.html#POST-rooms-room_id-tasks
PowerShell
FileMaker

以下のPowerShellを実行すれば、ChatWork へ新しいタスクが追加されます。

フィールド:Command
値:
Add-Type -AssemblyName System.Web;
$encode = [System.Text.Encoding]::UTF8;
[DateTime]$dateTime = '2017/4/1';
$limit = '{0:#}' -f (New-TimeSpan 1970/1/1 $dateTime).TotalSeconds;
$headers = @{'X-ChatWorkToken' = '自分のAPIトークン'};
$body='body='+[System.Web.HttpUtility]::UrlEncode('こんにちわ',$encode);
$body+='&limit='+$limit;
$body+='&to_ids='+'担当者のアカウントID';
$return=Invoke-RestMethod -Method POST -Uri https://api.chatwork.com/v2/rooms/{room_id}/tasks -Headers $headers -body $body;
$return=$return.task_ids ;

FileMakerから実行
以下のようにすると送信結果の「task_ids」が取得出来ます。

フィールド:CallBack
値:
Start-Process ('fmp://$/PowerShell?script=FireCommand&$Return='+$return);

スクリプト名:FireCommand
If [ not IsEmpty ( $Return )]
フィールド設定 [PS::Result; $return]
フィールドへ移動 []
現在のスクリプト終了 []
Else If [Get ( スクリプト引数 ) = 1]
変数を設定 [$Script; 値:Quote ( Substitute ( PS::Command & PS::CallBack ; ¶ ; "" ) )]
Event を送信 [「aevt」; 「odoc」; "powershell -windowstyle hidden -Command " & $Script]
End If