• Walter@Adicio
  • NEWBIE
  • 210 Points
  • Member since 2008

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 95
    Questions
  • 128
    Replies

Visualforce:

 

<apex:pageBlockSectionItem rendered="{!boolVal}">
<apex:outputLabel value="Test1" />
<apex:inputText value="{!t.value1}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{!NOT(boolVal)}">
<apex:outputLabel value="Test2" />
<apex:inputText value="{!t.value2}"/>
</apex:pageBlockSectionItem>

 

 Apex:

 

public object temp;
public object getT() {
if (temp == null && ApexPages.currentPage().getParameters().get('id') != null)
temp = [SELECT value1, value2 FROM object WHERE Id = :ApexPages.currentPage().getParameters().get('id') LIMIT 1];
if (temp.value2 == 'sampleval')
setBool(true);
else
setBool(false);
return temp;
}

public boolean bool;
public boolean getBoolVal() {
if (bool == null)
bool = True;
if (temp != null && temp.value2 != 'sampleval')
bool = False;
return bool;
}
public void setBoolVal(boolean b) {
bool = b;
}

 

 I am trying to dynamically show/hide the pageBlockSectionItems shown in the vf code above. It seems that the rendering of these pageBlockSectionItems happens before the apex code gets to the getT function. Is there a way to prioritize the order of apex calls or rerender the pageBlockSectionItems if the boolean value changes?

 

 

 

Message Edited by DrawloopSupport on 04-15-2009 04:35 PM

Hi I've written a trigger to send emails off the case object in certain scenarios, but I only want this trigger to fire when the user making updates is an internal user and not a customer portal user. Currently I have an If statement that says when profileid <> the customer portal ids. This is not very maintable, is there a flag that I can use to identify if a user is a customer portal user?

 

Thanks. 

setup a site and a custom object. The site public access guest user profile has full permissions to the custom object.

 

setup a controller and a page to show a record from the custom object. The site guest user also has access to the apex class and the visualforce page.

 

when i load the page as the site guest user i can see any standard fields for the custom object, but it does not show any custom fields for the custom object.

 

no error message just shows nothing.

 

what am i doing wrong?

im trying something like this but i know its not correct.

 

string source = '[ ref:123456789:ref ]';
Pattern mypattern = Pattern.compile('[ ref:.*?:ref ]');
string x = mypattern.matcher( source ).replaceAll('');

 

 

I’m trying to complete an email service to handle an approval process requests. Everything is working fine if I manually put the email service address in the ‘to’ box of my email. I cant figure out why the email service address is not showing up in my ‘to’ box automatically when i click ‘reply’ to the email and the single email message reply-to was set to the email service address.

 

I also tried to setup the email service address as an organizational wide email address so I can just send from the email service address and hopefully force the correct reply-to. However the verification email sent when you setup an Org Wide email is not coming through. I do not understand this either as I have setup an inbound email class for the address to create a task for my user. So I could receive and click on the verification link. No email comes through.

 

From what I read on the boards this is not possible because the "merging" happens when the email is actually sent based on WhatId and TargetObjectId and objects related to those objects.

 

I still need to get this done but before I write something the hard way does anyone have any feedback on what im thinking i need to do?

 

here is what i am thinking i need to do.

 

- when the script initializes i do a field describe on the objects it set up for the whoId and TargetObjectId

- i map the field names to the values returned from the query

- get the body from the email template

- parse through the body to find the merge fields looking for "X" inside the merge values "{!X}".

- replace X with the value from the map , matching by field name

 

doesnt that sound like it will accomplish what i want?

 

please provide feedback.

 

thank you.

 

I am confused please help me understand. Why does the Salesforce Schema in the Eclipse IDE allow you to built a query that may look like this...

 

 

Select c.ParentId, c.CreatedDate, c.CreatedBy.PortalRole, c.CreatedBy.SuperUser, c.CreatedBy.Id, c.CreatedById, c.CommentBody From CaseComment c where (c.CreatedBy.SuperUser = true)

 

