public without sharing class QISTrigger { // QISのId public static Set QIS_Ids = new Set(); // public static void setPhotoImgText(List newList, List oldList, Map newMap, Map oldMap) { for (QIS_Report__c qr : newList) { // 二重実行禁止 if (QIS_Ids.contains(qr.Id)) continue; // Photo1 if (Trigger.isInsert && String.isBlank(qr.Photo_1__c) == false || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_1__c != qr.Photo_1__c) || (Trigger.isUpdate && String.isBlank(qr.Photo_1__c) == false && String.isBlank(qr.Photo_1_Text__c)) ) { String phtTxt = ''; if (String.isBlank(qr.Photo_1__c) == false) { Integer pStt = qr.Photo_1__c.indexOf('= 0) { pStt = qr.Photo_1__c.indexOf('src="'); if (pStt >= 0) { Integer pEnd = qr.Photo_1__c.indexOf('"', pStt + 5); if (pEnd >= 0) { phtTxt = qr.Photo_1__c.substring(pStt + 5, pEnd); phtTxt = phtTxt.unescapeHtml4(); } } } } qr.Photo_1_Text__c = phtTxt; QIS_Ids.add(qr.Id); } // Photo2 if (Trigger.isInsert && String.isBlank(qr.Photo_2__c) == false || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_2__c != qr.Photo_2__c) || (Trigger.isUpdate && String.isBlank(qr.Photo_2__c) == false && String.isBlank(qr.Photo_2_Text__c)) ) { String phtTxt = ''; if (String.isBlank(qr.Photo_2__c) == false) { Integer pStt = qr.Photo_2__c.indexOf('= 0) { pStt = qr.Photo_2__c.indexOf('src="'); if (pStt >= 0) { Integer pEnd = qr.Photo_2__c.indexOf('"', pStt + 5); if (pEnd >= 0) { phtTxt = qr.Photo_2__c.substring(pStt + 5, pEnd); phtTxt = phtTxt.unescapeHtml4(); } } } } qr.Photo_2_Text__c = phtTxt; QIS_Ids.add(qr.Id); } // Photo3 if (Trigger.isInsert && String.isBlank(qr.Photo_3__c) == false || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_3__c != qr.Photo_3__c) || (Trigger.isUpdate && String.isBlank(qr.Photo_3__c) == false && String.isBlank(qr.Photo_3_Text__c)) ) { String phtTxt = ''; if (String.isBlank(qr.Photo_3__c) == false) { Integer pStt = qr.Photo_3__c.indexOf('= 0) { pStt = qr.Photo_3__c.indexOf('src="'); if (pStt >= 0) { Integer pEnd = qr.Photo_3__c.indexOf('"', pStt + 5); if (pEnd >= 0) { phtTxt = qr.Photo_3__c.substring(pStt + 5, pEnd); phtTxt = phtTxt.unescapeHtml4(); } } } } qr.Photo_3_Text__c = phtTxt; QIS_Ids.add(qr.Id); } // Photo4 if (Trigger.isInsert && String.isBlank(qr.Photo_4__c) == false || (Trigger.isUpdate && ((QIS_Report__c) oldMap.get(qr.Id)).Photo_4__c != qr.Photo_4__c) || (Trigger.isUpdate && String.isBlank(qr.Photo_4__c) == false && String.isBlank(qr.Photo_4_Text__c)) ) { String phtTxt = ''; if (String.isBlank(qr.Photo_4__c) == false) { Integer pStt = qr.Photo_4__c.indexOf('= 0) { pStt = qr.Photo_4__c.indexOf('src="'); if (pStt >= 0) { Integer pEnd = qr.Photo_4__c.indexOf('"', pStt + 5); if (pEnd >= 0) { phtTxt = qr.Photo_4__c.substring(pStt + 5, pEnd); phtTxt = phtTxt.unescapeHtml4(); } } } } qr.Photo_4_Text__c = phtTxt; QIS_Ids.add(qr.Id); } } } }