2016年10月16日日曜日

Bootstrap : Grid system

Grid system of Bootstrap is easy to use and develop the responsive web design.

<!-- 1 -->
<div class="container">
    <!-- 2 -->
    <div class="row">
        <!-- 3 -->
        <div class="col-sm-2">ID</h4></div>
        <div class="col-sm-2"><input type="text"/></div>
        <div class="col-sm-2">Name</div>
        <div class="col-sm-2"><input type="text"/></div>
        <div class="col-sm-2">Mail</div>
        <div class="col-sm-2"><input type="text"/></div>
    </div>
</div>

1. class="container" or class="container-fluid"
2. class="row"
3. class="col-{prefix}-{columns}"
4. {Columns} is specified so that the total value is 12


Bootstrap has 5 types of prefix. By the specified Prefix, the behavior of the grid changes.

1. xl
2. lg
3. md
4. sm
5. xs


"xl", "lg", "md" and "sm" have a breakpoints. If the size of browser is less than the breakpoints, the grid design are changed to horizontal. "xs" don't have breakpoints. So if you specify "xs", the grid design is horizontal all times.

1. xl : 1140px
2. lg : 940px
3. md : 720px
4. sm : 576px
5. xs : None




Change your browser size. You can see the horizontal design.

2016年10月8日土曜日

Salesforce : Force.com IDE For Eclipse Neon

I try to install Force.com IDE to Eclipse Neon.

1. Help > Install New Software

2. Click Add, Name is "Force.com IDE" and Location is "https://developer.salesforce.com/media/force-ide/eclipse45"


3. Check "Force.com IDE" and click Next

4. Click Next

5. Check "I accept the terms of the license agreement" and click Finish

6. Click Yes


After restart Eclipse
7. Window > Perspective > Open Perspective > Other

8. Choose "Force.com" and click OK

2016年10月6日木曜日

Salesforce : Apex : How can I send emails to more than 30 people in apex?

I wanted to send emails to more than 30 people in salesforce. So, I developed the batch apex job to send emails. But it didn't work. I checked log and found an error message.

ERROR : 
Scheduler: failed to execute scheduled job: jobId: 7072800002NeceT, class: common.apex.async.AsyncApexJobObject, reason: SendEmail failed. First exception on row 0; first error: LIMIT_EXCEEDED, Too many bccAddresses addresses.: [bccAddresses, 34]

// I get all of employees addresses
List<Employee__c> employeeList = [SELECT Mail__c FROM Employee__c];
List<String> toList = new List<String>();
for(Employee__c employee: employeeList){
    toList.add(employee.Mail__c);
}

// I want to send emails.
if(!toList.isEmpty()){
    Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
    message.setBccAddresses(toList);  // ERROR
    message.setInReplyTo('noreply@aaa.co.jp');
    message.setSubject('subject');
    message.setPlainTextBody('message');
    message.setSenderDisplayName('dispname');
    Messaging.sendEmail(new List<Messaging.SingleEmailMessage> { message });
}

The company I belong is employed more than 30 people. But we can't set more than 25 CC/BCC addresses for an single email instance.

I rewrite the apex.
public void send(){
    // I get all of employees address
    List<Employee__c> employeeList = [SELECT Mail__c FROM Employee__c WHERE RetirementFlg__c = FALSE];
    List<String> addresses = new List<String>();
    for(Employee__c employee: employeeList){
        addresses.add(employee.Mail__c);
    }

    // I send emails
    List<String> toList = new List<String>();
    for (String address : addresses) {
        if (toList.size() >= 25) {
            sendEmails(toList);
            toList.clear();
        }
        toList.add(address);
    }
    if (toList.size() > 0) {
        sendEmails(toList);
    }
}

private void sendEmails(List<String> toList) {
    Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
    message.setBccAddresses(toList);
    message.setInReplyTo('noreply@aaa.co.jp');
    message.setSubject('subject');
    message.setPlainTextBody('body');
    message.setSenderDisplayName('dispname');
    Messaging.sendEmail(new List<Messaging.SingleEmailMessage> { message });
}

Isn't there a more efficient way?