Skip to main content

Posts

Showing posts from November, 2012

Sending Document as an attachment in the form of Pdf Using Workflow Rules of force.com platform and Visualforce Template feature

Emailing the pdf on click of a boolean check box or click of a button are frequent requirements for which we often think of using Triggers and using Outbound Emails of apex .

This requirement can be easily accomplished through workflow rules and the Visualforce Email Templates

In this blog POST will walk through on how to approach this

Step 1:
Creation of Email Field This is the first step to create an Email Field so that when we develop workflow rules when for the email alert the Recipient Type is asked we may fill in the email field
Step 2:
Creation of workflowThis is a simple step where based on business criteria draft a workflow rule.Usually rule should be to trigger the email alert only if the boolean flag is checked .
Step 3:Creation of email template The email Template will be a visualforce template and hence if you are familiar with visualforce this must be a straight forward impementation
Below is the sample code that you may customize by replacing with your relevant obje…

Native Parsing Of JSON input into User Defined Class through Apex Rest Service

I have walked into Apex Guide of SFDC to find if there are code samples for the parsing of the JSON into User defined Class in apex.Unfortunately document mentions that this can be achieved but still there were no code snippets i could find.

This blog post might help for small snippet reference to understand how we can write an apex class and structure the Constructor of the POST annotated method to achieve native parsing automatically.
Here is the Code Snippet of the Class . Note that the Request is a combination of Account and Contacts and hence we may need an inner class .

@RestResource(urlMapping='/DemoUrl/*') global with sharing class MyRestResourcedemo{ //User defined Class global class RequestWrapper{ Account acct; Contact[] cons; } //Response Wrapper Class global class ResponseWrapper{ public String StatusCode; public String StatusMessage; public Account acct; public Contact[] cons; } @HttpPost global static ResponseWrapper doPost(RequestWrapp…