Browse Month: January 2013

How to enable .net to access Quickbooks company file

To do this You should have :
A) QuickBooksEnterprise (here we used 13)
B) QBSDK  (here we used  12.0)
c) Microsoft Visual Studio 2008

How we can do ?
a.  Open Connection to QuickBooks
b.  Begin session with a company file
c.  Construct set of request messages
d.  Send request to QuickBooks
e.  Receive response messages
f.   End session
g.  Close connection

a. Open Connection to QuickBooks
QBSessionManager mgr = new QBSessionManager();
mgr.OpenConnection(“appID”, “appName”);
/* appID, appName are String Type
appID: empty string for now
»Intended to eventually allow QuickBooks to link to a listing on Solutions Marketplace
appName: name to appear in QuickBooks

b. Begin session with a company file
mgr.BeginSession(@”pathfilename.qbw”, ENOpenMode.omDontCare);
/*  companyFile: path to the company to open
openMode: an enum of desired file mode
»qbFileOpenSingleUser / omSingleUser
»qbFileOpenMultiUser / omMultiUser
»qbFileOpenDoNotCare / omDontCare        */

c. Construct set of request messages
IMsgSetRequest setrq = mgr.CreateMsgSetRequest(“Contry_Name”,            qbXMLMajorVersion, qbXMLMinorVersion);
/*Contry_Name : String Type
qbXMLMajorVersion : short Type
qbXMLMinorVersion : short Type   */
Ex. to apeend request:
ICustomerAdd custadd = setrq.AppendCustomerAddRq();
custadd.Name.SetValue(“ABC infotech”);
custadd.CompanyName.SetValue(“ABC infotech”);

d.Send request to QuickBooks
IMsgSetResponse setres = mgr.DoRequests(setrq);

e. Receive response messages
count the total Responses in responseList
int count =  setres.ResponseList.Count – 1;
Receive  the response which you want
IResponse response = setres.ResponseList.GetAt(i);

f. End Seession

g. Close Connection


After this open your Quickbook Company file in Quickbooks. then run the above code.


How to create a calendar from salesforce page

To create a calendar from salesforce page to Google calendar use following code :

// VisualForce page

<apex:page controller="CreateCalendarController" sideBar="false">
<apex:form >
	<apex:outputPanel id="errorPanel">
		<apex:pageMessages />
	<apex:outputPanel id="mainPanel">
	<apex:pageBlock title="Create Calendar">
		<apex:pageBlockSection title="Calendar Input" columns="2">
			<apex:inputText value="{!inputCalendar.summary}" label="Summary: " required="true"/>
			<apex:inputText value="{!inputCalendar.description}" label="Description: " required="true"/>
			<apex:inputText value="{!inputCalendar.location}" label="Location: " required="true"/>
			<apex:selectList id="timeZone" value="{!inputCalendar.timeZone}" size="1" label="Time Zone: " required="true">
	            <apex:selectOption itemValue="America/Los_Angeles" itemLabel="America/Los_Angeles"/>
	        <apex:pageBlockSectionItem />
	        <apex:pageBlockSectionItem dataStyle="text-align:center;">
	        	<apex:commandButton action="{!createCalendar}" value="Create Calendar" rerender="mainPanel, errorPanel"/>
		<apex:pageBlockSection title="Calendar Output" columns="2" id="calendarOutputPanel" rendered="{!isResponseReady}">
			<apex:outputText value="{!}" label="Id: " />
			<apex:outputText value="{!responseCalendar.etag}" label="etag: " />
			<apex:outputText value="{!responseCalendar.kind}" label="kind: " />
			<apex:outputText value="{!responseCalendar.summary}" label="Summary: " />
			<apex:outputText value="{!responseCalendar.description}" label="Description: " />
			<apex:outputText value="{!responseCalendar.location}" label="Location: " />
			<apex:outputText value="{!responseCalendar.timeZone}" label="Time Zone: " />

