gpt4 book ai didi

javascript - 为什么我在执行更新请求后总是收到 "Duplicate Alert"错误?

转载 作者:行者123 更新时间:2023-12-02 23:07:43 25 4
gpt4 key购买 nike

我正在为 Vtiger CRM 编写 Chrome 扩展。我需要创建为项目页面上 CRM 中的“提案文本”字段添加值的能力。

这里是文档:https://www.vtiger.com/docs/rest-api-for-vtiger#/Update

我是如何做到的:

  1. 从 Vtiger API 获取项目。
  2. 更改项目对象中的值“cf_potials_proposaltext”。
  3. 发出 POST(根据文档要求)请求更新 Vtiger API 端点,发送更新后的项目对象
  4. 获取“重复警报”响应。

我绝对确定,因为我检查了我正在发送修改后的项目对象 - 使用console.log“Temprorary_1”(在vtigerAddProposal中)和“Temprorary_2”(在vtigerUpdatePotential中),还检查了Chrome开发控制台中的更改值网络选项卡..

这是我的代码:

function vtigerAddProposal() {
var temprorary_potential;
var dialog = $('#dialog');

chrome.storage.sync.get(['proposal'], function(result) {
$.ajax( {
url: 'https://roonyx.od2.vtiger.com/restapi/v1/vtiger/default/retrieve',
type: 'GET',
data: {
'id': localStorage.getItem('vtiger_last_opportunity_id')
},
success: function( response ) {
temprorary_potential = response['result'];
console.log("Temprorary_1: " + JSON.stringify(temprorary_potential, null, 2));
temprorary_potential['cf_potentials_proposaltext'] = result.proposal;
vtigerUpdatePotential(temprorary_potential);
},
error: function (response) {
console.log("Failed to get opportunity from Vtiger.");
$('#dialog-inner-text').text("Vtiger: " + response.status + " " + response.statusText);
dialog.show(800);
console.log(response);
}
});

});
}

function vtigerUpdatePotential(data) {
var dialog = $('#dialog');
console.log("Temprorary_2: " + JSON.stringify(data, null, 2));

// Second Part
$.ajax( {
url: 'https://roonyx.od2.vtiger.com/restapi/v1/vtiger/default/update',
type: 'POST',
data: {
element: JSON.stringify(data)
},
success: function( response ) {
console.log("Successfully updated Vtiger potential.")
console.log(response);
localStorage.removeItem('vtiger_last_opportunity_id'); // в случае успеха удаляем oppId
},
error: function (response) {
console.log("Failed to update potential in Vtiger.")
$('#dialog-inner-text').text("Vtiger potential wasn't update: " + response.status + " " + response.statusText);
dialog.show(800);
console.log(response);
}
});
}

提前谢谢您。

最佳答案

使用 revise https://www.vtiger.com/docs/rest-api-for-vtiger#/Revise 解决了问题一次而不是更新。感谢@pinaki

关于javascript - 为什么我在执行更新请求后总是收到 "Duplicate Alert"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57509628/

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