This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 検証用レコード作成 | |
*/ | |
List<ObjectB__c> records = new List<ObjectB__c>(); | |
records.add(new ObjectB__c(externalId__c = 'TerraSky')); //半角アルファベット | |
records.add(new ObjectB__c(externalId__c = 'TerraSky')); //全角アルファベット | |
records.add(new ObjectB__c(externalId__c = 'テラスカイ')); //半角カタカナ | |
records.add(new ObjectB__c(externalId__c = 'テラスカイ')); //全角カタカナ | |
insert records; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Opportunity" extensions="ValidateController"> | |
<apex:pageBlock > | |
<apex:outputLabel for="uname">ログインユーザ名:</apex:outputLabel> | |
<apex:outputText id="uname">{!$User.LastName} {!$User.FirstName}</apex:outputText> | |
<br/> | |
<apex:outputLabel for="result">入力チェック結果:</apex:outputLabel> | |
<apex:outputText id="result">{!isValidRecord}</apex:outputText> | |
</apex:pageBlock> | |
</apex:page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidateController{ | |
public class ValidateException extends Exception{} | |
private ApexPages.standardController controller; | |
public ValidateController(ApexPages.standardController stdController){ | |
controller = stdController; | |
} | |
/** | |
* 入力チェッククラスの呼出し | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidateForKacho extends ValidateCommon{ | |
//課長プロファイルに関する入力チェックを実装 | |
protected override Boolean doCustomizedValidate(Opportunity opp){ | |
return false; //検証のため、課長はFalseを返します。 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValidateForBucho extends ValidateCommon{ | |
public class buchoValidateException extends Exception{} | |
//部長プロファイルに関する入力チェックを実装 | |
protected override Boolean doCustomizedValidate(Opportunity opp){ | |
//検証のため、部長は例外を生成します。 | |
throw new buchoValidateException('部長は例外が発生します。'); | |
return true; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual class ValidateCommon{ | |
public Boolean doValidate(Opportunity opp){ | |
Boolean validateResult = true; | |
//共通入力チェック | |
// 値引率がカスタム設定の定義値以下のときTrue | |
validateResult = (opp.DiscountRate__c <= ValidateSettings__c.getInstance().DiscountRate__c); | |
//共通入力チェック=Trueの場合、個別Validateを実施 | |
if(validateResult){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page > | |
<apex:pageBlock > | |
<apex:outputLabel for="uname">ログインユーザ名:</apex:outputLabel> | |
<apex:outputText id="uname">{!$User.LastName} {!$User.FirstName}</apex:outputText> | |
<br/> | |
<apex:outputLabel for="rate">値引率:</apex:outputLabel> | |
<apex:outputText value="{0, number, percent}" id="rate"> | |
<apex:param value="{!$Setup.ValidateSettings__c.DiscountRate__c}"/> | |
</apex:outputText> | |
</apex:pageBlock> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//通貨レートマスタの取得 | |
List<CurrencyRate__c> rates = [SELECT Id,Name,CurrencyISO__c, YYYYMM__c FROM CurrencyRate__c]; | |
//商談に通貨レート参照関係を構築 | |
for(Opportunity opp:Trigger.New){ | |
for(CurrencyRate__c cr:rates){ | |
if(opp.CurrencyISO__c == cr.CurrencyISO__c //通貨コードが一致 かつ | |
&& String.valueOf(opp.CloseDate.year()) + String.valueOf(opp.CloseDate.month()) == cr.YYYYMM__c) // 年月が一致 | |
opp.CurrencyRate__c = cr.Id; | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger AccountTrigger on Account (before update){ | |
//更新された全取引先に紐づく成立商談の金額を集計 | |
for(Account acc:Trigger.New){ | |
Decimal amountSum = 0; | |
for(Opportunity opp:[SELECT Id,Amount FROM Opportunity | |
WHERE AccountId = :acc.Id | |
AND isWon = true]){ | |
amountSum += opp.Amount; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger OpportunityTrigger on Opportunity (after insert, after update) { | |
Map<String,Decimal> amountSumBykigyoCode = new Map<String, Decimal>(); | |
//更新された全商談の企業コードを変数に格納 | |
for(Opportunity opp:Trigger.New){ | |
amountSumBykigyoCode.put(opp.KigyoCode__c, 0); | |
} | |
// 取得された企業コードの取引先の取得と商談合計金額の初期化 |
NewerOlder