シュガーの REST API v4 を介して複数選択入力から複数の値をフォームに挿入する方法についての知識は誰にでもあります。これに関するドキュメントは見つかりませんでした。次は1つの値を正しく挿入しますが、複数の値を保存することに固執しています:
function getSugar($method, $parameters){
$url = 'https://****.sugarondemand.com/service/v4/rest.php';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$json = json_encode($parameters);
$postArgs = array(
'method' => $method,
'input_type' => 'JSON',
'response_type' => 'JSON',
'rest_data' => $json
);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArgs);
$response = curl_exec($curl);
if (!$response) {
die("Connection Failure.\n");
}
$result = json_decode($response);
if ( !is_object($result) ) {
die("Error handling result.\n");
}
if($method == "set_entry" || $method == "login"){
if ( !isset($result->id) ) {
die("Error: {$result->name} - {$result->description}\n.");
}
$id = $result->id;
return $id;
}else{
if ( !is_object($result) ) {
var_dump($response);
die("Error handling result.\n");
}
return true;
}
}
$x = "ABC";
$parameters = array(
'session' => $sessionId,
'module' => 'Leads',
'name_value_list' => array(
array('name' => 'programs_c', 'value' => $x),
),
);
$method = "set_entry";
$leadID = getSugar($method, $parameters);
フィールド「programs_c」は、いくつかのドロップダウン値を持つ砂糖のカスタム複数選択フィールドです。for-each ループを実行しようとしましたが、最後の値しか挿入されません。また、配列内に配列を挿入する可能性のあるほぼすべてのバリエーションを試みましたが、成功しませんでした。どんな助けでも大歓迎です!私はこれを理解しようと何時間も費やしました。これを処理する方法についての洞察/指示を事前に感謝します。