S1 Publisher – VF Edition
25 April, 2014
Peter Chittum
Developer Evangelist
@pchittum
Safe Harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contai...
Visualforce
Framework
 Server-side compiled web pages
– (Think PHP, JSP, etc.)
 Easily create salesforce UI
 Standard-compliant
 C...
Device Access Through Web APIs
 Audio/Video Capture
 Geolocation
 Accelerometer
Visualforce Tags
<apex:page docType=“html-5.0” />
<apex:input type=“email”/>
<apex:pageBlockSection collapsible=“false” />
Styling for Visualforce in S1
 Salesforce1 Styleguide
sfdc-styleguide.herokuapp.com/
 OneStarter jQuery plugin
github.co...
Hashed information block to track server side transports
Viewstate
Apex Form
 Required for standard salesforce post
 Incurs Viewstate Overhead
<apex:form>
…
</apex:form
aspdoifuapknva8943...
Interacting with the Platform
 Apex Controller Instance Method
 Apex Controller Static Remoting Method
 REST API
 Visu...
Apex Instance Method
 Use with apex:actionFunction to access via
Javascript
 ActionFunction requires ViewState
 Reduce ...
Apex Remote Action
 Static
 No View State
 Invoked through JS API
 Invokes JS Callback
@remoteAction
global static Str...
Calling Apex Remote Action
Visualforce.remoting.Manager.invokeAction(’
{!$RemoteAction.RemoteClass.methodName}'
,
param,
f...
Event Object: Success Example
{
"statusCode":200,
"type":"rpc",
"ref":false,
"action":"IncidentReport",
"method":"createIn...
Event Object: Failure Example
{
"statusCode":400,
"type":"exception",
"action":"IncidentReport",
"method":"createIncidentR...
Interacting with the Publisher: Allow Submit
 Make Submit Active
 Payload true/false
Sfdc.canvas.publisher.publish(
{
na...
Interacting with the Publisher: Subscribe to Submit
 Attach to Submit Event
Sfdc.canvas.publisher.subscribe({
name: "publ...
Interacting with the Publisher: Close Publisher
 Make the Submit Happen
Sfdc.canvas.publisher.publish({name:
"publisher.c...
REST API
 For large data transactions
 Use forcetk library for easy access.
github.com/developerforce/Force.com-JavaScri...
forcetk: Init and Bind To Session
<apex:includeScript value="{!$Resource.forcetk}"/>
...
var restClient = new forcetk.Clie...
forcetk: Init and Bind To Session
restClient.create('ContentVersion', {
"Origin": "H",
"PathOnClient": file.name,
"Version...
Spring ’14
(Developer Preview)
Remote Objects
 Standard CRUD/Q functionality without Apex
 Similar to remoteTK or SObjectData
 Visualforce components ...
Upcoming SlideShare
Loading in …5
×

S1 and Visualforce Publisher Actions

1,302 views

Published on

S1 Coding Dojo Presentation from 25 April, 2014

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,302
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
9
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Everything we show today will be current product, but this is a reminder to please make your purchasing decisions based on the product we have today, not on any forward-looking statements we may make.
  • For when declarative logic is not enough, we provide Apex. Apex is a cloud-based programming language, very similar to Java – except that you can code, compile and deploy all right from your Salesforce instance. You’ll see how we can create robust programmatic functions right from your browser.
  • Result is the return from the invoked method.Event is an object that represents data returned from the callback to communicate the state of the call (success, failure, HTTP code, This could do with examples on what to do with the result.
  • This is an excerpt showing some of the important attributes. The full JSON response taken from this example is below:{&quot;statusCode&quot;:400,&quot;type&quot;:&quot;exception&quot;,&quot;tid&quot;:2,&quot;ref&quot;:false,&quot;action&quot;:&quot;IncidentReport&quot;,&quot;method&quot;:&quot;createIncidentReport&quot;,&quot;message&quot;:&quot;List has more than 1 row for assignment to SObject&quot;,&quot;where&quot;:&quot;&quot;,&quot;data&quot;:{&quot;0&quot;:{&quot;Merchandise__c&quot;:&quot;a052000000GUgYgAAL&quot;,&quot;Type__c&quot;:&quot;Accident&quot;,&quot;Description__c&quot;:&quot;asdfasdf&quot;}},&quot;vfTx&quot;:true,&quot;vfDbg&quot;:true,&quot;result&quot;:null,&quot;status&quot;:false}
  • S1 and Visualforce Publisher Actions

    1. 1. S1 Publisher – VF Edition 25 April, 2014
    2. 2. Peter Chittum Developer Evangelist @pchittum
    3. 3. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward- looking statements.
    4. 4. Visualforce
    5. 5. Framework  Server-side compiled web pages – (Think PHP, JSP, etc.)  Easily create salesforce UI  Standard-compliant  Can Interact With Apex for Custom Logic
    6. 6. Device Access Through Web APIs  Audio/Video Capture  Geolocation  Accelerometer
    7. 7. Visualforce Tags <apex:page docType=“html-5.0” /> <apex:input type=“email”/> <apex:pageBlockSection collapsible=“false” />
    8. 8. Styling for Visualforce in S1  Salesforce1 Styleguide sfdc-styleguide.herokuapp.com/  OneStarter jQuery plugin github.com/joshbirk/onestarter
    9. 9. Hashed information block to track server side transports Viewstate
    10. 10. Apex Form  Required for standard salesforce post  Incurs Viewstate Overhead <apex:form> … </apex:form aspdoifuapknva894372h 4ofincao98vh0q938hfoq iwnbdco8q73h0o9fqubov ilbodfubqo3e8ufbw
    11. 11. Interacting with the Platform  Apex Controller Instance Method  Apex Controller Static Remoting Method  REST API  Visualforce Remote Object
    12. 12. Apex Instance Method  Use with apex:actionFunction to access via Javascript  ActionFunction requires ViewState  Reduce ViewState with Transient and Static
    13. 13. Apex Remote Action  Static  No View State  Invoked through JS API  Invokes JS Callback @remoteAction global static String myMethod(String inputParam){ ... }
    14. 14. Calling Apex Remote Action Visualforce.remoting.Manager.invokeAction(’ {!$RemoteAction.RemoteClass.methodName}' , param, function(result, event) { //...callback to handle result });
    15. 15. Event Object: Success Example { "statusCode":200, "type":"rpc", "ref":false, "action":"IncidentReport", "method":"createIncidentReport", "result":"a072000000pt1ZLAAY", "status":true }
    16. 16. Event Object: Failure Example { "statusCode":400, "type":"exception", "action":"IncidentReport", "method":"createIncidentReport", "message":"List has more than 1 row for assignment to SObject", "data": {"0": {"Merchandise__c":"a052000000GUgYgAAL","Type__c":"Accident","Desc ription__c":"This is an accident report"}}, "result":null, "status":false }
    17. 17. Interacting with the Publisher: Allow Submit  Make Submit Active  Payload true/false Sfdc.canvas.publisher.publish( { name: "publisher.setValidForSubmit", payload:true });
    18. 18. Interacting with the Publisher: Subscribe to Submit  Attach to Submit Event Sfdc.canvas.publisher.subscribe({ name: "publisher.post", onData:function(e) { // This subscribe fires when the user hits 'Submit' in the publisher postToFeed(); }});
    19. 19. Interacting with the Publisher: Close Publisher  Make the Submit Happen Sfdc.canvas.publisher.publish({name: "publisher.close", payload: { refresh:"true"}});
    20. 20. REST API  For large data transactions  Use forcetk library for easy access. github.com/developerforce/Force.com-JavaScript-REST- Toolkit
    21. 21. forcetk: Init and Bind To Session <apex:includeScript value="{!$Resource.forcetk}"/> ... var restClient = new forcetk.Client(); var contentId; var merchId; restClient.setSessionToken('{!$Api.Session_ID}'); //turn off proxy now that we have session restClient.proxyUrl = null; restClient.instanceUrl = '';
    22. 22. forcetk: Init and Bind To Session restClient.create('ContentVersion', { "Origin": "H", "PathOnClient": file.name, "VersionData": imageData }, function(data) { ... $('#test-display').text('File Create Complete:' + data.id); ... }, onErrorSfdc);
    23. 23. Spring ’14 (Developer Preview)
    24. 24. Remote Objects  Standard CRUD/Q functionality without Apex  Similar to remoteTK or SObjectData  Visualforce components define data models <apex:jsSObjectBase shortcut="tickets"> <apex:jsSObjectModel name="Ticket__c" /> <apex:jsSObjectModel name="Contact" fields="Email" /> <script> var contact = new tickets.Contact(); contact.retrieve({ where: { Email: { like: query + '%' } } }, function(err, data) {

    ×