Skip to content

Recent Articles

21
Aug

Highcharts extension for Sencha v3.2.1 is here

Highcharts extension v3.2.1 is out. This release includes important performance fix (due to my crap code) and corrupt xAxis display with connectNulls option.

13
Aug

Salesforce: Writing a Test class for Opportunity Product (OpportunityLineItem)

A note on writing a test class for Opportunity Product (OpportunityLineItem), when assigning a product to an OpportunityLineItem, we need to make sure the product is active. Otherwise, we will get integrity exception. To do that, we use isActive property to filter all the current active products.

    Account a = new Account(Name = 'Test Account Joe ');
    PricebookEntry pbID = [select Id, name from PricebookEntry where isActive = True limit 1];
    Opportunity o = new Opportunity();
    OpportunityLineItem ol = new OpportunityLineItem();
        
    insert a;

    o.AccountId = a.Id;
    o.Name = 'Test_Joe_123';
    o.StageName = 'Prospecting';
    o.CloseDate = date.today();
    o.Type = 'New Business';
    insert o;
        
    ol.OpportunityId = o.Id;
    ol.Quantity = 1;
    ol.UnitPrice = 2.00;
    ol.PricebookEntryId = pbId.Id;
        
    insert ol;
11
Aug

PDNS Recursor: Forwarding DNS queries to local DNS Server

I have setup two PDNS servers running in the same host; pdns_server (the authoritative server) and pdns_recursor (a recursive server).

Here are the configurations for both PDNS servers settings:

pdsn.conf

launch=gpgsql

loglevel=10
log-dns-queries=yes

gpgsql-host=127.0.0.1
gpgsql-user=xxxxxx
gpgsql-password=xxxxxxx
gpgsql-dbname=xxxxxx

recursor=127.0.0.1:5678

recursor.conf

forward-zones=.=10.10.10.1;8.8.8.8
local-port=5678
trace=on

Read more »

4
Aug

Salesforce: Workaround to Assign Asset Name with Auto Increment Unique Value

In Salesforce, when creating an Asset entry, the Name field is a mandatory text field. For some users, this field has no particular purpose but cannot be left empty. For others, they may want to set the field with unique incremental id. In order to assign the Name field with an auto incremental value, a workaround solution is to first create a custom numeric field, (e.g.) Auto Update Id, with auto increment property.

screen

Next step is to create a trigger which sets the Name field to the Auto_Update_Id value. Goes to Customize -> Assets -> Triggers and creates a trigger with the following simple code:

trigger SetNameToAutoIncrId on Asset (after insert) {

    for(Asset a: trigger.new){
       for (Asset ua: [ Select Name, Auto_Update_Id__c FROM Asset where Id = :a.id ]) {
           ua.Name = ua.Auto_Update_Id__c;
           update ua;
       }
    }
}

Since the auto increment value won’t be assigned until an Asset record is created, therefore we have to create a trigger with after insert event. Also Salesforce does not allow users to modify the triggered record in after insert event. So that we need to issue another SOQL query, assign the result to another Asset object and then update the record to the DB.

Although the user still needs to input something into the mandatory Name field, the insert operation will automatically overwrite the Name field with an unique numerical id.
 

11
Jul

Developing a Salesforce Trigger

Lets assume we need to develop a trigger to perform two checks on opportunities:

  • When creating or updating an opportunity, the Type selection box must be selected with a value
  • When an opportunity stage is selected to ‘Closed/Won’, the opportunity must contain Products (OpportunityLineItem) entry

Read more »

11
Jul

Where in Salesforce to create a trigger

There are two ways to create a trigger in Salesforce page; Setup or Developer Console

screen
Read more »

30
Jun

Python 3: __del__ method and imported modules

My python script generates the following error and the strange thing is that this error only occurs occasionally:

Exception AttributeError: "'NoneType' object has no attribute 'path'" in 
<bound method Client.__del__ of <__main__.MyObject object at 0x108c3dc50>> ignored

Read more »

26
Jun

Salesforce: Triggering Closed/Won Opportunity to New Entry in Assets Table associated with Opportunity.

In Salesforce, when an opportunity stage becomes ‘Closed/Won’, it doesn’t automatically convert the Products in Opportunity (OpportunityLineItem) into Assets. Luckily, there are two contributed packages available in Salesforce’s Appexchange; one by Comity Design and the other one by Salesforce Lab.

In this article, we

  • Install the Closed/Won trigger package
  • Add custom field to Asset table to reference Opportunity
  • Modify trigger code to update the reference to Opportunity in the Asset table
  • Show how to include the Assets table in the Accounts page layout

Read more »

19
Jun

PowerDNS: Configuring and Running Authoritative & Recursor Servers In The Same Host.

This article gives a quick introduction of setting up PowerDNS (pdns) Authoritative and Recursor servers, and also demonstrates a scenario that how we need to use both in the same host.

DNS

DNS has two type of server operations: Authoritative and Recursive. Most common use of DNS servers is authoritative. For those who don’t know the difference, here is a good introduction. Both are for different purposes, also both types of server can be operated individually and cooperatively under the same host. Read more »

23
Mar

Issue on running grunt. Error: Cannot find module ‘findup-sync’

grunt error

This problem occurs when I archive the whole node_modules directory (including the grunt command) to another machine. I have to do this because I have to create an Ubuntu 14 ISO for offline installation containing grunt as a requirement. Generally, this copy across approach works fine but not straightforward for grunt.

Although reinstalling grunt on the target machine works, it is not an option to me,

npm install -g grunt-cli

The real problem is actually the executable, /usr/local/bin/grunt, that is supposed to be a symbolic file which links to ../lib/node_modules/grunt-cli/bin/grunt. Copying across can break the symbolic link which causes the above error when running it. Rebuild the symbolic link and the problem is resolved.

 

Follow

Get every new post delivered to your Inbox.

Join 40 other followers