Hide
Need a quick chart or graph for your blog? Try our reStructured Text renderer. Join Siafoo Now or Learn More

Contacts Rolodex using SharePoint Data Zoom Extension for salesforce.com Atom Feed 0

In Brief Contacts Rolodex script for SharePoint Data Zoom Extension for salesforce.com. This script provides you with a filterable and sortable directory of all your organization's salesforce.com contacts. The SharePoint Data Zoom Extension for salesforce.com is required.
# 's
  1## SalesForce Contacts Rolodex v1.0
2## by SharePoint Solutions
3
4## Get search inputs
5#set( $id = $queryString.get_item("id") )
6#set( $searchCriteria = $form.get_item("searchCriteria") )
7#set( $searchType = $form.get_item("searchType") )
8#set( $rolodex = $form.get_item("rolodex") )
9
10## Get paging attributes
11#set( $pageIndex = $Strings.ConvertToInt($form.get_item("pageIndex"), 0) )
12#set( $pageSize = $Strings.ConvertToInt($form.get_item("pageSize"), 15) )
13
14## Add filter terms
15#if( !$Strings.IsNullOrEmpty($id) && $request.HttpMethod == "GET" )
16
17 ##set( $searchFilter = "$id" )
18 ##set( $searchType = "Id" )
19
20#elseif( !$Strings.IsNullOrEmpty($rolodex) )
21
22 #if( $rolodex == "All" )
23 #set( $searchFilter = "" )
24 #set( $searchCriteria = "" )
25 #else
26 #set( $searchFilter = "LastName like '${rolodex}%'" )
27 #set( $searchCriteria = "${rolodex}" )
28 #set( $searchType = "LastName" )
29 #end
30
31#elseif( !$Strings.IsNullOrEmpty($searchCriteria) )
32
33 #set( $searchFilter = "$searchType Like '%${searchCriteria}%'" )
34#end
35
36## Get account details
37#set( $acct_id = $form.get_item("aid") )
38
39#if( !$Strings.IsNullOrEmpty($acct_id))
40
41## Setup Account properties to fetch
42#set( $acct_properties = ["Name","BillingStreet","BillingCity","BillingState","BillingCountry","BillingPostalCode"] )
43
44## Get the Account
45#set( $acct_query = $Strings.Format("Id='{0}'", $acct_id ) )
46#set( $sfaAcct = $ApexAccounts.GetAccount($acct_query, $acct_properties) )
47
48#end
49
50#set( $ctx_id = $form.get_item("cid") )
51
52<script>
53<!--
54
55function applySearch()
56{
57 document.getElementById("pageIndex").value = "0";
58 document.getElementById("rolodex").value = "";
59 theForm.submit();
60}
61
62function setPageSize()
63{
64 document.getElementById("pageIndex").value = "0";
65 theForm.submit();
66}
67
68function gotoPageIndex(pageIndex)
69{
70 document.getElementById("pageIndex").value = pageIndex;
71 theForm.submit();
72}
73
74function gotoRolodex(rolodex)
75{
76 document.getElementById("pageIndex").value = "0";
77 document.getElementById("rolodex").value = rolodex;
78 theForm.submit();
79}
80
81function gotoAccount(rolodex,pageIndex,account,ctx)
82{
83 if(pageIndex == null)
84 pageIndex = '0';
85 document.getElementById("pageIndex").value = pageIndex;
86 document.getElementById("rolodex").value = rolodex;
87 document.getElementById("aid").value = account;
88 document.getElementById("cid").value = ctx;
89 theForm.submit();
90}
91
92function gotoDetails(rolodex,pageIndex,ctx)
93{
94 if(pageIndex == null)
95 pageIndex = '0';
96 document.getElementById("pageIndex").value = pageIndex;
97 document.getElementById("rolodex").value = rolodex;
98 document.getElementById("cid").value = ctx;
99 theForm.submit();
100}
101
102-->
103</script>
104
105<div style="padding:10px;">
106
107<span class="ms-linksectionheader"><h3 class="ms-standardheader">Search</h3></span>
108<blockquote style="margin:10px">
109
110<!-- Search area -->
111<input type="hidden" name="pageIndex" value="$!{pageIndex}" />
112<input type="hidden" name="rolodex" value="$!{rolodex}" />
113<input type="hidden" name="aid" value="$!{acct_id}" />
114<input type="hidden" name="cid" value="$!{ctx_id}" />
115
116<table cellpadding="2" cellspacing="0">
117 <tr>
118 <td>Find a user whose
119 <select name="searchType">
120 <option value="LastName" #if($searchType == "LastName")selected #end>Last Name</option>
121 <option value="FirstName" #if($searchType == "FirstName")selected #end>First Name</option>
122 <option value="Email" #if($searchType == "Email") selected #end>E-Mail Address</option>
123 </select>
124 contains
125 <input type="text" name="searchCriteria" value="$!{searchCriteria}" />
126 </td>
127 <td>
128 <a title="Find Account" href="javascript:applySearch();">
129 <img title="Go Search" alt="Find Employee" src="_layouts/images/gosearch.gif" style="border-width:0px;" />
130 </a>
131 </td>
132 </tr>
133</table>
134</blockquote>
135
136<span class="ms-linksectionheader"><h3 class="ms-standardheader">Rolodex</h3></span>
137<blockquote style="margin:10px">
138
139<!-- Rollidex -->
140<table cellpadding="2" cellspacing="2">
141 <tr>
142 #foreach($index in [0..10])
143 <td class="ms-vb"><a href="javascript:gotoRolodex('$index');">$index</a></td>
144 #end
145
146 #foreach($index in ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"])
147 <td class="ms-vb"><a href="javascript:gotoRolodex('$index');">$index</a></td>
148 #end
149
150 <td class="ms-vb"><a href="javascript:gotoRolodex('All');">All</a></td>
151 <tr>
152</table>
153</blockquote>
154
155## Setup Contact
156#set( $properties =["Id", "FirstName", "LastName", "Email", "Phone", "AccountId", "Description"] )
157
158## Get the matching entries
159#set( $sfaContacts = $ApexContacts.GetContacts($searchFilter, "LastName,FirstName", $pageIndex, $pageSize, $properties) )
160
161## Get the result data
162#set( $firstItemNumber = $pageIndex * $pageSize + 1 )
163#set( $lastItemNumber = $firstItemNumber + $sfaContacts.Count - 1 )
164#set( $prevPageIndex = $pageIndex - 1 )
165#set( $nextPageIndex = $pageIndex + 1 )
166
167<!-- Toolbar -->
168<table class="ms-menutoolbar" cellpadding="5" cellspacing="0" border="0" width="95%" >
169 <tr>
170 <td class="ms-toolbar"></td>
171
172 <td width="99%" class="ms-toolbar" nowrap>
173 <IMG SRC="_layouts/images/blank.gif" width=1 height=18 alt=""></td>
174
175 <td class="ms-toolbar" nowrap="true">
176 <table cellpadding="0" cellspacing="0" border="0">
177 <tr>
178 #if( $pageIndex > 0 )
179 <td>
180 <img src="_layouts/images/prev.gif" border="0" alt="Previous Page" onclick="gotoPageIndex($prevPageIndex);" /></td>
181 #end
182
183 <td class="ms-listheaderlabel" nowrap>&nbsp;${firstItemNumber}-${lastItemNumber}&nbsp;</td>
184
185 #if( $sfaContacts.Count == $pageSize )
186 <td>
187 <img src="_layouts/1033/images/next.gif" border="0" alt="Next Page" onclick="gotoPageIndex($nextPageIndex);" /></td>
188 #end
189 </tr>
190 </table>
191 </td>
192
193 <td class=ms-separator>|</td>
194
195 <td class="ms-toolbar" nowrap="true">Show &nbsp;&nbsp;</td>
196 <td class="ms-toolbar" nowrap="true">
197 <select name="pageSize" onchange="setPageSize();">
198 <option value="5" #if($pageSize == 5) selected #end>5</option>
199 <option value="10"#if($pageSize == 10) selected #end>10</option>
200 <option value="15"#if($pageSize == 15) selected #end>15</option>
201 <option value="50"#if($pageSize == 50) selected #end>50</option>
202 <option value="100"#if($pageSize == 100) selected #end>100</option>
203 </select>
204 </td>
205
206 <td>&nbsp;&nbsp;&nbsp;</td>
207 </tr>
208</table>
209
210<!-- Results area -->
211#foreach( $sfaContact in $sfaContacts)
212 #if( !$Strings.IsNullOrEmpty($acct_id) )
213 #end
214 #beforeall
215 <table class="ms-listviewtable" cellpadding="8" cellspacing="0" width="95%" border="0">
216 <tr class="ms-viewheadertr">
217 <th class="ms-vh2-nofilter"></th>
218 <th class="ms-vh2-nofilter"></th>
219 <th class="ms-vh2-nofilter">First Name</th>
220 <th class="ms-vh2-nofilter">Last Name</th>
221 <th class="ms-vh2-nofilter">E-Mail Address</th>
222 <th class="ms-vh2-nofilter">Phone Number</th>
223 </tr>
224 #odd
225 <tr class="">
226 #even
227 <tr class="ms-alternating">
228 #each
229 #if($ctx_id != $null && $sfaContact.Id == $ctx_id)
230 ## Selected item
231 <td class="ms-vb2" style="background-color:#B0C4DE;width:15px;text-align:center">#if( $Strings.IsNullOrEmpty($sfaContact.Description) != $true )<a href="javascript:gotoDetails('$!{rolodex}','$!{pageIndex}', '$!{sfaContact.Id}')"><img style="border:0px" src="_layouts/images/ATTACHTB.GIF"></a>#end</td>
232 <td class="ms-vb2" style="background-color:#B0C4DE;width:15px;text-align:center">#if( $Strings.IsNullOrEmpty($sfaContact.AccountId) != $true )<a href="javascript:gotoAccount('$!{rolodex}','$!{pageIndex}', '$!{sfaContact.AccountId}', '$!{sfaContact.Id}')"><img style="border:0px" src="_layouts/images/addressbook.gif"></a>#end</td>
233 <td class="ms-vb2" style="background-color:#B0C4DE;">$sfaContact.FirstName</td>
234 <td class="ms-vb2" style="background-color:#B0C4DE;">$sfaContact.LastName</td>
235 <td class="ms-vb2" style="background-color:#B0C4DE;"><a href="mailto:$!{sfaContact.Email}">$!{sfaContact.Email}</a></td>
236 <td class="ms-vb2" style="background-color:#B0C4DE;">$!{sfaContact.Phone}</td>
237 #else
238 <td class="ms-vb2" style="width:15px;text-align:center">#if( $Strings.IsNullOrEmpty($sfaContact.Description) != $true )<a href="javascript:gotoDetails('$!{rolodex}','$!{pageIndex}', '$!{sfaContact.Id}')"><img style="border:0px" src="_layouts/images/ATTACHTB.GIF"></a>#end</td>
239 <td class="ms-vb2" style="width:15px;text-align:center">#if( $Strings.IsNullOrEmpty($sfaContact.AccountId) != $true )<a href="javascript:gotoAccount('$!{rolodex}','$!{pageIndex}', '$!{sfaContact.AccountId}', '$!{sfaContact.Id}')"><img style="border:0px" src="_layouts/images/addressbook.gif"></a>#end</td>
240 <td class="ms-vb2">$sfaContact.FirstName</td>
241 <td class="ms-vb2">$sfaContact.LastName</td>
242 <td class="ms-vb2"><a href="mailto:$!{sfaContact.Email}">$!{sfaContact.Email}</a></td>
243 <td class="ms-vb2">$!{sfaContact.Phone}</td>
244 #end
245 #after
246 #if( $acct_id != $null && $sfaContact.AccountId == $acct_id && $sfaAcct != $null && $Strings.IsNullOrEmpty($sfaAcct.Name) != $true && $ctx_id != $null && $ctx_id == $sfaContact.Id)
247 </tr>
248 <tr>
249 <td colspan=6 style="padding-left:75px">
250 <table style="background-color:#F5F5F5;border-width:1px;border-style:solid;border-color:black">
251
252 <tr>
253 <th style="text-align:right">Account name:</th><td style="background-color:white">$sfaAcct.Name</td>
254 </tr>
255
256 #if( $Strings.IsNullOrEmpty($sfaAcct.BillingStreet) != $true )
257 <tr>
258 <th style="text-align:right">Address:</th><td style="background-color:white">$sfaAcct.BillingStreet</td>
259 </tr>
260 #end
261 #if( $Strings.IsNullOrEmpty($sfaAcct.BillingCity) != $true )
262 <tr>
263 <th style="text-align:right"></th><td style="background-color:white;margin-top:0px">$!sfaAcct.BillingCity, $!sfaAcct.BillingState $!sfaAcct.BillingCountry $!sfaAcct.BillingPostalCode</td>
264 </tr>
265 #end
266 </table>
267 </td>
268 #elseif( $Strings.IsNullOrEmpty($sfaContact.Description) != $true && $ctx_id != $null && $ctx_id == $sfaContact.Id)
269 </tr>
270 <tr>
271 <td colspan=6 style="padding-left:75px">
272 <table style="background-color:#F5F5F5;border-width:1px;border-style:solid;border-color:black">
273 <tr>
274 <td style="padding:12px"><strong><u>Notes:</u></strong><br/><br/>$sfaContact.Description</td>
275 </tr>
276 </table>
277 </td>
278 #else
279 </tr>
280 #end
281 #afterall
282 </table>
283 #nodata
284 <div style="padding:10px">No Contacts found</div>
285#end
286
287<div>

Contacts Rolodex script for SharePoint Data Zoom Extension for salesforce.com. This script provides you with a filterable and sortable directory of all your organization's salesforce.com contacts. The SharePoint Data Zoom Extension for salesforce.com is required.