• boyd_r
  • NEWBIE
  • 50 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies

3Strata Technologies develops software applications for specialised healthcare providers. We are an Enterprise Ireland HPSU fresh out of the gates in start-up mode.

 

We're looking for developers, ideally with experience in Salesforce (Apex, Visualforce, API). Also interested, if you have C# , Java and web development skills and looking to expand your horizons. 

 

The job will be located in Dublin Ireland

 

Richard Boyd

CEO

3Strata Technologies

richard.boyd@3strata.com

www.3strata.com

I developed to 2 custom VF Pages with associated custom tabs. The first VF page used a commandLink to navigate to the second VF with using a PageReference in a CustomController. Like so

 

 

<apex:commandLink action="{!SearchPage}" id="SearchLink">Do Search</apex:commandLink> <br/>

 

 

All good, the 2nd Page opened fine, EXCEPT that the Tab associated with the find page wasn't selected, instead the first tab was selected. Put more accurately the CSS wasn't updating to reflect the currently selected page. The target VF page in question isn't associated with an SObject (haven't tested this so I'm not sure if this is relevant). In this instance its a custom SearchPage

 

Ok what to do - I couldn't find any documentation or help, but I realised that the issue actually lay with the CSS... If I could manipulate the CSS I could fix the issue - step forward jQuery. I needed to change the CSS in the DOM and jQuery is just the tool.

 

**** WARNING***** this is a hack, if SFDC change the CSS or structure this code could break.

 

First setup you reference to the jQuery Lib in your target VF page

 

 

<script type="text/javascript"  src="{!URLFOR($Resource.jQuery, '/jquery-1.4.2.min.js')}"></script>

 

 

The tabs on the standard interface are wrapped in a table with the class name '.tab'

 

 

<table cellspacing="0" cellpadding="0" border="0" id="tabBar" class="tab"><tbody>
<tr>
<td nowrap="nowrap">
<div>
<a title="Home Tab" href="https://na7.salesforce.com/home/home.jsp">Home</a>
</div>
</td>

 

 

The td element of the currently selected tab will have a class added with the values like so:

 

 

<td nowrap="nowrap" class="currentTab primaryPalette">

 

 