And every single field I try for CreatedBy does not work. For example

 

CreatedBy.SuperUser

 

None of them work except CreatedBy.Id.

 

All of them give me this error...

 

"No such column "SuperUser" on entity "Name".

 

I understand CreatedBy is returning a Name, but how come the relationship the schema allows me to build does not work?

 

I know it is just that I am miss understanding. Please help me understand.

 

Thank you.

 

my debug log keeps reaching the max size, and i guess it hits that max before it gets to any of my system.debug() text.

 

this is making it really hard to debug. it looks like my debug log has nothing but validation rules. most likely because our org has a lot of validation rules.

 

any advice?

for example when i upload a file that is 4.89 KB according to windows file properties, my output below gives me 4.74 KB. Its always real close and a little under.

 

 

String s = Document.body.toString();

Decimal byteCount = s.length();

Decimal kb_dec = byteCount / 1000;
Decimal kb_divDec = byteCount.divide(1000, 2, System.RoundingMode.UP);
	   			
double mb = kb_dec / 1000;
Decimal mb_divDec = kb_dec.divide(1000, 2, System.RoundingMode.UP);
	   			
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'The image size is... ' +mb_divDec +' MBs, ' +kb_divDec+' KBs, '+byteCount+' bytes.'));

 

 

Is it something like this?

 

// every 5 minutes
String sch = '0 5 * * * ? ';

 

For example if I want to delete records and not have them bump other records out of the recycle bin. I know we will never need to recover the records I am deleting, and I dont want them to remove record that are in the recycle bin which may need to be recovered.

for example this returns no records but I can see them in the recycle bin.

 

 

select count() from event where isDeleted = true

 

Im getting error ' no such column found ' for ' Id ' for example in a test method when i query the ' GroupMember ' object with runAs a customer portal user.

I assume this means a customer portal user cannot see that object, but how can I confirm that to make sure its not something else I am missing?

 

for example if i have a very large list of records and i want to edit one record in a pop window for example. after editing the record and closing the popup i find i have to reload the entire list again.

 

is there anyway i can just reload the only record i edited so that the page load time is not so long due to loading the entire lista again and again after editing a record?

 

for example i have two pages both using the same controller. one page causes the max view state size error and the other does not.

 

the only difference between the two pages is the one causing the error has a lot of rendered attributes being used to switch between showing an outputfield and an inputfield on that same page.

 

also if anyone can point me to some info i can read about best practices for avoiding hitting the view state size limit that would be great.

for example if i set some values to a record when you enter a visualforce page. can i work on these values if a user just closes the browser or the tab.

 

i have a visualforce page used to edit a record and when a user is editing the record i save some values to the record so no other users can use the visualforce page to edit the same record at the same time.  to " lock " the record for editing. there is a button users have to click to " unlock " the record before they close the page. can i automate the " unlock " button action if they close the browser or the tab?

for example how the row heightlight works for a pageBlockTable. if i am using a dataTable instead and I want the same or a border to appear around the entire row when you mouse over the row. i can put a onmouseover on a element in a column.

I dont know if there is a better way to do what I want but this is what I am doing.

 

I have a page with a dataTable. there is a link for each record to open that record in a "thickbox" popup. so far i can only get the changes made to the record in the "thickbox" to pass back to the original page by making a second page to use the same controller as the first page and i load the second page into an iFrame in the "thickbox" with the information for the record i want to change. when you save it just returns you to the first page. this works fine.

 

What i want to do is after the user clicks save in the "thickbox" i want the opener page to navigate back to the specific record in the dataTable that i edited. a named anchor like behavior.

 

This is how i wrote it and why i am having a problem doing this. also please let me know if this is just a pure javascript issue and if i should post somewhere else. im reading in several places where it looks like i might be able to do this with javascript but i am posting here to make sure there isnt a completely different approach to my apex which can get this done before i start working on the javascript to do it.

 

ive taken out as much as i can to only show the fuctionality, removing styles and other visual details.

 

the datatable and edit link looks like this...

 

