修改以删除Lightning中的文件

时间:2019-07-09 12:26:08

标签: javascript salesforce-lightning

我目前有一个重置按钮,该按钮可以删除所有附件并重置某些内容-但是我们是在Classic中构建的,因此我不确定如何修改它以包含文件,因为随着闪电般的变化,它已经改变了。

任何人都可以给我一些关于如何包括所有类型的附件并使之闪电化的指示吗?

{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")} 

function resetDemo(oppId) { 
var query = "select Id, OrderNumber__c, eContract_Status__c, StageName from Opportunity where Id = '" + oppId + "'"; 
console.log("resetDemo("+oppId+"): "+query); 
var result = sforce.connection.query(query); 
if(!result || result['size'] != 1) { 
alert("Couldn't retrieve the Opportunity. " + result); 
return null; 
} 
var obj = result.getArray('records')[0]; 

obj.OrderNumber__c = ' '; 
obj.eContract_Status__c = ' '; 
obj.StageName = 'Negotiation/Review'; 

result = sforce.connection.update([obj]); 
/* 
if(!result || result['success'] != 'true') { 
alert("Couldn't udpate the Opportunity. " + result); 
return null; 
} 
*/ 
} 

function deleteFeedItems(oppId) { 
var query = "select Id, Body, ParentId from FeedItem where ParentId = '" + oppId + "' limit 200"; 
console.log("deleteFeedItems("+oppId+"): "+query); 
var result = sforce.connection.query(query); 
if(!result) { 
alert("Couldn't retrieve FeedItems. " + result); 
return null; 
} 

var feedList = result.getArray('records'); 
var delList = []; 
for(var i = 0; i < feedList.length; i++) { 
//if(feedList[i].Body != null && feedList[i].Body.indexOf("Envelope for Opportunity ") == 0) { 
delList.push(feedList[i].Id); 
//} 
} 
console.log('Deleting FeedItems:\n' + delList); 

result = sforce.connection.deleteIds(delList); 
console.log(result); 
return result; 
} 


function deleteStatusRecords(id) { 
var query = "select Id from dsfs__DocuSign_Status__c where dsfs__Opportunity__c = '" + id + "' limit 200"; 
console.log("deleteStatusRecords("+oppId+"): "+query); 
var result = sforce.connection.query(query); 
if(!result) { 
alert("Couldn't retrieve DocuSign Statuses. " + result); 
return null; 
} 

var feedList = result.getArray('records'); 
var delList = []; 
for(var i = 0; i < feedList.length; i++) { 
//if(feedList[i].Body != null && feedList[i].Body.indexOf("Envelope for ") == 0) { 
delList.push(feedList[i].Id); 
//} 
} 
console.log('Deleting statuses:\n' + delList); 

result = sforce.connection.deleteIds(delList); 
console.log(result); 
return result; 
} 

var oppId = "{!Opportunity.Id}"; 
resetDemo(oppId); 
deleteFeedItems(oppId); 
deleteStatusRecords(oppId); 
window.location.reload();

0 个答案:

没有答案