So what we need to do is remove the class from the incorrectly highlighted tab and add it to the tab we want highlighted. Here is the jQuery to do this. (My jQuery skills aren't going to win any prizes, someone may have a shorter/better way of achieving this)

 

 

<script type="text/javascript">
j$ = jQuery.noConflict();
	
	j$(document).ready(function($) {
	
		var title = j$('.tab').find('.currentTab > div > a').attr('title');
		
		if (title != 'Search Tab - Selected') {
			j$('.tab').find('.currentTab').removeClass('currentTab primaryPalette');
			
			var x= j$('a[title|=Search Tab]').attr('title', 'Search Tab - Selected');
			
			j$(x).parent().parent().addClass('currentTab primaryPalette');
		}
	});

</script>

 The title of the a link of the seleted tab is always myTabName Tab, if its currently selected is myTabName Tab -Selected. The code basically removes the class from the incorrect tab and adds it to the one we want.

 

The double use of .parent() (please feel free to offer a better technique) navigates from the <a> through the <div> back the current <td>, this is where the class needs to be added. And it works!!! But its a hack

 

 

 

 

 

 

 

 

I just switched from using the IDE on a PC to a MacBook Pro. I downloaded Eclipse and installed the Force.com prespective. All good. But I can't for the life of me figure out how to get my test classes to run. On the PC version a right click on the project - force.com-run tests and hey presto. Nada on the Mac - whats the secret. (BTW also used the IDE on ubuntu -no problem). Come on MacBoys publish the secret

 

Richard

I have a Controller that lets the User pass in a date (date of birth) and I'm trying to use Dynamic SOQL. The problem is that the query string insists in adding the date with 00:00:00 so a DoB or 1971-02-16 gets 00:00:00 appended. This causes the query to fail because the Date of Birth field is a Date only field.

 

I even tried this:

 

 

date d = date.newInstance(dob.year(), dob.month(), dob.day());

 

 

to try and force the removal of the time part before passing it to the query string, but the debug log shows the query passed looks like this:

 

Select id, Name, Date_of_Birth__c,  From myObject__c WHERE  Date_of_Birth__c = 1971-02-16 00:00:00

 

which fails. Pasting the above into the Schema explorer shows a similar failure - remove the 00:00:00 bit and it works fine

 

Help! :smileysad:

 

 

Just spent the past few hours trying to to get a method this uses SOSL to pass, but it kept returning zero rows.

 

So I check the code by running it in the Execute Anonymous window in the IDE and it worked!

 

I check the permissions - not an issue. I was stumped, then I stumbled upon this little help article hidden away at the back of the manual on Test.setFixedSearchResults

See Salesforce URLS

 

Ok so heres how it works in a test method:

 

//create your sobject with some test data

myobject o = new myObject(name='test');

 

//setup some ID's for the SOSL

 id[] fixedSearchResults = new id[1];
   fixedSearchResults[0] = o.id;
  Test.setFixedSearchResults(fixedSearchResults);

 

//Call the method on the controller that calls the SOSL query

mycontroller.doMySOSLQuery();

 

//do your asserts

 

 

I was looking for a definative answer on how to build navigation to a custom object in Apex and Visualforce. There are 3 answers depending on the scenerio.

 

The first solution was based on using the URLs of standard objects as defined in this blog Thoughts on Salesforce.

 

So your code would look something like this.

 

 

PageReference pageRef = New PageReference(/001/o);
pageRef.setRedirect(true);
return pageRef;

 

 

This brings you to the Accounts page. Thats fine for standard objects and assumes salesforce doesn't change these codes in the future. Assumption being the mother of all.... etc

 

If the url is to another visualforce page that's straight forward

 

 

PageReference pageRef = New PageReference(/apex/MyPage);
pageRef.setRedirect(true);
return pageRef;

 

 

Use <apex:param....> to pass parameters in the URL

 

 

But what if you've created a custom object and just want to navigate to the custom tab salesforce provides from a Visualforce page. You can use the first method a find the url used for the tab. HOWEVER there is no guarantee this will be the url if you distribute the app or move orgs. Its not a visualforce page so what do you?

 

The trick is to use the Schema class in you controller and find its Key Prefix.

 

 

//Get a reference to the Custom Object and gets its Key
Schema.DescribeSObjectResult result = customObject__c.sObjectType.getDescribe();

//navigate to the View Page
PageReference pageRef = New PageReference('/' + result.getKeyPrefix() + '/o');
pageRef.setRedirect(true);
return pageRef; 

The /o instructs the redirect to go to the View page of the custom tab. Using /e creates a new record. For more information go to this blog Salesforce URLS

 

 

Hope this helps

 

I developed to 2 custom VF Pages with associated custom tabs. The first VF page used a commandLink to navigate to the second VF with using a PageReference in a CustomController. Like so

 

 

<apex:commandLink action="{!SearchPage}" id="SearchLink">Do Search</apex:commandLink> <br/>

 

 

All good, the 2nd Page opened fine, EXCEPT that the Tab associated with the find page wasn't selected, instead the first tab was selected. Put more accurately the CSS wasn't updating to reflect the currently selected page. The target VF page in question isn't associated with an SObject (haven't tested this so I'm not sure if this is relevant). In this instance its a custom SearchPage

 

Ok what to do - I couldn't find any documentation or help, but I realised that the issue actually lay with the CSS... If I could manipulate the CSS I could fix the issue - step forward jQuery. I needed to change the CSS in the DOM and jQuery is just the tool.

 

**** WARNING***** this is a hack, if SFDC change the CSS or structure this code could break.

 

First setup you reference to the jQuery Lib in your target VF page

 

 

<script type="text/javascript"  src="{!URLFOR($Resource.jQuery, '/jquery-1.4.2.min.js')}"></script>

 

 

The tabs on the standard interface are wrapped in a table with the class name '.tab'

 

 

<table cellspacing="0" cellpadding="0" border="0" id="tabBar" class="tab"><tbody>
<tr>
<td nowrap="nowrap">
<div>
<a title="Home Tab" href="https://na7.salesforce.com/home/home.jsp">Home</a>
</div>
</td>

 

 

The td element of the currently selected tab will have a class added with the values like so:

 

 

<td nowrap="nowrap" class="currentTab primaryPalette">

 

 

So what we need to do is remove the class from the incorrectly highlighted tab and add it to the tab we want highlighted. Here is the jQuery to do this. (My jQuery skills aren't going to win any prizes, someone may have a shorter/better way of achieving this)

 

 

<script type="text/javascript">
j$ = jQuery.noConflict();
	
	j$(document).ready(function($) {
	
		var title = j$('.tab').find('.currentTab > div > a').attr('title');
		
		if (title != 'Search Tab - Selected') {
			j$('.tab').find('.currentTab').removeClass('currentTab primaryPalette');
			
			var x= j$('a[title|=Search Tab]').attr('title', 'Search Tab - Selected');
			
			j$(x).parent().parent().addClass('currentTab primaryPalette');
		}
	});

</script>

 The title of the a link of the seleted tab is always myTabName Tab, if its currently selected is myTabName Tab -Selected. The code basically removes the class from the incorrect tab and adds it to the one we want.

 

The double use of .parent() (please feel free to offer a better technique) navigates from the <a> through the <div> back the current <td>, this is where the class needs to be added. And it works!!! But its a hack

 

 

 

 

 

 

 

 

I just switched from using the IDE on a PC to a MacBook Pro. I downloaded Eclipse and installed the Force.com prespective. All good. But I can't for the life of me figure out how to get my test classes to run. On the PC version a right click on the project - force.com-run tests and hey presto. Nada on the Mac - whats the secret. (BTW also used the IDE on ubuntu -no problem). Come on MacBoys publish the secret

 

Richard

I have a Controller that lets the User pass in a date (date of birth) and I'm trying to use Dynamic SOQL. The problem is that the query string insists in adding the date with 00:00:00 so a DoB or 1971-02-16 gets 00:00:00 appended. This causes the query to fail because the Date of Birth field is a Date only field.

 

I even tried this:

 

 

date d = date.newInstance(dob.year(), dob.month(), dob.day());

 

 

to try and force the removal of the time part before passing it to the query string, but the debug log shows the query passed looks like this:

 

Select id, Name, Date_of_Birth__c,  From myObject__c WHERE  Date_of_Birth__c = 1971-02-16 00:00:00

 

which fails. Pasting the above into the Schema explorer shows a similar failure - remove the 00:00:00 bit and it works fine

 

Help! :smileysad:

 

 

Anyone know if the Spring 10 rollout delay means that the Spring IDE update will be pushed back from Feb 15th?

 

Thanks

David