• rhsumner
  • NEWBIE
  • 25 Points
  • Member since 2009

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

I want to allow users to click on the account name (or have a link in a fourth column that says 'View this Account') and be directed to the record.

 

Have searched and it's probably right in front of me, but I can't figure it out. 

 

Source of vf page template: http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_methods.htm

 

<apex:page controller="SearchBeforeAddingController">
<apex:form >
<apex:pageBlock mode="edit" id="block">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Search for:</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Go!" action="{!doSearch}"
rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="searching existing accounts... please wait..."/>
<apex:pageBlockSection title="These Accounts Potentially Match:" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="a"
rendered="{!NOT(ISNULL(results))}">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.site}"/>
<apex:column value="{!a.AKA__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>


 

Hi,

 

Is there anyway to ensure my SOQL query results are accent insensitive, that is, when I run the query:

 

 

[SELECT Id, FirstName, LastName FROM Contact
where firstname like 'jorg']

 

I would like the results to include both contacts whose first name is 'Jorg' or 'Jörg'.

 

Hi,

 

I have a component which sits on a visualforce page, everytime this component is rendered I would like to do a check and insert some data. Initially I tried to put this code in the component controllers' constructor obviously this failed because no DML operations are allowed at this point.

 

Instead I now call the method from one of the components get properties. This appears to work and the debug logs show it as working, unfortunatly the data is not there. If I execute the same code anonamously from Eclipse it works perfectly.

 

Here is the log of the particular method in question:

 

17:6:34.930|METHOD_ENTRY|[16,6]|01pS00000005AJs|FieldAuditController.CreateSnapShot()
17:6:34.930|METHOD_ENTRY|[31,6]|01pS00000005AJs|FieldAuditController.MustCreateSnapshot()
17:6:34.930|METHOD_ENTRY|[46,192]|LIST<FieldAuditSnapshot__c>.size()
17:6:34.930|SOQL_EXECUTE_BEGIN|[46,15]|Aggregations:0|SELECT Id FROM FieldAuditSnapshot__c WHERE User__c=:Userinfo.getUserId() AND Month__c=:DateTime.Now().month() AND Year__c=:DateTime.Now().Year() AND ObjectType__c=:objectType
17:6:34.930|METHOD_ENTRY|[46,68]|Userinfo.getUserId()
17:6:34.930|METHOD_EXIT|[46,68]|Userinfo.getUserId()
17:6:34.930|METHOD_ENTRY|[46,118]|Datetime.month()
17:6:34.930|METHOD_ENTRY|[46,103]|DateTime.Now()
17:6:34.930|METHOD_EXIT|[46,103]|DateTime.Now()
17:6:34.930|METHOD_EXIT|[46,118]|Datetime.month()
17:6:34.930|METHOD_ENTRY|[46,154]|Datetime.Year()
17:6:34.930|METHOD_ENTRY|[46,139]|DateTime.Now()
17:6:34.930|METHOD_EXIT|[46,139]|DateTime.Now()
17:6:34.931|METHOD_EXIT|[46,154]|Datetime.Year()
17:6:34.937|SOQL_EXECUTE_END|[46,15]|Rows:0
17:6:34.937|METHOD_EXIT|[46,192]|LIST<FieldAuditSnapshot__c>.size()
17:6:34.937|METHOD_EXIT|[31,6]|FieldAuditController.MustCreateSnapshot()
17:6:34.938|METHOD_ENTRY|[36,18]|Userinfo.getUserId()
17:6:34.938|METHOD_EXIT|[36,18]|Userinfo.getUserId()
17:6:34.938|METHOD_ENTRY|[37,33]|Datetime.year()
17:6:34.938|METHOD_ENTRY|[37,18]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[37,18]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[37,33]|Datetime.year()
17:6:34.938|METHOD_ENTRY|[38,34]|Datetime.month()
17:6:34.938|METHOD_ENTRY|[38,19]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[38,19]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[38,34]|Datetime.month()
17:6:34.938|METHOD_ENTRY|[39,5]|Database.insert(SOBJECT:FieldAuditSnapshot__c)
17:6:34.938|DML_BEGIN|[39,5]|Op:Insert|Type:FieldAuditSnapshot__c|Rows:1
17:6:34.979|DML_END|[39,5]
17:6:34.979|METHOD_EXIT|[39,5]|Database.insert(SOBJECT:FieldAuditSnapshot__c)
17:6:34.979|METHOD_EXIT|[16,6]|FieldAuditController.CreateSnapShot()

 

 

