[salesforce]APEXでランダム文字列生成
こんなかんじ。
[php]
public string getRandomString(Integer LengthRequired){
String CharList = ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_’;
String Res = ”;
integer position;
for(Integer i = 0; i <= LengthRequired; i++) {
position = Integer.valueof(String.valueof(Math.roundToLong(CharList.length()*Math.random()))) -1;
Res += CharList.substring(position,position+1);
}
return Res;
}
[/php]