Monday 31 October 2011

Salesforce DEV 401 Preparation - Day 2

1. Balance sheet
Create balance sheet report.
Create Balance Sheet object:
+ Name: Text(80)
+ Period: Lookup(Period)
+ Credit: Roll-Up Summary(Sum Journal.Credit)
+ Debit: Roll-Up Summary(Sum Journal.Debit)
+ Amount: Formula(Credit - Debit)

Use Data Loader to insert data: http://www.megaupload.com/?d=J3V4HFCE

Update Journal object:
+ Balance_Sheet: Master-Detail(Balance Sheet)

Use Data Loader and Excel to collect and insert data: http://www.megaupload.com/?d=G54TNI1T

Salesforce DEV 401 Preparation - Schedule

1. 31/10/2011 - 04/11/2011: Build accounting application without coding

2. 07/11/2011: Review functions on [App Setup -> Customize], [App Setup -> Deploy], [App Setup -> Schema Builder], [App Setup -> Installed Packages], [App Setup -> AppExchange Marketplace], [App Setup -> Critical Updates]

3. 08/11/2011: Review functions on [App Setup -> Create], [App Setup -> Develop]

4. 09/11/2011: Review functions on [Personal Setup], [Administration Setup -> Manage Users]

5. 10/11/2011: Review remaining functions on [Administration Setup]

6. 11/11/2011: Build application without coding

7. 14/11/2011: Review functions on [App Setup -> Customize], [App Setup -> Deploy], [App Setup -> Schema Builder], [App Setup -> Installed Packages], [App Setup -> AppExchange Marketplace], [App Setup -> Critical Updates]

8. 15/11/2011: Review functions on [App Setup -> Create], [App Setup -> Develop]

9. 16/11/2011: Review functions on [Personal Setup], [Administration Setup -> Manage Users]

10. 17/11/2011: Review remaining functions on [Administration Setup]

11. 18/11/2011: Build application without coding

12. 21/11/2011: Review functions on [App Setup -> Customize], [App Setup -> Deploy], [App Setup -> Schema Builder], [App Setup -> Installed Packages], [App Setup -> AppExchange Marketplace], [App Setup -> Critical Updates]

13. 22/11/2011: Review functions on [App Setup -> Create], [App Setup -> Develop]

14. 23/11/2011: Review functions on [Personal Setup], [Administration Setup -> Manage Users]

15. 24/11/2011: Review remaining functions on [Administration Setup]

16. 25/11/2011: Build application without coding

17. 26/11/2011 - 30/11/2011: Review mock exams

2nd week: Review and take notes.
3rd week: Review and make questions
4th week: Review and build mock exams
  

Sunday 30 October 2011

Salesforce DEV 401 Preparation - Day 1

I start with building accounting application without coding.

1. Chart of Accounts
Create forms for adding/editing chart of accounts.

Create Account object with following fields:
+ Code: Text(20)
+ Name: Text(80)
+ Kind: Picklist(Assets, Liabilities, Owner's Equity, Operating Revenues, Operating Expenses, 
Non-operating Revenues and Gains, Non-operating Expenses and Losses)

Use data loader to insert data: http://www.megaupload.com/?d=MXVL8LB1

2. Transactions
Create forms which record transactions.

Create Period object:
+ Name: Text(80)
+ Start: Date
+ End: Date
+ Previous: Lookup(Period)

Create Journal object:
+ Name: Text(80)
+ Account: Lookup(Account)
+ Period: Lookup(Period)
+ Credit: Roll-Up Summary(Sum Transaction.Credit)
+ Debit: Roll-Up Summary(Sum Transaction.Debit)
+ Amount: Formula(Credit - Debit)

Create Transaction object:
+ Name: Text(80)
+ Date: Date
+ No.: Number
+ Journal: Master-Detail(Journal)
+ Credit: Currency
+ Debit: Currency
+ Amount: Currency

