Use SED to get rid of those nasty empty lines in a text file:
sed '/^$/ d' someFile > someNewFile
mv someNewFile someFile
July 3, 2009
I Heart Unix
June 7, 2009
MySQL’s version of SQL*Loader
Just found the nice command built into MySQL to load data files. It couldn’t have been simpler to use. Just be sure to through the right newline. Using ‘\r\n’ worked for a file generated in SSIS in my case.
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[CHARACTER SET charset_name]
[{FIELDS | COLUMNS}
[TERMINATED BY 'string']
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char']
]
[LINES
[STARTING BY 'string']
[TERMINATED BY 'string']
]
[IGNORE number LINES]
[(col_name_or_user_var,...)]
[SET col_name = expr,...]
See more magic here from the MySQL manual.
April 23, 2009
Dynamicallly build URLs in RightNow
I always forget this, despite it being one of the most important features.
If you want to build a tab, that can pass a value from a custom field in RightNow as part of the parameter you can do it as follows:
- $p_ccf_ — use with contact custom fields
- $p_orgcf_ — use with organization custom fields
- $p_icf_ — use with incident custom fields
- $p_acf_ — use with answer custom fields
- $p_spcf_ — use with sales product custom fields
- $p_ocf_ — use with opportunity custom fields
Why would the “H” would one do this? Think of it this way. Client ABC has an existing portal that uses friendly URLs (like Ruby on Rails). So if I had an account-id custom field on an organization, I could pass that value and the web page shown in the control would present information pertinent to that account-id (aka. organization). HUGE savings.
April 20, 2009
Turn a WSDL to a referenceable DLL
Found this will surfing the intertubes. I’m using it to build my first Webservice integration into RightNow using their desktop integration API.
Here were my steps in creating the dll.
- Turn the WSDL into buildable, C-Sharp code
- Compile the C-Sharp code into a referenceable DLL
"C:\Program Files\Microsoft SDKs\Windows\v6.0a\bin\wsdl.exe" /l:cs /protocol:SOAP https://www.penproplus.com/pppwebservice/pppwebservice.asmx?WSDL
c:\windows\microsoft.net\Framework\v3.5\csc /t:library /r:System.Web.Services.dll /r:System.Xml.dll PPPWebServices.cs
I had a couple of wonky path issues when running these commands. I had to make sure I was running the CSC compiler from the .Net Framework directory. Otherwise, I get some complaints about missing dlls and other grumpy messages
February 23, 2009
RightNow Desktop Integration .. it begins
I’ve started exploring the new capabilities of RightNow desktop integration. It looks to be quite powerful, assuming I can get my hacking skills around it.
Unit testing code is a pain with the integration API. Each change requires a restart of RightNow. That can take a while, even with a fast connection & computer.
One recommendation, however, is to add the following in the project’s Post-build event. This will automatically deploy the new compiled dll and move it to the proper directory for development testing. It should be part of the default set of templates, but it isn’t.
mkdir "%USERPROFILE%\RightNowDev"
mkdir "%USERPROFILE%\RightNowDev\AddIns"
mkdir "%USERPROFILE%\RightNowDev\AddIns\$(ProjectName)"
copy /Y "$(TargetDir)$(TargetName).*" "%USERPROFILE%\RightNowDev\AddIns\$(ProjectName)\"
Great stuff.
January 28, 2009
RNOWOrganization – how to add a parent?
I’m still working with hacking my way through C#. The latest stumbling block is adding an organization with an associated parent organization. The end result would look like the following within RightNow:

To date, I have the following code using the RNOW Data Connection API
// set parent org
if (Convert.ToString(row[38]) != "")
{
int z = getXrefId(Convert.ToString(row[38]), tblXrefIds);
if (z != 0)
{
RNOWOrganization parentOrg = new RNOWOrganization(z);
List parentOrgs = new List();
parentOrgs.Add(parentOrg.ID);
myOrg.Parent = parentOrgs;
}
else
{
//log error
}
}
The current question? The code syntax 'myOrg.Parent = parentOrgs;' doesn’t work. Instead, I get the error:
Cannot implicitly convert type ‘System.Collections.Generic.List<int>’ to ‘System.Collections.Generic.List<int?>’
Seems same to me.
Argh!!! Why can it just be a single Integer representing the ID of the organization. A list to set a single parent? What for? Make it simple stupid. The head scratching continues.
Update
Turns out C# provides a way to define a nullable list of collections. This is defined by the ‘?’ notation. So, parentOrgs in the code snippet above had to be defined by:
List<int?> parentOrgs = new List<int?>();
Defining the hierarchy is still not working 100%, but this hurdle is hopped over.
January 7, 2009
RightNow Connect DLL
I’ve found myself doing some .Net coding these days. A rest from Ruby on Rails (which is friggin’ awesome).
When using the RightNow Connect DLL I always would get the most common error of all..
“Invalid Server Version. Server ‘ ‘. Connect ‘8.5.0.127′.”
Scratching my head. I closed the new solution in Visual Studio, which caused the solution’s folder structure to be created. After reopening it and re-pointing the reference to the RightNow Connect DLL. Things seem to work. No problems with that A-N-N-O-Y-I-N-G “invalid server version” message. Viola! It works. Good enough.
December 9, 2008
And now for something completely different…mongrel
I’ve been switching gears lately. I’m not riding the ruby rails or trying to at least.
Thanks to this entry, I’m finally up and running. I’ll probably need this in the future, so I’m saving it for future reference. Thanks for the post.
Configure the Mongrel Cluster
mongrel_rails cluster::configure -e production -p 8000 -N 2 -c /home/railsuser/rails/appname -a 127.0.0.1
A note about this:
-N 2 : Two instances of Mongrel will be started up as part of this cluster
-p 8000: The Mongrel instances will listen at ports starting at 8000 (i.e. 8000 and 8001)
/home/railsuser/rails/appname : Path to the folder where your Rails app resides
-a 127.0.0.1 : This restricts access to localhost.
August 18, 2008
Reporting in Salesforce
Oh how I loathe thee… so damn limited, I’m tempted just to build a secondary database to run a freakin’ SQL query. Real SQL not the SOQL stuff that can’t even do joins.
Give me the ability to aggregate on my terms
Give me the ability to specify joins on my terms
Give me the ability to specify OUTER joins on my terms
Oh how I loathe thee…. so damn limiting.
August 13, 2008
Salesforce.com APEX – new record trigger
Bouncing around a little bit now, I’ve found myself on a Salesforce.com project (dare I say “trapped”?). Anyway, I did have some fun coding with the Force.com IDE.
In this scenario, I had to write my very first trigger. The requirement was to create a case upon the creation of a new record. My code ended up looking like this for the trigger.
trigger createCaseFromBroker on BrokerShop__c (after insert) { List<Group> sfdcGroup = [select Id, name from Group where Name = 'Support Queue' limit 1]; if(Trigger.new.size() == 1){ for(BrokerShop__c b:Trigger.new){ //for each broker, b, create a new DueDiligence case Case newCase = new Case( Subject = 'Perform Due Diligence', Broker_Shop__c = b.Id, Status = 'Open', Priority = 'Medium', Category__c = 'Pre-Approval', Subcategory__c = 'How to become a Broker', Origin = 'Web' //is there an origin? required in UI ); //if broker has a primary contact if(b.Primary_Contact__c != null){ newCase.ContactId = b.Primary_Contact__c; } if(!sfdcGroup.isEmpty()){ newCase.OwnerId = sfdcGroup[0].Id; } insert newCase; } } }
A couple of notes on this:
- This is the main trigger set to fire ‘after insert’
- The trigger is based on a custom SFDC object
On to the unit testing. I will give credit to Salesforce on this one. Requiring unit tests with a minimum coverage of 75% is commendable. Annoying for those of us that just hack our way (me), but still commendable. On to the tests. I encapsulated all of the test cases into my own class file.
public class CreateCase { static testMethod void test_createCaseFromBroker(){ //create contact record Contact contact = new Contact(); contact.FirstName = 'Test 1 - contact'; contact.LastName = 'Dummy'; insert contact; String contactId = contact.Id; //create broker record #1 BrokerShop__c broker1 = new BrokerShop__c(); broker1.Name = 'Test 1 - broker'; broker1.Street_Address__c = '123 Test St'; broker1.City__c = 'Test'; broker1.State__c = 'California'; broker1.Zip__c = '00000'; broker1.Primary_Contact__c = contactId; insert broker1; String broker1Id = broker1.Id; //validate case was created List<Case> bsCase = [ SELECT Id,Broker_Shop__c FROM case WHERE Broker_Shop__c = :broker1Id LIMIT 1 ]; for( Case c:bsCase ){ System.assertEquals(broker1Id,c.Broker_Shop__c); } } }
So there you have it. A insert trigger within Salesforce to create a related case record.