ラベル salesforce の投稿を表示しています。 すべての投稿を表示
ラベル salesforce の投稿を表示しています。 すべての投稿を表示

2017年12月19日火曜日

[Apex/Visualforce] エラー/Error Unexpected Token : 'FROM'

<問題・Problem>

エラー:Unexpected Token : 'FROM'
Error : Unexpected Token : 'FROM'

<解決策・Solution>

SOQLに問題あり。おそらくカンマがFROMの前に余計に付いています。
There is a problem in SOQL. Maybe there is extra comma "," just before "FROM".

2017年12月4日月曜日

[Apex/JSON] JSON型文字列を配列にする/Change JSON Type to Array

<問題・Problem>

JSON型の文字列をApex ClassでList型やMap型に変換したい!
JSON type String needs to be changed to List type or Map type in Apex Class!

<解決策・Solution>

JSON.deserializeとキャストを使用します。
Use JSON.deserialize and Cast.

Listの場合/List case:
List<String> リスト名/List Name = (List<String>)JSON.deserialize(JSON文字列/JSON String , List<String>.class);

<サンプル・Sample>

JSON:
 [  
   {"name":"pen","num":"10"},  
   {"name":"pineapple","num":"20"},  
   {"name":"apple","num":"30"}  
 ]  

Apex Class:
 String jsonString = '[{"name":"pen","num":"10"},{"name":"pineapple","num":"20"},{"name":"apple","num":"30"}]';  
   
 List<map<String,String>> sampleList = (List<Map<String,String>>)JSON.deserialize(jsonString,List<Map<String,String>>.class);  
 
 for(Integer i = 0;i<sampleList.size();i++){  
   for(String s : sampleList[i].keySet()){  
     system.debug(s + ' : ' + sampleList[i].get(s));  
   }  
 }  

Debug Result:
 pen : 10  
 pineapple : 20  
 apple : 30  

2017年12月1日金曜日

[Visualforce SLDS] slds-tableのヘッダーを固定する/Fix header of slds-table

<問題・Problem>

SLDSのTableComponentページhttps://www.lightningdesignsystem.com/components/data-tables/にはヘッダーを固定する方法が書いてありません。
There is no description about fixed header in SLDS TableComponent pagehttps://www.lightningdesignsystem.com/components/data-tables/.

<解決策・Solution>

実は、ヘッダーを固定するクラスがSLDSに用意されているのです!ヘッダー固定はとっても簡単に実装できます!
Actually, there are some classes which can fix table header! It's very easy to implement the feature!

Class:
  • slds-table–header-fixed_container
  • slds-table--header-fixed
  • slds-cell-fixed

<サンプル・Sample>


 <div class="slds-table--header-fixed_container" style="height:300px;">  
   <div class="slds-scrollable_y" style="height:100%;">  
     <table class="slds-table slds-table_bordered slds-table--header-fixed">  
       <thead>  
         <tr class="slds-text-title_caps">  
           <th scope="col">  
             <div class="slds-truncate slds-cell-fixed" style="padding: 8px;" title="Name">  
               Name   
             </div>  
           </th>  
           <th scope="col">  
             <div class="slds-truncate slds-cell-fixed" style="padding: 8px;" title="Amount">  
               Amount  
             </div>  
           </th>  
         </tr>  
       </thead>  
       <tbody >  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pen"><a href="javascript:void(0);">pen</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">10</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pineapple"><a href="javascript:void(0);">Pineapple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">20</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Apple"><a href="javascript:void(0);">Apple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">30</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pen"><a href="javascript:void(0);">pen</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">10</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pineapple"><a href="javascript:void(0);">Pineapple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">20</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Apple"><a href="javascript:void(0);">Apple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">30</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pen"><a href="javascript:void(0);">pen</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">10</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pineapple"><a href="javascript:void(0);">Pineapple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">20</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Apple"><a href="javascript:void(0);">Apple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">30</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pen"><a href="javascript:void(0);">pen</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">10</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pineapple"><a href="javascript:void(0);">Pineapple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">20</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Apple"><a href="javascript:void(0);">Apple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">30</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pen"><a href="javascript:void(0);">pen</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">10</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Pineapple"><a href="javascript:void(0);">Pineapple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">20</div>  
           </td>  
         </tr>  
         <tr>  
           <th scope="row" data-label="Name">  
             <div class="slds-truncate" title="Apple"><a href="javascript:void(0);">Apple</a></div>  
           </th>  
           <td data-label="Amount">  
             <div class="slds-truncate" title="10">30</div>  
           </td>  
         </tr>  
       </tbody>  
     </table>  
   </div>  
 </div>