<apex:dataTable value="{!editlineItems}" var="item">

<apex:column>
{!item.prod.name}
</apex:column>

<apex:column>
<apex:commandLink target="theiframe2" onclick="openOnload()"						value="Edit" action="{!editProductDescription}">
<apex:param name="pdesc" value="{!item.index}" />						
</apex:commandLink>
</apex:column>

</apex:dataTable>

 

 

the thickbox looks like this...

 

<div id="open-onload" style="display:none;position:absolute;top:0px;left:0px;">
	<div style="border: solid 1px white">
		<div style="border: solid 1px #62aac1">
			<div id="document-ta">
				<apex:iframe src="#" id="theiframe2" height="590px" width="100%" />
			</div>
		</div>
	</div>
</div>

 

 here is how the thickbox is opened...

 

    function openOnload()
    {
      	var document_ta = document.getElementById('document-ta').innerHTML;

        var t = null;
        var a = '#TB_inline?height=600&width=600&inlineId=open-onload&modal=true'; 
        var g = false;
        
        tb_show(t, a, g);
    }  

 

here is how i load the second page into the iFrame in the thickbox...

 

 

public pageReference edit()
{	
// get the sepcific record to work on	
string editname = ApexPages.CurrentPage().getParameters().get('pdesc');	
Integer i = Integer.valueOf(editname);

// make a copy of the index for the record the user is editing
// so i can work on the same record from another method
workingQuoteLineIndex = i;  	

// get the text i want to edit
customProductDescription = editlineItems.get(i).quoteLine.Description__c;

// open the page with the WYSIWYG editor
return Page.page2;
}

 

 

here is how i save the changes in the thickbox and send the user back to the first page...

 

public pageReference saveProductDescription()
{
// update the record to take the value from the editor in the popup
editLineItems.get(workingQuoteLineIndex).quoteLine.Description__c = customProductDescription;

// send the user back to page 1
return Page.page1;

}

 

 *** At this point I want to user go get sent back to the specific record they edited in the dataTable.

 

 

 I know I can do this with javascript but  here is where I am wondering if a different approach via APEX can get this done...

 

 

 If i was sending the user to a new pageReference I could store the anchor value before opening the popup and then use the same anchor when sending them back to the opener window. something like this...

 

 

public pageReference saveProductDescription()
{
pageReference page = new pageReference('/apex/page1#' +storedAnchorValue );
return page;
}

 

If the new pageRerence approach is possible i need help understading how i maintain the " state " of the application when I do not use navigation like this...

 

return page.page1;

 

 what i mean is if the user works in the application and makes a bunch of changes, those changes are lost if i just send them to a new pageReference.

 

should i be working on passing the state of my datatable between the pages in the controller?

 

here is the inner class...

 

// the innerClass for products
public class productWrapper
{
public integer index {get; set;} 
public product2 prod {get; set;}
public boolean selected {get; set;}	
public SFDC_520_QuoteLine__c quoteLine {get; set;}
}

 

my list is of innerClass records....

 

public list<productWrapper> editlineitems {get; set;}
{return editlineitems;}

 

 what i need help understanding is how i pass a named anchor via a new page reference AND maintain the state of the entire application. the application has many objects and values sitting in memory while the user works on it.

 

 

i am trying to move multiple records between two lists. when i use something like this it works only if i move one record at a time. for example if i try to move 5, it only moves 3, and leaves 2 behind.

 

what am i doing wrong?

 

 

if(availableProducts!=null && availableProducts.size() != 0 )
{        
	for(Integer i=0; i< availableProducts.size(); i++)
	{            
		if(availableProducts.get(i).selected==true)            
		{                              
			availableProducts.Remove(i);           
		}        
	}    
}

 

 

 public List<productWrapper> availableProducts {get; set;} {availableProducts = new List<productWrapper>();}

 

 

 

public class productWrapper
{
	public integer index {get; set;} 
	public product2 prod {get; set;}
	public boolean selected {get; set;}	
	public SFDC_520_QuoteLine__c quoteLine {get; set;}
	{ 
		quoteLine = new SFDC_520_QuoteLine__c(Sales_Discount__c = 0.0);
	}
}

 