Create workflow rules that update fields: 
+ Journal.Name = Journal.Period.Name & Journal.Account.Name
+ Transaction.Credit = IF( ISPICKVAL( Journal__r.Account__r.Kind__c , "Operating Revenues" ) ||  ISPICKVAL( Journal__r.Account__r.Kind__c , "Non-operating Revenues and Gains" ), ABS( Amount__c ) , IF( ISPICKVAL( Journal__r.Account__r.Kind__c , "Assets" ) && Amount__c < 0, ABS( Amount__c ) ,  IF( (ISPICKVAL( Journal__r.Account__r.Kind__c , "Liabilities" ) || ISPICKVAL( Journal__r.Account__r.Kind__c , "Owner's Equity" ) ) && Amount__c > 0 , ABS( Amount__c ) , 0  )  ) )
+ Transaction.Debit = IF( ISPICKVAL( Journal__r.Account__r.Kind__c , "Operating Expenses" ) ||  ISPICKVAL( Journal__r.Account__r.Kind__c , "Non-operating Expenses and Losses" ), ABS( Amount__c ) , IF( ISPICKVAL( Journal__r.Account__r.Kind__c , "Assets" ) && Amount__c > 0, ABS( Amount__c ) ,  IF( (ISPICKVAL( Journal__r.Account__r.Kind__c , "Liabilities" ) || ISPICKVAL( Journal__r.Account__r.Kind__c , "Owner's Equity" ) ) && Amount__c < 0 , ABS( Amount__c ) , 0  )  ) )

I prepare for Salesforce DEV 401

After falling first Salesforce DEV 401 exam, I start looking around Internet to find tips for exam. I have found some useful.

1. Developer 401 Force.com Exam - Tips
The developer 401 Force.com Exam is geared toward people who do not know how to code as per say write a trigger or Visual Force Page. 
But does understand what the technical functions are in salesforce.com.
Things needs to be reviewed:
+ Security that is involved on the force.com platform <== Refers to Groups, Roles, Profiles
+ Master/Detail/Lookup relationships
+ Junction Objects
+ relationship between Developer/Full Copy/Config sandbox and Production
+ Matrix Reports (similar to a Pivot table in Excel)
+ DataLoader
+ Import Wizard
+ Know all the Components(See pic below)
Basically go through the setUp area and you should know and understand everything that is there for this exam. 
Remember this exam does not test your code knowledge it is an exam to make sure you undertstand the technical side of things.
Everytime when a developer gets a project, one must think of two things:
+ Can it be done without code <== this is understand the functions of the App.
+ If done in code then what would be affected, as in Relationships between objects, Reports, etc. 

Tuesday 25 October 2011

Demand for a product increases when the prices of its complements decrease

Demand for a product increases when the prices of its complements decrease.
This quote comes from Strategy Letter V (Joel on software). It's useful for selling products.
Every product in the marketplace has substitutes and complements. 
A substitute is another product you might buy if the first product is too expensive. 
Chicken is a substitute for beef. 
If you're a chicken farmer and the price of beef goes up, 
the people will want more chicken, and you will sell more.
When computers become cheaper, more people buy them, and they all need operating systems, 
so demand for operating systems goes up, which means the price of operating systems can go up.
Smart companies try to commoditize their products' complements.
When IBM designed the PC architecture, they used off-the-shelf parts instead of custom parts, 
and they carefully documented the interfaces between the parts in the (revolutionary) IBM-PC Technical Reference Manual. 
Why? So that other manufacturers could join the party. As long as you match the interface, you can be used in PCs. 
IBM's goal was to commoditize the add-in market, which is a complement of the PC market, and they did this quite successfully. 
Within a short time scrillions of companies sprung up offering memory cards, hard drives, graphics cards, printers, etc. 
Cheap add-ins meant more demand for PCs.
When IBM licensed the operating system PC-DOS from Microsoft, Microsoft was very careful not to sell an exclusive license. 
This made it possible for Microsoft to license the same thing to Compaq 
and the other hundreds of OEMs who had legally cloned the IBM PC using IBM's own documentation. 
Microsoft's goal was to commoditize the PC market. Very soon the PC itself was basically a commodity, with ever decreasing prices, 
consistently increasing power, and fierce margins that make it extremely hard to make a profit. The low prices, of course, increase demand.
 Increased demand for PCs meant increased demand for their complement, MS-DOS. 