Here is the controller:

 

public without sharing class FieldAuditController {
	public string objectType{get;set;}
	public string title{get;set;}
	public FieldAuditController(){	}
	//for this prototype we'll just use the candidate object with a small set of fields
	public integer AuditPercent{
		get{					
			if(AuditPercent == null){
				//these queries would be where we filter by date
				string q = 'SELECT AVG(Completedness__c) FROM '+objectType+' WHERE OwnerId=\''+Userinfo.getUserId()+'\'';
				AggregateResult result = Database.query(q);
				AuditPercent = double.valueOf(result.get('expr0')).intValue();
			 	CreateSnapShot();
			} 
			return AuditPercent;			
		}
		set;
	}
	// the incomplete percentage
	public integer AuditIncompletePercent{
		get{
			return 100 - AuditPercent;
		}set;
	}

	public void CreateSnapShot(){
		//check if its neccessary to create snapshot
		if(MustCreateSnapshot()){

				FieldAuditSnapshot__c ss = new FieldAuditSnapshot__c();
				ss.Complete__c = AuditPercent;
				ss.ObjectType__c = objectType;
				ss.User__c = Userinfo.getUserId();
				ss.Year__c = DateTime.Now().year();
				ss.Month__c = DateTime.Now().month();
				Database.insert(ss);

		}
	}
	private boolean MustCreateSnapshot(){
		//Query the FieldAuditSnapshot__c record to see if a snapshot has been created for this user on candidate for this month and year
		integer c = [SELECT Id FROM FieldAuditSnapshot__c WHERE User__c=:Userinfo.getUserId() AND Month__c=:DateTime.Now().month() AND Year__c=:DateTime.Now().Year() AND ObjectType__c=:objectType].size();
		if(c==0){
			return true;
		}
		return false;
	}
}

 

 

 

And here is the component:

 

<apex:component controller="FieldAuditController" allowDML="true">
<apex:attribute assignTo="{!objectType}" name="objectType" required="true" type="string" description="object type"/>
<apex:attribute assignTo="{!title}" name="title" required="true" type="string" description="title"/>

<div class="sidebox">
<div class="title-left"><div class="title-right"><div class="title-center">
<span>Field Audit</span>
<img class="widgetImage" src="{!URLFOR($Resource.goldicons,'lead_gold.png')}" />
</div></div></div>
<div class="content">
<!-- Attempt using google apis chart library, bind the data values inside the url -->
<img src="http://chart.apis.google.com/chart?chs=200x120&cht=p&chd=t:{!AuditPercent},{!AuditIncompletePercent}&chdl=Completed+data|Data+left+blank&chma=0,0,30&chtt={!title}" />
Your {!title} data is {!AuditPercent}% complete.
</div>
</div>
</apex:component>

 

 

 

 

Hi,

 

I have a visualforce page for a custom object with an input field for the contact lookup. When the lookup dialog window is opened, the user can now search for a contact or create a new one, which navigates them to the quick create form for contact. 

 

I would like to know, how I can go about adding fields to this form?

 

Secondly, and less importantly, does anyone know how to stop salesforce closing the browser dialog windows (for example the lookup dialog) when they loose focus?

 

Thanks.

 

Ryan. 

Hi,

 

Some of my custom object layout pages double-click inline editing functionality has stopped working. It has also stopped working on Contacts but not Accounts.

 

No doubt this is caused by something I have done, is anyone aware of what could cause this feature to break?

 

Thanks.

Hello, I hope someone can help me, I have the following function:

 

public static void CreateNote(Id parentId, string subject, string msg){ Note n = new Note(); n.Body = msg; n.ParentId = parentId; n.Title = subject; insert n; }

 

 Now, I need to update the parent records last modified timestamp, but in order to query the parent I need to determine the parents sObjectType from the parentId.

 

I have no idea how to do this.

 

 

Hi,

 

Is there anyway to ensure my SOQL query results are accent insensitive, that is, when I run the query:

 

 

[SELECT Id, FirstName, LastName FROM Contact
where firstname like 'jorg']

 

I would like the results to include both contacts whose first name is 'Jorg' or 'Jörg'.

 

Hi,

 

I have a component which sits on a visualforce page, everytime this component is rendered I would like to do a check and insert some data. Initially I tried to put this code in the component controllers' constructor obviously this failed because no DML operations are allowed at this point.

 