hello,

 

does anyone know if it is possible to access a 'content delivery' URL after it has been created so I can replace the salesforce domain with a CNAME?

 

we have switched to using a CNAME for most URLs that go out to customers mainly due to the recent salesforce server move for us in NA3 occuring on 9/4.

 

A CNAME makes it easier on us for changes like that but content delivery generated URLs are a different story.

is this OK or is there a better way to go about moving multiple records from one list to another?

 

the goal is for the user to click checkboxes for items in alist and click one 'add' / 'remove' button to move records back and forth.

 

 

	public PageReference massRemoveSelectedItems() 
 	{

    	list<wrap> remove = new list<wrap>();
    	list<wrap> retain = new list<wrap>();
    	
    	
		if(selectedList!=null && selectedList.size() != 0 )
		{
	    	for(wrap w : selectedList)
	    	{
	    		if(w.selected==true){
	    			remove.add(w);
	    		}
	    		
	    		if(w.selected==false)
	    		{
	    			retain.add(w);
	    		}
	    	}
		}
    	
  		if(retain != null && retain.size() != 0 ){
	    	selectedList.clear();
	    	
	    	for(wrap w : retain)
	    	{
	    		selectedList.add(w);
	    	}

  		}
  		
  		if(remove!= null && remove.size() != 0 ){

	    	for(wrap w : remove)
	    	{
	    		availableToSelectList.add(w);
	    	}
 		}
    	
    	return null;
    }

 

 

ive used the describe methods when I know I want information for a case, for example:

 

 

 

		Schema.DescribeSObjectResult caseObj = Case.sObjectType.getDescribe();
		Map<String, Schema.SObjectField> caseObjFields = caseObj.fields.getMap();
		string caseSOQL = 'Select '; 
		for (String fieldName : caseObjFields.keySet()){caseSOQL += fieldName + ',';} 
		caseSOQL = caseSOQL.substring(0,caseSOQL.length()-1);

 

 

what if i want to be able to get to the fields for any object related to a task?

 

for example there are 20 objects related to the task object in our Org and i wouldnt want to write 20 describe methods, besides for that probably goes over the govenor limit for describe calls.

 

 

setup a site and a custom object. The site public access guest user profile has full permissions to the custom object.

 

setup a controller and a page to show a record from the custom object. The site guest user also has access to the apex class and the visualforce page.

 

when i load the page as the site guest user i can see any standard fields for the custom object, but it does not show any custom fields for the custom object.

 

no error message just shows nothing.

 

what am i doing wrong?

my debug log keeps reaching the max size, and i guess it hits that max before it gets to any of my system.debug() text.

 

this is making it really hard to debug. it looks like my debug log has nothing but validation rules. most likely because our org has a lot of validation rules.

 

any advice?

for example when i upload a file that is 4.89 KB according to windows file properties, my output below gives me 4.74 KB. Its always real close and a little under.

 

 

String s = Document.body.toString();

Decimal byteCount = s.length();

Decimal kb_dec = byteCount / 1000;
Decimal kb_divDec = byteCount.divide(1000, 2, System.RoundingMode.UP);
	   			
double mb = kb_dec / 1000;
Decimal mb_divDec = kb_dec.divide(1000, 2, System.RoundingMode.UP);
	   			
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'The image size is... ' +mb_divDec +' MBs, ' +kb_divDec+' KBs, '+byteCount+' bytes.'));

 

 

Can someone please point me in the right direction, I am looking to use the PHP SOAP API to upload a document to store as a Document object within Salesforce.

 

I want the document to be available publicly which I can do with the document type.

 

Any tips and suggestions and pointers appriciated.

 

 

I am trying to write some code to see what cron jobs currently exist in my SF org, but I'm having troubles.

 

Here's what I am trying to do in a trigger I have on a custom object.

 

 

