Skip to content

Instantly share code, notes, and snippets.

public class displaySObjectList {
public Map<String, List<String>> stdObj = new Map<String, List<String>>();
public Map<String, List<String>> cstmObj = new Map<String, List<String>>();
public Map<String, List<String>> getStdObject(){
return stdObj;
}
<apex:page showHeader="true" sidebar="true" controller="displaySObjectList">
<p>Sobjectのリストを取得してオブジェクト名とプレフィックスを表示します</p>
<p>プレフィックスがnullのものは表示されません</p>
<div>
<apex:form>
<apex:commandButton value="display" action="{!CreateObjectList}" reRender="result"/>
</apex:form>
</div>
@101dvlp
101dvlp / chatterSample
Last active August 1, 2017 10:29
ChatterFeedFromApex
public pageReference feedWithMention(){
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
// メンション先のユーザを指定
User u = [SELECT Id FROM User WHERE Name = 'testUser' LIMIT 1];
mentionSegmentInput.id = u.Id;
public with sharing class ContactSampleExtension {
private final Contact cont;
public String selected {get; set;}
public ContactSampleExtension(ApexPages.StandardController stdController) {
this.cont = (Contact)stdController.getRecord();
}
public List<SelectOption> getItems(){
<apex:page showHeader="true" sidebar="true" standardController="Contact" extensions="ContactSampleExtension">
<p>This is ContactSample page(VF)</p>
<!-- 選択肢を表示 -->
<apex:form>
<div style="width: 20%;">
<apex:selectRadio value="{!selected}" layout="pageDirection" borderVisible="true" legendText="選択肢サンプル">
<apex:selectOptions value="{!items}"/>
</apex:selectRadio>
</div>
// 検索元のContact
Contact c = new Contact();
c.LastName = 'con';
c.Phone = '0311111111';
// SOSLを実行
List<List<SObject>> searchList = [FIND :c.Phone IN Phone FIELDS RETURNING Account(Name, Phone), Contact(Name, Phone)];
Account[] acList = ((List<Account>)searchList[0]);
Contact[] cList = ((List<Contact>)searchList[1]);
@101dvlp
101dvlp / SOSLSample
Created July 10, 2017 10:07
SOSL Sample
List<List<SObject>> searchList = [FIND '*test*' IN NAME FIELDS RETURNING Account(Id, Name), Contact];
Account[] ac = ((List<Account>)searchList[0]);
Contact[] co = ((List<Contact>)searchList[1]);
System.debug(ac[0].Name);
System.debug(co[0].Name);
@101dvlp
101dvlp / gist:4e53aaf1a8a60cc85963c9a336d59e79
Created June 25, 2017 14:15
都道府県の県庁所在地を格納するMap
// 都道府県と緯度経度を格納するMap
Map<String, Location> prefs = new Map<String, Location>();
// 北海道
Location hokkaido = Location.newInstance(43.063968, 141.347899);
prefs.put('北海道', hokkaido);
// 青森県
Location aomori = Location.newInstance(40.824623, 140.740593);
prefs.put('青森県', aomori);
// 岩手県
Location iwate = Location.newInstance(39.703531, 141.152667);
<script type="text/javascript">
$(document).ready(function(){
$('.content').collapser({
mode: 'chars',
truncate: 10,
showText: '続きを読む',
hideText: '隠す'
});
});
</script>
<apex:page>
<h1>This is sampleCode</h1>
</apex:page>