All else being equal, the greater the demand for a product, the more money it makes for you. 
And that's why Bill Gates can buy Sweden and you can't.

Sunday 16 October 2011

Retrieve CPU brand by C and Win32 API


In order to retrieve CPU brand, information in red square on above photo, please use following code:

string GetCPUBrand() {
 char pszCPUBrand[49];
 memset(pszCPUBrand, ' ', 49);

 _asm {
  mov eax, 80000002h
  cpuid

  // getting information from EAX

  mov pszCPUBrand[0], al
  mov pszCPUBrand[1], ah
  ror eax, 16
  mov pszCPUBrand[2], al
  mov pszCPUBrand[3], ah

  // getting information from EBX

  mov pszCPUBrand[4], bl
  mov pszCPUBrand[5], bh
  ror ebx, 16
  mov pszCPUBrand[6], bl
  mov pszCPUBrand[7], bh

  // getting information from ECX

  mov pszCPUBrand[8], cl
  mov pszCPUBrand[9], ch
  ror ecx, 16
  mov pszCPUBrand[10], cl
  mov pszCPUBrand[11], ch

  // getting information from EDX

  mov pszCPUBrand[12], dl
  mov pszCPUBrand[13], dh
  ror edx, 16
  mov pszCPUBrand[14], dl
  mov pszCPUBrand[15], dh

  mov eax, 80000003h
  cpuid

  // getting information from EAX

  mov pszCPUBrand[16], al
  mov pszCPUBrand[17], ah
  ror eax, 16
  mov pszCPUBrand[18], al
  mov pszCPUBrand[19], ah

  // getting information from EBX

  mov pszCPUBrand[20], bl
  mov pszCPUBrand[21], bh
  ror ebx, 16
  mov pszCPUBrand[22], bl
  mov pszCPUBrand[23], bh

  // getting information from ECX

  mov pszCPUBrand[24], cl
  mov pszCPUBrand[25], ch
  ror ecx, 16
  mov pszCPUBrand[26], cl
  mov pszCPUBrand[27], ch

  // getting information from EDX

  mov pszCPUBrand[28], dl
  mov pszCPUBrand[29], dh
  ror edx, 16
  mov pszCPUBrand[30], dl
  mov pszCPUBrand[31], dh

  mov eax, 80000004h
  cpuid

  // getting information from EAX

  mov pszCPUBrand[32], al
  mov pszCPUBrand[33], ah
  ror eax, 16
  mov pszCPUBrand[34], al
  mov pszCPUBrand[35], ah

  // getting information from EBX

  mov pszCPUBrand[36], bl
  mov pszCPUBrand[37], bh
  ror ebx, 16
  mov pszCPUBrand[38], bl
  mov pszCPUBrand[39], bh

  // getting information from ECX

  mov pszCPUBrand[40], cl
  mov pszCPUBrand[41], ch
  ror ecx, 16
  mov pszCPUBrand[42], cl
  mov pszCPUBrand[43], ch

  // getting information from EDX

  mov pszCPUBrand[44], dl
  mov pszCPUBrand[45], dh
  ror edx, 16
  mov pszCPUBrand[46], dl
  mov pszCPUBrand[47], dh

 }

 pszCPUBrand[48] = '\0';

 return string(pszCPUBrand);
}

Saturday 15 October 2011

Call JSONP with jQuery

In order to call JSONP with jQuery, please use following code

function jsonp() {

  this.request = function(url, args, callbackVar, bufferID) {
    var super = this;
    var callback = 'jsonp_response_' + Math.floor(Math.random() * 100000);
    window[callback] = function(data) {
      super.response(args, data);
      delete window[callback];
    }
    var params = { callbackVar : callback };
    var buffer = $('#' + bufferID);
    buffer.append("<script src='" + url + '&' + jQuery.param(params) + "'></script>");
  }

  this.response = function(args, data) {
  }

}

callbackVar: name of GET variable containing JSONP callback, eg. api.php?jsonp=response
bufferID: id of empty div tag which is used for temporarily adding script tag
args: arguments is passed to callback function

Friday 14 October 2011

Upload file to SharePoint site

In order to upload file to SharePoint site, please use following code:

