gpt4 book ai didi

php - 如何通过 Rest API 将多选值发布到 SugarCRM?

转载 作者:行者123 更新时间:2023-12-04 21:14:30 24 4
gpt4 key购买 nike

任何人都知道如何通过 sugar 的 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”是 sugar 中的自定义多选字段,具有多个下拉值。我试过运行一个 for-each 循环,但它只插入最后一个值。我还尝试了几乎所有可能的在数组中插入数组的变体,但都没有成功。任何帮助深表感谢!我花了几个小时试图弄清楚这一点。提前感谢您提供有关如何处理此问题的任何见解/指导。

最佳答案

以这种格式放置字段内容行得通吗?

^value1^,^value2^,^value3^

关于php - 如何通过 Rest API 将多选值发布到 SugarCRM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14446616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com