CronTrigger existingCronJob = [SELECT Id, CronExpression FROM CronTrigger WHERE Id = :configObject.Scheduled_Email_Job_Id__c LIMIT 1];
In the Force.com IDE in Eclipse, it gives me an error "Save error: sObject type 'CronTrigger' is not supported."

 

 

 

Look here, do page search for 'CronTrigger'. It explicitly says that  "Q: Is it possible to query the last time a scheduled batch process completed? A: Yes, you can query the CronTrigger table."

http://wiki.developerforce.com/index.php/Tech_Talk:_Whats_New_in_Apex_Code_FAQ

 

So what gives? Any answers out there?

 

Thanks!

-Alex

  • March 10, 2011
  • Like
  • 0

I am working on something where I want to allow an admin to assign items to a Public Group.  Then, at runtime, I need to determine what Public Groups a user is in (directly or via Roles / Roles + Subordinates) and display the appropriate items.  Because Public Groups can be complicated having other Public Groups as Members and also Roles & Subordinates, figuring out the Groups a user is in can be difficult.

 

I started a conversation on Twitter about it and then did some research and have a starting point.  I'd like to encourage others to help me vet this and then it could become a Cookbook item down the line.  Here's what I got...

 

I think this can be done in 2 steps without much looping.  From what I can tell, the Group table can contain all kinds of Groups ("Regular" Public Groups, Roles, Soles & Subordinates, Queues, etc.).  The Group Member table seems to only contain pointers to Users or to Other Groups.  Groups that are copies of Roles and Roles & Subordinates have a Related Id filled in.  

 

I believe the following 2 queries could determine the Public Groups that a User is actually in...

 

1) Query the Group table to get the Group records where the Related Id = the users's role.  We could filter for Type of Role or RoleAndSubordinates, but it seems that anything with a RelatedId filled in is one of those types.  This query is essentially getting the Group records that mirror our Role record.

 

 

List<String> roleRelatedGroupIds = new List<String>();
for (Group g : [SELECT id, RelatedId, Type FROM Group where RelatedId= :UserInfo.getUserRoleId()]{
   roleRelatedGroupIds.add(g.id);
}

 

2) Next we query the Group Member table for records where our user is specifically assigned and  also include records where our role is assigned.

 

