Pages

Thursday, April 19, 2012

Server Monitoring - Alerts Object

The first thing that I'm going do is create the object in which my alerts are going to live in Salesforce.  For this example, I'm going to create a dedicated custom object for this.  You may want to use Chatter or even incorporate it into your existing structure; perhaps you have some sort of IT inventory (who doesn't?) objects that you can connect to.

The basics of what we need are:
  • The resource - what device is having an issue
  • The alert - details about the issue the resource is having (low disk space for our usage)
This is how I'm configuring the object on the "New Custom Object" page:


I've checked off both "Allow Reports" and "Allow Activities."  Ideally, when the alerts are configuring and being dumped into Salesforce, I will be building workflow to send off some e-mails.  Then I'll begin building a few reports for any notifications over the course of time - scheduled weekly emails of low system resources sounds kind of cool.  Imagine that patterns you could observe over the course of a few months.  I've also enabled notes and attachments as I imagine this could be used for future issue identification and resolution as well.  Feel free to create a tab for this if you'd like.

Once the object is created, I've got my shell of an object with the basic fields:
  • Alert Name - auto number
  • Created By
  • Last Modified By
  • Owner
Now I'm going to add my two custom fields mentioned above and listed below:
  • Resource
  • Details

I've required that the "Resource" field be populated at the field level.  Don't forget to set the correct permissions for these fields based on profiles on the following screen.

Not a lot of rocket science in this post, but at least now we've got our object for which we'll insert our alert records into.  The next posts will be a little more exciting and cover creating and scheduling a batch file for performing a disk space checks and creating a Windows Perfmon alert.













Friday, March 23, 2012

Server Monitoring - Project Description

It's a very Salesforce Friday; the weather is nice, my fingers are flying, and most importantly my code is saving without errors!

I'm hoping the description got your attention on this one and you wondering how in the world Salesforce is going to monitor your servers.  Well, I've fed your assumptions a half-truth.  At this point, Salesforce isn't going to be doing the monitoring (yet?); it will be simply providing to you notifications.

I know, I know - you've got high-end systems in place doing all the server monitoring you could ever dream of full of alerts, notifications, bells, whistles, and some Rita's Water Ice on top of that too (you know, in honor of it being Spring).  Don't overlook the point of this series; it isn't to just create a custom object that will trigger some workflow.  It's about being able to tie together three or four different pieces of software to build an entire system that leverages the flexibility of Salesforce (and because all roads will inevitably lead to Salesforce).  Not just a system, but something that can easily be expanded an built upon.

Here's what I'm thinking:

Monitor a server
Use Perfmon - Memory Usage
Use a command-line utility - Hard disk utilization

Create Alerts
What's wrong with who

Import Process
Get that info into Salesforce so we can use it
Where's the data going to live?

Dashboard/Workflow
What are you going to do with that data?

Stay tuned!  We're going to have some fun with Perfmon, batching, Data Loader, and some VF.

Thursday, March 15, 2012

One View to Rule Them All

Scenario:  I was working on customizing a project management app and needed a quick view named "My Projects" that would allow a user to see only the projects in which they were listed as the "Project Manager."

"Project Manager" was a custom User lookup field.  It seemed erroneous to instruct users to create their own views.  There had to be a way that I could create it once and it would provide the correct results for each user.

When you are on the "Create New View" screen, unlike when you are writing a workflow rule, you don't have the ability to create formula based criteria; only the "Filter By Additional Fields" field-operator-value drop downs are available.
IdeaExchange:  https://sites.secure.force.com/success/ideaView?id=08730000000K149AAC




Unfortunately, the Owner of a Project record won't necessarily be the Project Manager, so using the "My Projects" filter won't work (wouldn't it be nice if for any "My" option, a list of User lookup fields would appear that you could select from?)
IdeaExchange:  https://sites.secure.force.com/success/ideaView?id=08730000000grYFAAY


To create one view to rule them all, I ended up creating a formula field that would compare the current user's ID to the Project Manager field and return either 0 or 1.


IF($User.Id = Project_Manager__c, 1,0)


Now that you have your field, any record that you are looking at in which your User ID matches the ID found in the Project Manager field, the "PM is Me" formula field should read "1."


That being so, you can create your view with a single criterion:

That's that!



Monday, February 13, 2012

There's a Hole in My Bucket!

Ah, for many Salesforce users, Spring '12 was rolled out over the weekend. There are lots of new features that I've been chewing on in the pre-release sandbox and a few surprises.

One of the new features is the ability to create report "Buckets." Buckets let you create groups for a field's data without needing to create a formula field. I can't tell you how many formula fields I've created just to display the information I want to see on a report correctly. Of course - these bucket fields exist only on the report you're creating, so if you want to base workflow off of the field, it is off to the formula field editor for you.

Say you've got your list of clients, all equally important to you (of course), but you'd like to group them by the amount of assets they've brought to you. I'm not saying my Gold level clients are going to receive any special treatment over the Bronze level - I just want to know... really.

I'm going to classify my clients, using three tiers:
Gold: Anyone over 3,000,000
Silver: Between 1,000,000 and 3,000,000
Bronze: Below 1,000,000

1)  To create a new Bucket field, within a new/existing report, click on the "Add Bucket" link within the fields section.



2)  Next, double-check your "Source Column, give your Bucket field a name, and define your ranges:

3)  Click on the "OK" button and you'll see your newly created "Service Level" field within your report grid:


 
Unfortunately, like many initial rollouts of SF (I'm looking at you lookup field filters), it is lacking the ability to create and use filters.

What if I had a client that has been with me from day one.  Sounds like an instant Gold Service Level criterion to me.  It would be great to be able to include something like "Initial Contract Date < 1/1/2005" = Gold, else follow the ranged criteria.

For more information, check out this video, by my new favorite SF video narrator:  http://www.youtube.com/watch?v=QFYEtBtLHG4

Saturday, February 11, 2012

Don't Double Quote Me!

I came across an odd bug within a Visualforce page yesterday.  At least I think it is a bug - I can't explain it and it has been esclated to an upper tier of premier support.

Within an <apex:outputPanel />, I was using a "rendered" formula within the tag:

<apex:outputPanel rendered="{!If(AND(myObject__c.relatedObject__r.theSuspectField__c = 'The Picklist Value',myObject__c.myField2 > 0), true,false)}">


Ater I saved the page (and although the page would save), I started to receive warnings that I needed to close my tag. Thinking that was strange, I commented out everything between my and tags and received the same thing. Then I saw my rendered formula - that's strange, I must have used double quotes by accident. This is what I saw:

<apex:outputPanel rendered="{!If(AND(myObject__c.relatedObject__r.theSuspectField__c = "The Picklist Value",myObject__c.myField2 > 0), true,false)}">


I replaced the double quotes with single ticks again, hit save, and bam - they were converted to doubles again.

What gives?

Eventually I figured out that if I changed the order in which my fields were listed, the record would save as expected - no double quotes:

<apex:outputPanel rendered="{!If(AND(myObject__c.myField2 > 0,myObject__c.relatedObject__r.theSuspectField__c = 'The Picklist Value'), true,false)}">


I'm assuming that this it has something to do with myObject__c.relatedObject__r.theSuspectField__c being a picklist field, located on a related record.  Why it works in an alternate position in the formula, beats me, but is probably one of those strang quirks of Salesforce.

I'll update as I find out more.

Note:  I was using the inline VF editor, but saw the same issue when I attempted to resolve the issue within the Force.com/Eclipse IDE.

Tuesday, January 3, 2012

VF Templates: Formatted Merge Values (dates)

Just like in the previous post, another type of field that you might not receive your expected data format are date fields.
My record said: 

This is the VF code I was using:
{!relatedTo.myDateField__c}

The resulting text displayed in an email was:

That's not too pretty.
For date fields, you can extract individual pieces of the date, including the month, year, and date.  Once you pull those pieces out, you can separate them with a forward slash (“/”) and then it will look more like the date field you were hoping for.

I'm hoping for something that looks like "1/3/2012."

To retrieve the "1" for the month:

{!month(relatedto.Distribution_Form_Received_Date__c)}

To retrieve the "3" for the date:


{!day(relatedto.Distribution_Form_Received_Date__c)}


To retrieve the year "2012":

{!year(relatedto.Distribution_Form_Received_Date__c)}


Put them all together with those forward slashes:
{!month(relatedto.Distribution_Form_Received_Date__c)}/{!day(relatedto.Distribution_Form_Received_Date__c)}/{!year(relatedto.Distribution_Form_Received_Date__c)}


With that little bit of magic, your end result will be:

Monday, January 2, 2012

VF Templates: Formatted Merge Values (currency)

Once in a while, I'll run across something that I've forgotten all about.  Today, I was working with a Visualforce e-mail template that contained a currency field as one of the merge fields.

My record said:  $99.00
I was pulling it in with just this VF code:

{!relatedTo.myCurrencyField__c}

Just doing that resulted in the template displaying:
Not quite what I was looking for.  What I ended up doing was throwing my merge data into a pre-formatted apex:outputText field, using an apex:param:

<apex:outputText value="{0,number,$###,###,##0.00}">
    <apex:param value="{!relatedTo.myCurrencyField__c}" />
</apex:outputText>

This will format the dollar amount up to $999,999,999.99.  The 0's are there just incase your amount is not a full dollar ($0.89) or an amount that ends in 0 ($25.40).  Otherwise, those values are truncated ($.89 and $25.4 respectively).

Now the template looks like this:





To see more of what you can do, check out:  Java MessageFormat