outputPanelのrendered属性について
https://developer.salesforce.com/forums/?id=906F00000009BOgIAM
kinkun's blog
outputPanelのrendered属性について
https://developer.salesforce.com/forums/?id=906F00000009BOgIAM
GMTからseconds取得
Long gettime = Datetime.now().getTime();
System.debug('gettime:'+gettime);
gettime = gettime/1000;
System.debug('gettime:'+gettime);
結果
17:39:16:003 USER_DEBUG [8]|DEBUG|gettime:1654591156228
17:39:16:003 USER_DEBUG [11]|DEBUG|gettime:1654591156
ここで、1654591156:seconds
Unix Timestamp Conversion Tools
Cloud Firestore
https://qiita.com/TakeshiNickOsanai/items/a2dc728d3b854d6c2d76
ApexでawsへファイルDelete
public Integer fileUpload(Attachment file){
String attachmentBodyEncoded = EncodingUtil.base64Encode(file.Body);
String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
String key = awsAccessKey;
String secret = awsSecretAccessKey;
String bucketname = awsBucket;
String host = awsService + '-' + awsReign + '.amazonaws.com';
String method = 'DELETE';
String fileNameEncoded = EncodingUtil.urlEncode(file.Name, 'UTF-8');
HttpRequest req = new HttpRequest();
req.setMethod(method);
req.setEndpoint('https://' + bucketname + '.' + host + '/' + bucketname + '/' + fileNameEncoded);
req.setHeader('Host', bucketname + '.' + host);
req.setHeader('Content-Length', String.valueOf(attachmentBodyEncoded.length()));
req.setHeader('Content-Encoding', 'UTF-8');
req.setHeader('Content-type', file.ContentType);
req.setHeader('Connection', 'keep-alive');
req.setHeader('Date', formattedDateString);
req.setHeader('ACL', 'public-read-write');
req.setBodyAsBlob(EncodingUtil.base64Decode(attachmentBodyEncoded));
String stringToSign = 'DELETE\n\n' +
file.ContentType + '\n' +
formattedDateString + '\n' +
'/' + bucketname + '/' + bucketname + '/' + fileNameEncoded;
Blob mac = Crypto.generateMac('HMACSHA1', blob.valueof(stringToSign),blob.valueof(secret));
String signed = EncodingUtil.base64Encode(mac);
String authHeader = 'AWS' + ' ' + key + ':' + signed;
req.setHeader('Authorization',authHeader);
Http http = new Http();
HTTPResponse res = http.send(req);
return res.getStatusCode();
}
Apexをスケジュール設定でApexクラスが検索されない件の対応
検索されないケース
public class SampleBatchSchedule implements Schedulable {
public void execute(SchedulableContext sc) {
SampleBatch batch = new SampleBatch();
database.executebatch(batch);
}
}
検索されるケース
global class SampleBatchSchedule implements Schedulable {
public void execute(SchedulableContext sc) {
SampleBatch batch = new SampleBatch();
database.executebatch(batch);
}
}
CANNOT_EXECUTE_FLOW_TRIGGER
テストクラス実行時、エラー詳細
System.DmlException: Insert failed. First exception on row 0; first error:
CANNOT_EXECUTE_FLOW_TRIGGER,
「Campaign Create、Member Status Auto Set」処理失敗により、このレコードを保存できません。
Salesforce システム管理者に次の詳細を報告してください。
Salesforce には、削除条件に一致するレコードがありません。
Salesforce には、削除条件に一致するレコードがありません。: []
対応案の一つ
@isTest(SeeAllData=true)
※場合によって効く。
ユーザの2要素の接続解除
該当ユーザの詳細画面にて、
アプリケーション登録: Salesforce Authenticator ⇒ 「切断」リンク押下する。
Apexバッチの処理内でAPIを実行
Apexバッチの処理内でAPIを実行する場合は『Database.AllowsCallouts』の宣言が必要になります。
global with sharing class testBatch implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts{
public testBatch() {
}
}
ApexでREST API使用して画像ファイルUpload
public void fileUpload(Attachment attach){
HttpRequest req = new HttpRequest();
Http http = new Http();
HTTPResponse res = new HTTPResponse();
String boundary = '------------' + String.valueOf(DateTime.now().getTime());
String header += '--' + boundary;
header += '\r\n';
header += 'Content-Disposition: form-data; name="attach"; filename="' + attach.name + '"';
header += '\r\n';
header += 'Content-Type: ' + attach.ContentType;
String headerEncoded = EncodingUtil.base64Encode(Blob.valueOf(header+'\r\n\r\n'));
while(headerEncoded.endsWith('=')){
header += ' ';
headerEncoded = EncodingUtil.base64Encode(Blob.valueOf(header + ' ' +'\r\n\r\n'));
}
String bodyEncoded = EncodingUtil.base64Encode(attach.Body);
String footor += '\r\n';
footor += '--'+boundary;
footor += '\r\n';
footor += 'Content-Disposition: form-data; name="attachname"';
footor += '\r\n\r\n';
footor += attach.name;
footor += '\r\n';
footor += '--'+boundary+'--';
String footorEncoded = EncodingUtil.base64Encode(Blob.valueOf(footor));
Blob bodyBlob = null;
String last4Bytes = bodyEncoded.substring(bodyEncoded.length()-4,bodyEncoded.length());
if(last4Bytes.endsWith('='))
{
Blob decoded4Bytes = EncodingUtil.base64Decode(last4Bytes);
HttpRequest tmp = new HttpRequest();
tmp.setBodyAsBlob(decoded4Bytes);
String last4Bytesfootor = tmp.getBody()+footor;
bodyBlob = EncodingUtil.base64Decode(headerEncoded+bodyEncoded.substring(0,bodyEncoded.length()-4)+EncodingUtil.base64Encode(Blob.valueOf(last4Bytesfootor)));
}
else
{
bodyBlob = EncodingUtil.base64Decode(headerEncoded+bodyEncoded+footorEncoded);
}
req = new HttpRequest();
req.setHeader('Content-Type','multipart/form-data; boundary=' + boundary);
req.setMethod('POST');
req.setEndpoint('https://' + endPoint);
req.setBodyAsBlob(bodyBlob);
req.setTimeout(120000);
http = new Http();
res = http.send(req);
}