Instead I now call the method from one of the components get properties. This appears to work and the debug logs show it as working, unfortunatly the data is not there. If I execute the same code anonamously from Eclipse it works perfectly.

 

Here is the log of the particular method in question:

 

17:6:34.930|METHOD_ENTRY|[16,6]|01pS00000005AJs|FieldAuditController.CreateSnapShot()
17:6:34.930|METHOD_ENTRY|[31,6]|01pS00000005AJs|FieldAuditController.MustCreateSnapshot()
17:6:34.930|METHOD_ENTRY|[46,192]|LIST<FieldAuditSnapshot__c>.size()
17:6:34.930|SOQL_EXECUTE_BEGIN|[46,15]|Aggregations:0|SELECT Id FROM FieldAuditSnapshot__c WHERE User__c=:Userinfo.getUserId() AND Month__c=:DateTime.Now().month() AND Year__c=:DateTime.Now().Year() AND ObjectType__c=:objectType
17:6:34.930|METHOD_ENTRY|[46,68]|Userinfo.getUserId()
17:6:34.930|METHOD_EXIT|[46,68]|Userinfo.getUserId()
17:6:34.930|METHOD_ENTRY|[46,118]|Datetime.month()
17:6:34.930|METHOD_ENTRY|[46,103]|DateTime.Now()
17:6:34.930|METHOD_EXIT|[46,103]|DateTime.Now()
17:6:34.930|METHOD_EXIT|[46,118]|Datetime.month()
17:6:34.930|METHOD_ENTRY|[46,154]|Datetime.Year()
17:6:34.930|METHOD_ENTRY|[46,139]|DateTime.Now()
17:6:34.930|METHOD_EXIT|[46,139]|DateTime.Now()
17:6:34.931|METHOD_EXIT|[46,154]|Datetime.Year()
17:6:34.937|SOQL_EXECUTE_END|[46,15]|Rows:0
17:6:34.937|METHOD_EXIT|[46,192]|LIST<FieldAuditSnapshot__c>.size()
17:6:34.937|METHOD_EXIT|[31,6]|FieldAuditController.MustCreateSnapshot()
17:6:34.938|METHOD_ENTRY|[36,18]|Userinfo.getUserId()
17:6:34.938|METHOD_EXIT|[36,18]|Userinfo.getUserId()
17:6:34.938|METHOD_ENTRY|[37,33]|Datetime.year()
17:6:34.938|METHOD_ENTRY|[37,18]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[37,18]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[37,33]|Datetime.year()
17:6:34.938|METHOD_ENTRY|[38,34]|Datetime.month()
17:6:34.938|METHOD_ENTRY|[38,19]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[38,19]|DateTime.Now()
17:6:34.938|METHOD_EXIT|[38,34]|Datetime.month()
17:6:34.938|METHOD_ENTRY|[39,5]|Database.insert(SOBJECT:FieldAuditSnapshot__c)
17:6:34.938|DML_BEGIN|[39,5]|Op:Insert|Type:FieldAuditSnapshot__c|Rows:1
17:6:34.979|DML_END|[39,5]
17:6:34.979|METHOD_EXIT|[39,5]|Database.insert(SOBJECT:FieldAuditSnapshot__c)
17:6:34.979|METHOD_EXIT|[16,6]|FieldAuditController.CreateSnapShot()

 

 

Here is the controller:

 

public without sharing class FieldAuditController {
	public string objectType{get;set;}
	public string title{get;set;}
	public FieldAuditController(){	}
	//for this prototype we'll just use the candidate object with a small set of fields
	public integer AuditPercent{
		get{					
			if(AuditPercent == null){
				//these queries would be where we filter by date
				string q = 'SELECT AVG(Completedness__c) FROM '+objectType+' WHERE OwnerId=\''+Userinfo.getUserId()+'\'';
				AggregateResult result = Database.query(q);
				AuditPercent = double.valueOf(result.get('expr0')).intValue();
			 	CreateSnapShot();
			} 
			return AuditPercent;			
		}
		set;
	}
	// the incomplete percentage
	public integer AuditIncompletePercent{
		get{
			return 100 - AuditPercent;
		}set;
	}

	public void CreateSnapShot(){
		//check if its neccessary to create snapshot
		if(MustCreateSnapshot()){

				FieldAuditSnapshot__c ss = new FieldAuditSnapshot__c();
				ss.Complete__c = AuditPercent;
				ss.ObjectType__c = objectType;
				ss.User__c = Userinfo.getUserId();
				ss.Year__c = DateTime.Now().year();
				ss.Month__c = DateTime.Now().month();
				Database.insert(ss);

		}
	}
	private boolean MustCreateSnapshot(){
		//Query the FieldAuditSnapshot__c record to see if a snapshot has been created for this user on candidate for this month and year
		integer c = [SELECT Id FROM FieldAuditSnapshot__c WHERE User__c=:Userinfo.getUserId() AND Month__c=:DateTime.Now().month() AND Year__c=:DateTime.Now().Year() AND ObjectType__c=:objectType].size();
		if(c==0){
			return true;
		}
		return false;
	}
}

 

 

 

