Skip to content

Archive for

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.