private String uploadFile(String site, String username, String password, String library, String filename) {
     String tag = "";
     try {
      CopySoapStub stub = SharePointWSDL.newCopy(new URL(site + "/_vti_bin/Copy.asmx"), new CopyLocator());
      stub.setUsername(username);
      stub.setPassword(password);

      String name = (new File(filename)).getName();
      String tagPath = site + "/" + library + "/" + name; 
      FieldInformation[] fis = new FieldInformation[1];
      UnsignedIntHolder uih = new UnsignedIntHolder(new UnsignedInt());
      CopyResultCollectionHolder crch = new CopyResultCollectionHolder(new CopyResult[] { new CopyResult() });

      fis[0] = new FieldInformation();
      fis[0].setInternalName("Title");
      fis[0].setDisplayName(name);
      fis[0].setType(FieldType.Text);
      fis[0].setValue(name);
       
      stub.copyIntoItems(tagPath, new String[] { tagPath }, fis, readFile(filename), uih, crch);
      boolean success = true;
      for (int i = 0; i < crch.value.length; i++) {
       if (CopyErrorCode._Success.equals(crch.value[i].getErrorCode().getValue())) continue;
       logger.error(crch.value[i].getErrorCode().getValue() + " : " + crch.value[i].getErrorMessage());
       logger.info(crch.value[i].getDestinationUrl());
       success = false;
      }
      if (success) {
          tag = tagPath;
      }
     } catch (Exception e) {
      logger.error("", e);
     }
     return tag;
    }
    
    private byte[] readFile(String filename) {
     File file = new File(filename);
     byte[] tag = new byte[0];
     try {
         tag = new byte[(int)file.length()];
         InputStream is = new FileInputStream(file);     
         int offset = 0;
            int numRead = 0;
            while (offset < tag.length && (numRead = is.read(tag, offset, tag.length - offset)) >= 0) {
                offset += numRead;
            }     
     } catch (Exception e) {
      logger.error("", e);
     }
     return tag;
    }

Above code use Java WSDL for SharePoint

You should use domain name in site URL instead of IP.

Using IP will cause error. Please checkout Get 'Object reference not set to an instance of an object' error when upload file to SharePoint

Thursday 13 October 2011

Accessing SharePoint web service requires Basic Authentication

In order to access SharePoint web service through java WSDL, you need to enable Basic Authentication for IIS. 

Please checkout Get '(401)Unauthorized' error when calling SharePoint web service and wsdl2java with Basic Authentication (Axis 1.6.1)

Retrieve list of libraries on SharePoint site

In order to retrieve list of libraries on SharePoint site, please use following code:

private List getLibraries(String site, String username, String password) {
     List tag = new ArrayList();
     try {
      ListsSoapStub stub = SharePointWSDL.newLists(new URL(site + "/_vti_bin/Lists.asmx"), new ListsLocator());
      stub.setUsername(username);
      stub.setPassword(password);
      com.microsoft.schemas.sharepoint.soap.GetListCollectionResponseGetListCollectionResult lcr = stub.getListCollection();
      if (lcr.get_any().length > 0) {
          NodeList children = lcr.get_any()[0].getChildNodes();
          for (int i = 0; i < children.getLength(); i++) {
           Node node = children.item(i);
           String baseType = node.getAttributes().getNamedItem("BaseType").getNodeValue();
           if (!"1".equals(baseType)) continue;
           String template = node.getAttributes().getNamedItem("ServerTemplate").getNodeValue();
           String title = node.getAttributes().getNamedItem("Title").getNodeValue();
           if ("|101|115|109|".indexOf("|" + template + "|") < 0) continue;
           tag.add(title);
          }
      }
     } catch (Exception e) {
      logger.error("", e);
     }
     return tag;
    }
Above code use Java WSDL for SharePoint

Tuesday 11 October 2011

Install java plugin on Ubuntu 10.04.3 LTS

1. Open FireFox or Chromium
2. Go go http://java.com
3. Click on "Free Java Download"

4. Scroll to Linux section
5. Click on "Verify Now" link


6. When you are asked to install missing plugin, choose to install "Icedtea Java Plugin"
7. Close browser and open it again, java is enabled for your browser now.