SlideShare a Scribd company logo
1 of 9
z
親レコード承認申請中
添付ファイルロック不可
への対策案
Created By: Kagawa Hoang
Created Date: 2020/08/30
z
Agenda
1. 承認プロセスのロック仕組みについて
2. 承認申請中ファイルロック不可の課題
3. 承認申請中ファイルロック不可への対策案
4. ソースコード
z
1. 承認プロセスのロック仕組みについて
格納先
ContentDocument:ファイ
ル中身を格納
ContentDocumentLink:
ファイルの共有先を格納
子オブジェ
クト
親
承認申請
子オブジェ
クト
ファイル
オブジェク
ト
主従関係 参照関係 参照関係
一般的に申請確定、回付中、
承認済み申請承認対象レ
コードをロックとする
z
2. 承認申請中ファイルロック不可の課題
格納先
ContentDocument:ファイ
ル中身を格納
ContentDocumentLink:
ファイルの共有先を格納
子オブジェ
クト
親
承認申請
子オブジェ
クト
ファイル
オブジェク
ト
主従関係 参照関係 参照関係
①申請承認レコードをロック際に勝手に主従関係子
レコードも親のロック状態を継承される
②参照関係子レコード又は添付ファイル(参照関
係)が親のロック状態を継承しません。(=>Unlock)
z
3. 承認申請中ファイルロック不可への対策案
「添付ファイルの関連リスト」に
て「ファイルをアップロード」を防
ぐ
「添付ファイルのレコードアクション」関連リストにて「新しいバージョンをアップロード」、「ファイルの詳
細を編集」、「削除」、「レコードから削除」を防ぐ
z
3. 承認申請中ファイルロック不可への対策案
No 防ぐ対象アクション 対策
1 ファイルをアップロード ContentDocumentのBeforeUpdateトリガーにて親レコードの
ロック状態により新規ファイルの添付を防ぐ
2 新しいバージョンをアップロード ContentDocumentのBeforeUpdateトリガーにて親レコードの
ロック状態によりファイルの書き換えを防ぐ
3 ファイルの詳細を編集 ContentDocumentLinkのBeforeUpdateトリガーにて親レコード
のロック状態により添付ファイルの詳細情報更新を防ぐ
4 削除 ContentDocumentのBeforeDeleteトリガーにて親レコードの
ロック状態により添付ファイルの削除を防ぐ
5 レコードから削除 ContentDocumentLinkのBeforeDeleteトリガーにて親レコード
のロック状態によりレコードから添付ファイルの削除を防ぐ
z
4. ソースコード
//セールスフォースのベストプラクティスによりトリガーハンドラーを書いてね!
trigger ContentDocumentTrigger on ContentDocument (before update,before delete) {
if(Trigger.isUpdate ){
for(ContentDocumentLink link:[SELECT Id,ContentDocument.title,ContentDocumentId,ShareType,
LinkedEntity.Name
FROM ContentDocumentLink where ContentDocumentId=: Trigger.newMap.keySet()]){
if(Approval.isLocked(link.LinkedEntityId)){
System.debug(‘新規ファイルの添付又はファイルの書き換え又はファイル削除がダメ’);
trigger.newMap.get(link.ContentDocumentId).addError(‘新規ファイルの添付又はファイルの書
き換え又はファイル削除がダメ'');
}
}
}
if(Trigger.isDelete){
for(ContentDocumentLink link:[SELECT Id,ContentDocument.title,ContentDocumentId,ShareType,
LinkedEntity.Name
FROM ContentDocumentLink where ContentDocumentId=: Trigger.oldMap.keySet()]){
if(Approval.isLocked(link.LinkedEntityId)){
System.debug(‘添付ファイルの削除がダメ');
trigger.oldMap.get(link.ContentDocumentId).addError('添付ファイルの削除がダメ');
}
}
}
}
z
4. ソースコード
//セールスフォースのベストプラクティスによりトリガーハンドラーを書いてね!
trigger ContentDocumentLinkTrigger on ContentDocumentLink (before update, before delete) {
if(Trigger.isUpdate ){
for(ContentDocumentLink rNew : trigger.new)
{
if(Approval.isLocked(rNew.LinkedEntityId)){
System.debug(‘添付ファイルの詳細情報更新がダメ');
rNew.addError('添付ファイルの詳細情報更新がダメ');
}
}
}
if(Trigger.isDelete ){
for(ContentDocumentLink rOld : trigger.old)
{
if(Approval.isLocked(rOld.LinkedEntityId)){
System.debug(‘レコードから添付ファイルの削除がダメ');
rOld.addError('レコードから添付ファイルの削除がダメ');
}
}
}
}
z
4. おしまい
Happy Coding!

More Related Content

What's hot

Software Re-Engineering in Software Engineering SE28
Software Re-Engineering in Software Engineering SE28Software Re-Engineering in Software Engineering SE28
Software Re-Engineering in Software Engineering SE28koolkampus
 
Quality Management in Software Engineering SE24
Quality Management in Software Engineering SE24Quality Management in Software Engineering SE24
Quality Management in Software Engineering SE24koolkampus
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independenceapoorva_upadhyay
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction toolsAkhil Kaushik
 
Requirements Engineering Processes in Software Engineering SE6
Requirements Engineering Processes in Software Engineering SE6Requirements Engineering Processes in Software Engineering SE6
Requirements Engineering Processes in Software Engineering SE6koolkampus
 
MODULE 1_Introduction to Data analytics and life cycle..pptx
MODULE 1_Introduction to Data analytics and life cycle..pptxMODULE 1_Introduction to Data analytics and life cycle..pptx
MODULE 1_Introduction to Data analytics and life cycle..pptxnikshaikh786
 
Database management system by Neeraj Bhandari ( Surkhet.Nepal )
Database management system by Neeraj Bhandari ( Surkhet.Nepal )Database management system by Neeraj Bhandari ( Surkhet.Nepal )
Database management system by Neeraj Bhandari ( Surkhet.Nepal )Neeraj Bhandari
 
Data Exploration and Visualization with R
Data Exploration and Visualization with RData Exploration and Visualization with R
Data Exploration and Visualization with RYanchang Zhao
 
Software Engineering Important Short Question for Exams
Software Engineering Important Short Question for ExamsSoftware Engineering Important Short Question for Exams
Software Engineering Important Short Question for ExamsMuhammadTalha436
 
Software assessment and audit
Software assessment and auditSoftware assessment and audit
Software assessment and auditSpoorthi Sham
 
Capability maturity model
Capability maturity modelCapability maturity model
Capability maturity modelFaizan Anwar
 
Project Planning in Software Engineering
Project Planning in Software EngineeringProject Planning in Software Engineering
Project Planning in Software EngineeringFáber D. Giraldo
 
Software Quality Assurance
Software Quality AssuranceSoftware Quality Assurance
Software Quality AssuranceSiddhesh Palkar
 
Software Quality Challenge
Software Quality ChallengeSoftware Quality Challenge
Software Quality ChallengeHelmy Satria
 
Chapter 15 software product metrics
Chapter 15 software product metricsChapter 15 software product metrics
Chapter 15 software product metricsSHREEHARI WADAWADAGI
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMRajendran
 
Non- Recursive Predictive Parsing.pptx
Non- Recursive Predictive Parsing.pptxNon- Recursive Predictive Parsing.pptx
Non- Recursive Predictive Parsing.pptxsampathkumar912515
 
Random testing
Random testingRandom testing
Random testingLocaweb
 
Chapter 13 software testing strategies
Chapter 13 software testing strategiesChapter 13 software testing strategies
Chapter 13 software testing strategiesSHREEHARI WADAWADAGI
 

What's hot (20)

Software Re-Engineering in Software Engineering SE28
Software Re-Engineering in Software Engineering SE28Software Re-Engineering in Software Engineering SE28
Software Re-Engineering in Software Engineering SE28
 
Term weighting
Term weightingTerm weighting
Term weighting
 
Quality Management in Software Engineering SE24
Quality Management in Software Engineering SE24Quality Management in Software Engineering SE24
Quality Management in Software Engineering SE24
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independence
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Requirements Engineering Processes in Software Engineering SE6
Requirements Engineering Processes in Software Engineering SE6Requirements Engineering Processes in Software Engineering SE6
Requirements Engineering Processes in Software Engineering SE6
 
MODULE 1_Introduction to Data analytics and life cycle..pptx
MODULE 1_Introduction to Data analytics and life cycle..pptxMODULE 1_Introduction to Data analytics and life cycle..pptx
MODULE 1_Introduction to Data analytics and life cycle..pptx
 
Database management system by Neeraj Bhandari ( Surkhet.Nepal )
Database management system by Neeraj Bhandari ( Surkhet.Nepal )Database management system by Neeraj Bhandari ( Surkhet.Nepal )
Database management system by Neeraj Bhandari ( Surkhet.Nepal )
 
Data Exploration and Visualization with R
Data Exploration and Visualization with RData Exploration and Visualization with R
Data Exploration and Visualization with R
 
Software Engineering Important Short Question for Exams
Software Engineering Important Short Question for ExamsSoftware Engineering Important Short Question for Exams
Software Engineering Important Short Question for Exams
 
Software assessment and audit
Software assessment and auditSoftware assessment and audit
Software assessment and audit
 
Capability maturity model
Capability maturity modelCapability maturity model
Capability maturity model
 
Project Planning in Software Engineering
Project Planning in Software EngineeringProject Planning in Software Engineering
Project Planning in Software Engineering
 
Software Quality Assurance
Software Quality AssuranceSoftware Quality Assurance
Software Quality Assurance
 
Software Quality Challenge
Software Quality ChallengeSoftware Quality Challenge
Software Quality Challenge
 
Chapter 15 software product metrics
Chapter 15 software product metricsChapter 15 software product metrics
Chapter 15 software product metrics
 
POST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEMPOST’s CORRESPONDENCE PROBLEM
POST’s CORRESPONDENCE PROBLEM
 
Non- Recursive Predictive Parsing.pptx
Non- Recursive Predictive Parsing.pptxNon- Recursive Predictive Parsing.pptx
Non- Recursive Predictive Parsing.pptx
 
Random testing
Random testingRandom testing
Random testing
 
Chapter 13 software testing strategies
Chapter 13 software testing strategiesChapter 13 software testing strategies
Chapter 13 software testing strategies
 

More from furuCRM株式会社 CEO/Dreamforce Vietnam Founder

More from furuCRM株式会社 CEO/Dreamforce Vietnam Founder (20)

GithubAction+DevOpsCenter.pptx
GithubAction+DevOpsCenter.pptxGithubAction+DevOpsCenter.pptx
GithubAction+DevOpsCenter.pptx
 
BackupMetadataByGitAction.pptx
BackupMetadataByGitAction.pptxBackupMetadataByGitAction.pptx
BackupMetadataByGitAction.pptx
 
Salesforce Flow_InternalTraining.pptx
Salesforce Flow_InternalTraining.pptxSalesforce Flow_InternalTraining.pptx
Salesforce Flow_InternalTraining.pptx
 
FlowErrorHandling.pptx
FlowErrorHandling.pptxFlowErrorHandling.pptx
FlowErrorHandling.pptx
 
DevOpsCenter_BetaVersion.pptx
DevOpsCenter_BetaVersion.pptxDevOpsCenter_BetaVersion.pptx
DevOpsCenter_BetaVersion.pptx
 
Omni-Chanel_ForInternal.pptx
Omni-Chanel_ForInternal.pptxOmni-Chanel_ForInternal.pptx
Omni-Chanel_ForInternal.pptx
 
基本設計+詳細設計の書き方 社内勉強会0304
基本設計+詳細設計の書き方 社内勉強会0304基本設計+詳細設計の書き方 社内勉強会0304
基本設計+詳細設計の書き方 社内勉強会0304
 
SVF cloud for salesforce
SVF cloud for salesforceSVF cloud for salesforce
SVF cloud for salesforce
 
External services
External servicesExternal services
External services
 
Data spider servista for Beginner
Data spider servista for BeginnerData spider servista for Beginner
Data spider servista for Beginner
 
Record level-access in Salesforce
Record level-access in SalesforceRecord level-access in Salesforce
Record level-access in Salesforce
 
Salesforce CMS
Salesforce CMS Salesforce CMS
Salesforce CMS
 
Salesforce Scheduler
Salesforce SchedulerSalesforce Scheduler
Salesforce Scheduler
 
Pardot MA Fundamental
Pardot MA FundamentalPardot MA Fundamental
Pardot MA Fundamental
 
Field service lightning
Field service lightningField service lightning
Field service lightning
 
ETL And Salesforce Integration
ETL And Salesforce IntegrationETL And Salesforce Integration
ETL And Salesforce Integration
 
Sfdx jenkins
Sfdx jenkinsSfdx jenkins
Sfdx jenkins
 
Heroku platform introduction
Heroku platform introductionHeroku platform introduction
Heroku platform introduction
 
Unlocked package
Unlocked packageUnlocked package
Unlocked package
 
Asynchronous apex
Asynchronous apexAsynchronous apex
Asynchronous apex
 

Recently uploaded

自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineerYuki Kikuchi
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案sugiuralab
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)UEHARA, Tetsutaro
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...博三 太田
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfFumieNakayama
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfFumieNakayama
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?akihisamiyanaga1
 

Recently uploaded (9)

自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
 

Lock attachfilewhileparentrecordlocked