我正在尝试在Apex中创建一个触发器,它有助于在阶段更新时增加计数



基本上,当Stage标记为Closed Won时,Opportunity中标记为Closed_Won__c的数字字段应将其计数增加1。有人能帮我输入代码吗

你是说你是新来的。从Salesforce的Trailheads开始。它们非常适合从SF开始旅程的人。

以下是有关触发器的模块链接:https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers/apex_triggers_intro

不过,我建议您查看其他模块,从Apex Basics开始:https://trailhead.salesforce.com/content/learn/modules/apex_database

这是的代码

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
for(Opportunity opp : [SELECT Id,StageName FROM Opportunity Where Id IN :Trigger.New])
{
if(opp.StageName == 'Closed Won')
{
//add the code to increment the corresponding value here.
}
}
}

最新更新