And here is the component:

 

<apex:component controller="FieldAuditController" allowDML="true">
<apex:attribute assignTo="{!objectType}" name="objectType" required="true" type="string" description="object type"/>
<apex:attribute assignTo="{!title}" name="title" required="true" type="string" description="title"/>

<div class="sidebox">
<div class="title-left"><div class="title-right"><div class="title-center">
<span>Field Audit</span>
<img class="widgetImage" src="{!URLFOR($Resource.goldicons,'lead_gold.png')}" />
</div></div></div>
<div class="content">
<!-- Attempt using google apis chart library, bind the data values inside the url -->
<img src="http://chart.apis.google.com/chart?chs=200x120&cht=p&chd=t:{!AuditPercent},{!AuditIncompletePercent}&chdl=Completed+data|Data+left+blank&chma=0,0,30&chtt={!title}" />
Your {!title} data is {!AuditPercent}% complete.
</div>
</div>
</apex:component>

 

 

 

 

Hi,

 

I have a visualforce page for a custom object with an input field for the contact lookup. When the lookup dialog window is opened, the user can now search for a contact or create a new one, which navigates them to the quick create form for contact. 

 

I would like to know, how I can go about adding fields to this form?

 

Secondly, and less importantly, does anyone know how to stop salesforce closing the browser dialog windows (for example the lookup dialog) when they loose focus?

 

Thanks.

 

Ryan. 

I used to create Work Order object using a Custom Button (create work order) in Service Order page. This used to call one S-Control which had sforce.connection.create([workorder]);

 

How can I do similar thing in visualforce, it seems I can't execute any DML like that.

 

Any suggestion would be appreciated.

 

Thanks

Bhaskar

I want to allow users to click on the account name (or have a link in a fourth column that says 'View this Account') and be directed to the record.

 

Have searched and it's probably right in front of me, but I can't figure it out. 

 

Source of vf page template: http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_methods.htm

 

<apex:page controller="SearchBeforeAddingController">
<apex:form >
<apex:pageBlock mode="edit" id="block">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Search for:</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Go!" action="{!doSearch}"
rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="searching existing accounts... please wait..."/>
<apex:pageBlockSection title="These Accounts Potentially Match:" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="a"
rendered="{!NOT(ISNULL(results))}">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.site}"/>
<apex:column value="{!a.AKA__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>


 

I've set the attribute to required="true" and as far as I can tell it has not effect at all.

 

I added an onsubmit javascript function:

 

function validateForm() { var fileVal = document.getElementById("{!$Component.UploadForm.firstBlock.requiredElements.fileNameSection.theFile}").value; if ("" == fileVal) { alert("The File Name field is required."); return false; } var accessVal = document.getElementById("{!$Component.UploadForm.firstBlock.requiredElements.fileAccessSection.theAccess}").value; if ("" == accessVal) { alert("The File Access field is required."); return false; } var folderVal = document.getElementById("{!$Component.UploadForm.firstBlock.requiredElements.fileFolderSection.theFolder}").value; if ("" == folderVal) { alert("The Folder field is required."); return false; } }

 

 

and added this call:

 

 

 <apex:form id="UploadForm" onSubmit="return validateForm()"> 

 

I've tested the javascript function against inputText, inputTextarea, and selectList and it works just fine. I have verified that I am accessing the inputFile field using the same pattern as all other fields and have even compared the actual View Source on the form against the $Component call.

 

How can I make my inputFile field absolute required? I don't want the user to be able to submit the form without specifying a file to upload.

 

TIA,

 

John

 

 

 

 

 

  • June 16, 2009
  • Like
  • 0