List<String> allGroupIDs = new List<String>();
for (GroupMember gm : [SELECT Id, group.id, group.name, group.type FROM GroupMember where (UserOrGroupId = :UserInfo.getUserId() AND group.type='Regular') OR (UserOrGroupId IN :roleRelatedGroupIds AND group.type='Regular')]{
allGroupIDs.add(gm.group.id);
}

 

 

I'd need to hack at this given lots of users and lots of Group Types like Queues, Territories, Roles, Public Groups, etc.  From what I've been able to test, this works.

  • March 09, 2011
  • Like
  • 0

Hi there,

I'm publishing Custom Object to public site. Site can display standard field like 'name'. However, it does not display anything when it comes to custom fields.

 

As a first step I checked profile "Standard Guest". And here comes the mystery: I can not see this profile in profile list in salesforce.com, it could be accessible only from IDE. Next, I can not change any of Custom Object Permissions (can not mark anything checked there) . I was able to set Custom Field-Level Security properly though.

 

Is there anything I'm doing wrong?

 

How's your experience? What steps have you had to take to get Custom fields from your custom objects visible for Guests?

Is it something like this?

 

// every 5 minutes
String sch = '0 5 * * * ? ';

 

Hi,

I need to be able to receive a pdf form in xfdf format (xml) inside my force.com application.

Currently I am able to post (HTTP POST) the data to the server.

But does anyone know how can I access the body of the request from an apex class (be it a controller or otherwise) and parse it?

I cannot name the data to imitate the posing of a form...

Thanks in advance

  • January 20, 2011
  • Like
  • 0

 

for example i have two pages both using the same controller. one page causes the max view state size error and the other does not.

 

the only difference between the two pages is the one causing the error has a lot of rendered attributes being used to switch between showing an outputfield and an inputfield on that same page.

 

also if anyone can point me to some info i can read about best practices for avoiding hitting the view state size limit that would be great.

for example if i set some values to a record when you enter a visualforce page. can i work on these values if a user just closes the browser or the tab.

 

i have a visualforce page used to edit a record and when a user is editing the record i save some values to the record so no other users can use the visualforce page to edit the same record at the same time.  to " lock " the record for editing. there is a button users have to click to " unlock " the record before they close the page. can i automate the " unlock " button action if they close the browser or the tab?

 

i am trying to move multiple records between two lists. when i use something like this it works only if i move one record at a time. for example if i try to move 5, it only moves 3, and leaves 2 behind.

 

what am i doing wrong?

 

 

if(availableProducts!=null && availableProducts.size() != 0 )
{        
	for(Integer i=0; i< availableProducts.size(); i++)
	{            
		if(availableProducts.get(i).selected==true)            
		{                              
			availableProducts.Remove(i);           
		}        
	}    
}

 

 

 public List<productWrapper> availableProducts {get; set;} {availableProducts = new List<productWrapper>();}

 

 

 

public class productWrapper
{
	public integer index {get; set;} 
	public product2 prod {get; set;}
	public boolean selected {get; set;}	
	public SFDC_520_QuoteLine__c quoteLine {get; set;}
	{ 
		quoteLine = new SFDC_520_QuoteLine__c(Sales_Discount__c = 0.0);
	}
}

 

is this OK or is there a better way to go about moving multiple records from one list to another?

 

the goal is for the user to click checkboxes for items in alist and click one 'add' / 'remove' button to move records back and forth.

 

 

	public PageReference massRemoveSelectedItems() 
 	{

    	list<wrap> remove = new list<wrap>();
    	list<wrap> retain = new list<wrap>();
    	
    	
		if(selectedList!=null && selectedList.size() != 0 )
		{
	    	for(wrap w : selectedList)
	    	{
	    		if(w.selected==true){
	    			remove.add(w);
	    		}
	    		
	    		if(w.selected==false)
	    		{
	    			retain.add(w);
	    		}
	    	}
		}
    	
  		if(retain != null && retain.size() != 0 ){
	    	selectedList.clear();
	    	
	    	for(wrap w : retain)
	    	{
	    		selectedList.add(w);
	    	}

  		}
  		
  		if(remove!= null && remove.size() != 0 ){

	    	for(wrap w : remove)
	    	{
	    		availableToSelectList.add(w);
	    	}
 		}
    	
    	return null;
    }

 

 

here is what my problem is and maybe you can set me straight on what i should be writting instead of what i am trying to write. i ran into the "script too large" error. so i am trying to figure out how to break apart the script into different classes.

 

one script has some logic to run a update / insert command. what i am trying to do is run that same logic but before commiting to the database just present a type of "Are you sure?" option with a "yes", and only when they click "yes" will it actually commit to the database.

 

i know you can probably get this all in one script but please help me understand my choices for getting different scripts to work with the same variables.... because the script really has a lot going on and even if i re-write the whole thing to be more efficient. i am still going to run into "script too large" error eventually until i know how to get more than one class to talk to each other. im sure there is a better what to go about this.

 

 

here is an example:

 

in one script different variables are created. for example a task.

 

	public Task task;
	public Task getTask(){
		if(task==null) task = new Task();
		return task;
	}

 

so the user would fill out the subject line of that task .

 

in another script id like it to be able to see the same variable and subject value from the first script. so another script could do something like this.

 

 

if(task!=null && task.subject!=null && task.subject.length()>0){
     // some stuff
}

 

 

 

 

Has anyone figured out a creative way to manage single email methods given the 10 message governor limit?  For example, If I have an email method set-up to send out a message upon an opportunity closing, then we can't update more than 10 opportunities at a time (single trigger execution) without hitting this limit.

 

Can't use built-in workflow/email alerts because the data for the email message is coming from more than 1 object and we need to have control over the to:, cc: fields.

 

Looking for any creative ideas here.