// Below is the code for apex createCalendarController
* Controller for the CreateCalendar VF page
* Creates a Google Calendar by making an API call go Google Calendar API and processes the response back
public class CreateCalendarController extends GoogleApiManager { �
  //calendar object to be serialized and passed to the API
  public GoogleCalendar inputCalendar {
    get {
      if(inputCalendar == null)
        inputCalendar = new GoogleCalendar();
      return inputCalendar;
  //calendar object to be deserialized from the API response
  public GoogleCalendar responseCalendar{
    get {
      if(responseCalendar == null)
        responseCalendar = new GoogleCalendar();
      return responseCalendar;
  public Boolean isResponseReady {
    get { return != null; }
  public PageReference createCalendar(){
      String calendarJsonInput = inputCalendar.serialize(); �
      System.debug('calendarJsonInput: ' + calendarJsonInput);
      String calendarJsonOutput;
      //no callouts in test mode
        calendarJsonOutput = doAPICall(CALENDAR_URL, calendarJsonInput, 'POST');
        doAPICall(CALENDAR_URL, calendarJsonInput, 'POST');
        calendarJsonOutput = testCalendarJson;
      System.debug('calendarJsonOutput: ' + calendarJsonOutput);
      System.debug('isAPIError: ' + isAPIError);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, calendarJsonOutput));
    catch(Exception e){
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, e.getMessage()));
    return null;

// for methods such as serialize and deserialize or doAPICall see GoogleApp project on AppExchange.

How to implement Paging in Apex Salesforce

Put this code in your class & replace your query for myRequestsSetCon:

public ApexPages.StandardSetController myRequestsSetCon {
get {
if(myRequestsSetCon == null) {
myRequestsSetCon = new ApexPages.StandardSetController(Database.getQueryLocator([
select Id, Name, Merchant_Name__c, Requested_Pricing_Change_Effective_Date__c, Status__c, CreatedDate
from Global_Merchant_Pricing_Change__c
where Status__c != ‘Draft’ order by CreatedDate desc

//for(Global_Merchant_Pricing_Change__c c: myRequestsSetCon)
// c.CreatedDate = c.CreatedDate;

// sets the number of records in each page set
return myRequestsSetCon;

// indicates whether there are more records after the current page set.
public Boolean hasNext {
get {
return myRequestsSetCon.getHasNext();

// indicates whether there are more records before the current page set.
public Boolean hasPrevious {
get {
return myRequestsSetCon.getHasPrevious();

// returns the page number of the current page set
public Integer pageNumber {
get {
return myRequestsSetCon.getPageNumber();

// returns the total page numbers of set
public Integer totalPages {
get {
Integer currPageNumber = myRequestsSetCon.getPageNumber();
Integer totalPages = myRequestsSetCon.getPageNumber();
return totalPages;

// returns the first page of records
public void first() {

// returns the last page of records
public void last() {

// returns the previous page of records
public void previous() {

// returns the next page of records
public void next() {;

This is corresponding Visualforce page code:

<apex:form >
<apex:outputPanel id=”RecentRequestsSection”>
<apex:pageBlock rendered=”{!ISNULL(SelectedRequest)}” mode=”maindetail”>
<apex:pageblockTable var=”r” value=”{!myRequests}” width=”100%” style=”margin-top:10px;”>
<apex:column headerValue=”Request Number” style=”text-align:left”>
<apex:outputLink value=”/apex/GNSWeb_GMP_View_Request?id={!r.Id}”>{!r.Name}</apex:outputLink>
<apex:column value=”{!r.Merchant_Name__c}” headerValue=”Merchant”/>
<apex:column headerValue=”Effective Date”>
<apex:outputText value=”{0,date,MMMM’ ‘d’ ‘yyyy}”>
<apex:param value=”{!r.Requested_Pricing_Change_Effective_Date__c}” />
<apex:column value=”{!r.Status__c}” headerValue=”Status”/>
<apex:column headerValue=”Created Date”>
<apex:outputText value=”{0,date,MMMM’ ‘d’ ‘yyyy}”>
<apex:param value=”{!r.CreatedDate}” />

<apex:panelGrid columns=”7″ rendered=”{!ISNULL(SelectedRequest)}”>
<apex:commandLink action=”{!first}” reRender=”RecentRequestsSection”>First</apex:commandlink>
<apex:commandLink action=”{!previous}” reRender=”RecentRequestsSection” rendered=”{!hasPrevious}”>Previous</apex:commandlink>
<apex:outputText value=”Previous” rendered=”{!NOT(hasPrevious)}”/>
<apex:commandLink action=”{!next}” reRender=”RecentRequestsSection” rendered=”{!hasNext}”>Next</apex:commandlink>
<apex:outputText value=”Next” rendered=”{!NOT(hasNext)}”/>
<apex:commandLink action=”{!last}” reRender=”RecentRequestsSection”>Last</apex:commandlink>
<apex:outputLabel value=”[Page {!pageNumber} of {!totalPages}]” />