• calvin_nr
  • NEWBIE
  • 130 Points
  • Member since 2012

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 36
    Questions
  • 107
    Replies

 

Hello,

Please help me to write test case for the below class.

 

 

public with sharing class ABC{

Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
public string errormsg{get;set;}
public ApexPages.StandardSetController setCon {
get{ if(setCon == null){
String status='';
String contid='';
try {
status = ApexPages.currentPage().getParameters().get('status');
status = status.trim();
contid=ApexPages.currentPage().getParameters().get('Id');
contid = contid.trim();
} catch (System.StringException e) {
System.debug('Error in param Processing: ' + e);
}
size = 10;
string queryString = string queryString = 'SELECT Id, Name FROM Sample__c Order by Name WHERE InquiryContent__c = \''+contid+ '\' AND Status__c = \''+status +'\' Order by Name';
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size);
noOfRecords = setCon.getResultSize();
if(noOfRecords ==0) {
errormsg='No records to display';
} else {
errormsg='';
}
}
return setCon;
}set;
}
Public List<Sample__c> sampleList(){
List<Sample__c> inqList = new List<Sample__c>();
for(Sample__c a : (List<Sample__c>)setCon.getRecords())
inqList.add(a);
return inqList;
}
public pageReference refresh() {
setCon = null;
sampleList();
setCon.setPageNumber(1);
return null;
}
public Integer getpage{
get{ integer i;
if(math.mod(noOfRecords,size)==0) {
i=noOfRecords/size;
}else {
i=noOfRecords/size+1;
}
return i;
}
set;}
}

Hey guys,

 

I thought that the primary selling point of Force.com sites is creating public web pages where you can display data to users without requiring a login where our VF pages could be accessed by the Site guest user provided we gave the right object access to the guest user profile.

 

We want to display a custom object and its chatter feed and we need it to be read only. I thought this will be possible but it turns out that the Guest user does not have access to the Chatter APIs.

 

Has anybody else run into this problem? We are hoping to avoid having to ask the users to login.

Any thoughts on this problem would be much appreciated.

 

Thanks.

Hi,

 

As you may know Salesforce released a new product recently which is based on Chatter. The out of the box product looks great but I have seen some demos where the uers have made advance customizations on the community pages. They have also changed the main chatter pages and added some sections to it.

 

How do we customize existing pages on a community. I have experience building new pages from scratch. Does anybody have any experience customizing communities using HTML/CSS?

 

Another question is we would need to use a force.com site to host the custom pages. How do we use chatter tags in Visualforce since the documentation says most chatter tags do not work with VF pages which are part of a force.com site?

 

Thanks!

I am trying to display a link on a custom VF page to a word document which has been uploaded to a folder in the Documents tab.

 

For some reason this is not working as expected. The link is not pointing to the document. Security is also not an issue. I am not doing something right in the VF I suppose.

 

Here is my controller code:

 

public with sharing class osv_portal_HomePageContoller {
public string strDocUrl;
public osv_portal_HomePageContoller()

{

    try
    {
        List<Document> lstDocument = [Select Name from Document where Name = 'SLA-Technology' limit 1];
        string strOrgId = UserInfo.getOrganizationId();
        strDocUrl = '/servlet/servlet.FileDownload?file='+lstDocument[0].Id;

    }
    catch (Exception e) 
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error in getDocumentLogoUrl() ' + e.getMessage()));
        System.debug('Error: ' + e.getMessage());
    }
        System.debug('The URL is ' + strDocUrl);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'The URL returned is ' + strDocUrl));   

    }

 This is my VF code:

<apex:outputLink value="{!strDocUrl}" id="theLink" styleclass="slabutton">
    <span class="delete">Service Level Agreement</span>
 </apex:outputLink>

Thanks,
Calvin

Guys,

 

I made a ton of changes to a VF page using Salesforce in my broswer. The same file was also part of a project in my IDE. Somehow while saving another file from the IDE, my VF page in the server got ovrwritten by an older copy from the IDE. I lost a lot of important work.

 

Since there was no local copy of the changes I had made, I cannot restore the file from the local filesystem.

 

Does Salesforce offer any other means using which I can restore my VF file.

 

Thanks,
Calvin

I am developing a site in Visualforce and would like to offer user a simple form to send me feedback via email. There would be 3-4 fields like name, user's email, reason and feedback and "send" button. Clicking the send button should automatically send that message to my email address.

I do not want to store the form data in salesforce at least for now...All the stuff I found online about visualforce/apex and email is about saving that data to salesforce too.

Can I just make use of apex's email capabilities and send out email without storing that data anywhere in salesforce?

Thanks,

Calvin

Hi folks,

 

I have not been able to get any reliable information about this issue online. But I think it must be an issue which must be affecting a lot of people.

 

Basically I wrote a simple trigger and test class in sandbox, tested it and when it was fine I deployed it to PRD.

I tried the validation mode first and I got this error.

 

System.LimitException: Too many SOQL queries: 101

 

This error was shown to occur in some other test class. So I feel that the test cases in my trigger ran and this coupled with the remaining test cases somehow overshot the limit.

 

So the total number of SOQL queries in our unit tests must be less than 100. This is a little hard to adere to right? I can imagine with so many test cases, surely we will need more than 100 queries.

 

So what are the ways to avoid hitting this limit because Salesforce runs all the test cases when deploying even a single line of code.

 

I dont not have any of the usual suspects...like SOQL within a for loop.

 

Can you please share your thoughts?

 

Thanks,

Calvin

 

 

 

 

hey guys,

 

I have a customized visualforce page. I need to display some documents. I dont want to upload them as static resources but rather in a folder where I can control which groups/roles can see that folder.

 

How can I link to or display any documents which are uploaded to this folder?

 

Thanks,
Calvin

Hey guys, I need to validate a date field which is being entered by a user via a visualforce page.

 

The format my code expects is "yyyy-MM-dd".

 

What is the best way to handle this in apex?

I have done similar stuff in Java before using certain standard classes which are not available in Apex like SimpleDateFormat for example.

 

Now I can check if the "format" is correct using a regular expression. But I must also prevent users from entering "9999-99-99" which satisfies the format.

 

I am hoping Salesforce has a good built-in solution.

 

Thanks, Calvin

Hi folks,

 

My code for updating records of a custom object is not working as expected. 

 

I thought we would just need to create an object of the same type and assign the id of the record we needed to update and then make our changes. Am I wrong?

 

          Invoice__c invoiceToUpdate = new Invoice__c();
                    invoiceToUpdate.Id = invoice.Id.ToString();
                    invoiceToUpdate.Open_Amount__c = Convert.ToDouble(tempTable.Rows[0]["InvoiceOpenAmt"]);
                    invoiceToUpdate.Open_Amount__cSpecified = true;

                    //Update this invoice in Salesforce
                    SaveResult[] results2 = binding.create(new sObject[] {
                              invoiceToUpdate });

                    if (results2[0].success) 
                    {
                        Console.WriteLine("An Invoice record with Id: {0} was updated.",
                                 results2[0].id);

                    } 
                    else 
                    {
                        Console.WriteLine("FAILURE to update Invoice record with Id: {0}",
                                   results2[0].id);
                    }

 

Thanks,
Calvin 

 



Hi folks, I implemented pagination on my visual force page looking at these two resources.

http://hisrinu.wordpress.com/2012/01/09/pagination-using-standardsetcontroller/

http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/

 

The next(), previous() etc methods do not work unless I make a call to the method which fetches records from the controller.

 

For example:

    // returns the first page of records
    public void first() { 
        //con = null;    
        try{
        con.first();  
              
        moneyTransactions = getMoneyTransactions();
        }
        catch (Exception e) 
            {
               ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Code Error '+e));
            }
        
    }

 

 

Also the next, previous etc links start freezing up after I click on them continuously for some time. Has anybody encountered these problems before since these methods are pretty standard wrt to the standard set controller.

 

What am I doing wrong?

 

Thanks, Calvin

Guys, 

 

This is a VS page where I display SF data using an Apex:Datatable. I have customized the table using CSS. The table is rendered badly in Firefox v13 where the cells have been spread wide out and the table contents are overflowing. While it is fine in IR and Chrome.

 

Another problem is the top border appears in IE and does not appear in Chrome and Firefox. 

The top border issue I can live with but do you have any idea why Firefox would display the page like this? any known issues. 

 

Screenshots(sensitive data has been blackened) and code snippets below:

 

IE

IE

Firefox: The cells have been stretched out :(

Firefox

 

Datatable code:

<apex:outputPanel styleClass="tableContainerClass" id="tableContainer">  
       
    <apex:dataTable value="{!moneyTransactions}" var="mt" id="dataTable" rowClasses="oddRow,evenRow" styleClass="tableClass" cellpadding="5" cellspacing="45" headerClass="dataHeaderRow" captionClass="pagetitle" columnsWidth="15%,10%,20%,5%,20%,15%,15%" rules="none">   
     <apex:facet name="caption">FUNDING REPORT </apex:facet>
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Transaction Type" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="ACH_Type__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                
               <apex:outputText value="Direct Deposit" rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR DDP Collection',true,false)}"/> 
               <apex:outputText value="Checks" rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR Check Collection',true,false)}"/> 
               <apex:outputText value="Direct Deposit" rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR DDP Disbursement and Collection',true,false)}"/> 
               <apex:outputText value="Taxes" rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR Tax Collection',true,false)}"/>
               <apex:outputText value="Garnishment" rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR Garnishment Collection',true,false)}"/>
               <apex:outputText value=" "/> 
               <apex:outputPanel styleClass="iconPanel">
               <apex:image rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR DDP Collection',true,false)}" value="{!$Resource.DepositImg}" width="30" height="20" styleClass="iconClass"/>
               <apex:image rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR Check Collection',true,false)}" value="{!$Resource.CheckImage}" width="30" height="20" styleClass="iconClass"/>
               <apex:image rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR Tax Collection',true,false)}" value="{!$Resource.TaxImage}" width="30" height="20" styleClass="iconClass"/>
               <apex:image rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR Garnishment Collection',true,false)}" value="{!$Resource.GarnishmentImage}" width="30" height="20" styleClass="iconClass"/>
               <apex:image rendered="{!IF(mt.moneyTransactions.ACH_Type__c ='VHR DDP Disbursement and Collection',true,false)}" value="{!$Resource.DepositImg}" width="30" height="20" styleClass="iconClass"/>
               </apex:outputPanel>
       
        
           
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Settlement Date" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="Settlement_Date_First__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>   
                <apex:outputField value="{!mt.moneyTransactions.Settlement_Date_First__c}"/>              
            </apex:column>
 
           
          <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Details" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="Settlement__r.id" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet> 
                <apex:outputLink onclick="window.open('/apex/SettlementDetails?id={!mt.moneyTransactions.Settlement__c}');" rendered="{!IF((mt.moneyTransactions.ACH_Type__c ='VHR DDP Disbursement and Collection' || mt.moneyTransactions.ACH_Type__c ='VHR Check Collection' || mt.moneyTransactions.ACH_Type__c ='VHR DDP Collection')&& mt.moneyTransactions.Settlement__c != null,true,false)}">    
                  {!mt.moneyTransactions.Settlement__r.name}
                </apex:outputLink>
               <apex:outputLink onclick="window.open('/apex/TaxDetails?id={!mt.moneyTransactions.Tax_Batch__c}');" rendered="{!IF((mt.moneyTransactions.ACH_Type__c ='VHR Tax Collection') && mt.moneyTransactions.Tax_Batch__c != null,true,false)}">    
                    Tax Batch  
               </apex:outputLink>  
               <apex:outputLink onclick="window.open('/apex/GarnishmentDetails?id={!mt.moneyTransactions.Payroll_Group_Detail__c}');" rendered="{!IF((mt.moneyTransactions.ACH_Type__c ='VHR Garnishment Collection'),true,false)}">    
                    Payroll Group Detail
               </apex:outputLink>  
                            
            </apex:column>   
    
                <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Movement Type" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="Money_Movement_Type__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet> 
                <apex:outputField value="{!mt.moneyTransactions.Money_Movement_Type__c}"/>           
            </apex:column>
            
             <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Bank Name" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="Bank_Name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet> 
                <apex:outputField value="{!mt.moneyTransactions.Bank_Name__c}"/>           
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Account Number" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="Bank_Account_Number__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet> 
                <apex:outputText value="{!mt.moneyTransactions.Bank_Account_Number__c}"/>           
            </apex:column>
            
             <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Total Amount" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="Total_ACH_Amount__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>  
                <apex:outputField value="{!mt.moneyTransactions.Total_ACH_Amount__c}"/>                     
            </apex:column>
 

            
            
        </apex:datatable>  
        </apex:outputPanel> 

 CSS relevant to this:

 

.tableClass {width:80%;border-collapse:collapse;border-spacing:1pt;position:relative;}
.tableContainerClass{width:80%;position:relative;}
.oddRow{border-bottom:1px solid #fec00d;border-top:1px solid transparent;padding:8px;background:#F2F2F2;color:#339;}
.evenRow{background:#fff;border-bottom:1px solid #fec00d;color:#669;border-top:1px solid transparent;padding:8px;}
.commandStyle{color: #0079C1}
a:hover{color:black;}
[id*=criteria] {color: font-size: 11px;}
.dataHeaderRow{font-size:13px;font-weight:normal;background:#fff;border-bottom:4px solid #fec00d;border-top:1px solid #fec00d;color:#800080;padding:8px;border-collapse:collapse;border-spacing:0pt;}
.iconClass{
   horizontal-align: middle;
   padding: 1px;
  
} 
.iconPanel{
float: right;
}
.pagetitle{
font-weight:bold;
color: #0079C1;
background-color:white;
text-align:left;
text-indent:8px;
}
.IconExcel{
float: right; 
}

 Thanks a lot in advance!

 

Calvin


Hey guys please move this thread if this is not the best forum for it.

 

I wanted to understand the limitations of the high volume customer users and what they really mean to anyone who implements a salesforce customer portal.

 

From the salesforce docs,

 

Limitations

    High-volume portal users can't manually share records they own or have access to.
    You can't transfer cases from non-high-volume portal users to high-volume portal users.
    High-volume portal users can't own accounts.
    You can't add case teams to cases owned by high-volume portal users.
    You can't include high-volume portal users in:
        Personal groups or public groups
        Sharing rules
        Account teams, sales teams, or case teams
        Salesforce CRM Content libraries

 

I want to understand the limitations marked in bold especially the last one...What does "Salesforce CRM Content libraries" actually mean? Does it mean I cannot share a document with these users?

Hey All,

 

This is something that has stumped. Its easy enough to drag a Visualforce page from an installed app onto a page layout.

 

But in my case I am building a customer portal using Visualforce and would need to display a login page from this app on my page.

 

How would I go about doing this. Does it need special syntax to be able to refer to this app page?

 

Thanks,
Calvin

Our org currently has "public read" permissions on our org wide defaults. We cannot make this private.

I am creating a customer portal with custom visual force pages...where I display data using SOQL queries.

 

Is it a good idea to add a clause on the SOQL query to return only those records where the account id matches the logged in user's acount id?

 

And if yes..how can I get the currently logged in user's acount id?

 

Thanks.

This is Visual force related but I think the problem is in my code so I am asking it here.

 

I have a visualforce page displaying records from a custom object. It has one field settlement__c which is a lookup field and has a master-child relationship with another object called settlement.

 

I am displaying all records using a data table. The user has full access to both objects and all fields.

I am extracting data using a SOQL statement and have verified it returns the correct data in the query explorer.

 

These results are stored in a list which is used to populate the datatable columns,.

When I use Settlement__c , I can see a value in that column. But the same does not work when I use settlement__r.name or settlement__r.id which I need to obtain so that I can display a page with that record's information.

 

My code:

 

      <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Settlement" action="{!toggleSort}" rerender="results,debug,fundingReportResults,dataTable,errors,pageNumberPanel" styleClass="commandStyle">
                        <apex:param name="sortField" value="Settlement__r.id" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet> 
                <apex:outputLink onclick="window.open('/apex/InvoiceDetails?id={!mt.moneyTransactions.Settlement__r.id}');">    
                    Details
                </apex:outputLink>
            </apex:column>

 I am not getting anything, the id or name returned is null.

 

What am I missing here I was so sure it was security but apparently the user has full security to the object and has has field level security.

And why do I see data when I use Settlement__c instead of settlement__r.name/settlement__r.id?

 

Thanks,

Calvin

Hi All,

 

I thought this should be a pretty straightfoward thing but I was not able to find anything about it.

 

Basically in a datatable I am displaying names in a column using apex:outputtext(by binding results returned by a list in a controller class). These names are of varying lengths. I am displaying icons next to the names and want to format the names to be of fixed length so that the icons can line up.

 

I thought that there would be a length attribute or something to that effect. Is there anything that helps us to specify a fixed length in any visualforce text component. ?

 

Thanks,
Calvin

Hi All,

 

I have written a validation trigger to make sure that only one record of a custom object has a particular flag turned on for each account.

When I test this trigger directly by trying to create a record that satisfies the trigger condition, I get the error message as expected.

 

So I went ahead and wrote a test class. I am new to apex and this was my first attempt at writing a test method. I read the docmentation and some examples. When I run my test, its 75% complete which is good to move to production but 2 of the most crucial lines are not being tested. I want to understand why this is happening and how  can address it.

 

When I look at the log, the SOQL query whic is a the heart of my trigger's error mechanism does not return any rows. I confirmed that this query with the values given in the test class does return a row and therefore the error must be raised. but for some reason this is not happening.

Please help meunderstand what is wrong here. Thanks.

 

Trigger code:

 

trigger osv_check_default_flag on Collection_Rule__c (before insert, before update) 
{
	//Declarations		
	ID accountID;
	//List of Collection rule objects from the same account
	List <Collection_Rule__c> rules;
	
	for (Collection_Rule__c newRule : Trigger.new) 
	{
		//Get Account of record being inserted
		accountID = newRule.Account__c;
		//Get collection rules from the same Account where the "default" flag is checked.
		rules=[select id from Collection_Rule__c where Default__c=true and Account__c=:accountID];
				
		//If records with the default exist and the current record has its default flag checked, Do not save and raise ERROR!
		if(rules.size()>0 && newRule.Default__c == true)
		{
			newRule.addError('An Account can only have ONE Default Collection Rule');
			break;
		}	 
	  
	 }
	
	

}

 test class:

 

@isTest
private class osv_test_collection_rule_trigger {
	//Test Method
	static testMethod void CollectionRulesDefault_Test() 
	{
		//Prepare Data
		Collection_Rule__c cr = new Collection_Rule__c();
		cr.Name = 'Test Collection Rule';		
		//This is an ID and will need to be changed when moving to production.
		cr.Account__c = '001Z0000004pGIIIA2';
		cr.Default__c = true;
	
		
		//START TEST
    	//test.starttest();
    	
    	/*Try-catch is the better way to test AddError() method
    	//http://boards.developerforce.com/t5/Apex-Code-Development/How-do-I-test-for-an-exception-addError-in-a-Trigger/td-p/145443*/
    	
    	try {    	
    	//Insert record
    		insert cr;   		
    		
    	}
    	catch(Exception e){
    		Boolean expectedExceptionThrown =  e.getMessage().Equals('An Account can only have ONE Default Collection Rule')? true : false;
            System.AssertEquals(expectedExceptionThrown, true);
            } 
    	
    	//test.stoptest();
	}
}

 

I am trying to create a validation rule to do the following.

 

When creating a record which has a check field called flag, check if any other record of the same sObject type has its flag checked. If yes do not save.....

 

Since I need to reference other records, how can this be done in a validation rule. is this even possible?

We have a Salesforce app where we have some custom objects and want to expose the various custom object rcords to customers.

We need to ensure that customers can see only the records belonging to their Account. Because of the way these records are setup(owned by various system users at different levels of processing), we cannot use owner based sharing...and cannot use criteria based sharing since its not dynamic(I cant use criteria based sharing to say "Share this record with all customer portal users who belong to the same Account as the record" at runtime).

So I know I have to use Apex based sharing. I have read up on the sharing objects and the sharing table. But how would I approach this.

I can write a trigger which upon inserting will create a share object and get all userids who belong to the customer portal group and whose account equals the account of the record and associate them with the share object of the record.

But I feel this is overkill correct? Lets say there are 5 users from one of our customers and lets say there are 500 records created a day...that means 2500 share objects a day just for 1 customer...for 10 customers this can go upto 25000...and scale in this way...

Am I right here?

Another problem would be if a new person joined that customer team..unless another process updates the sharing on older records, he/she cannot see the older records.

So is there a better/elegant way to do this? I thought of adding a share object to the group...but there is just one group "Customer portal group" and how do I associate the group with the account of the users?

I will appreciate any thoughts about this.

<apex:image rendered="{!IF({!mt.moneyTransactions.ACH_Type__c}=='Direct Deposits',true,false)}" value="{!$Resource.DepositImg}" width="30" height="20"/>

 

What is wrong with this? Is my IF condition correct? I get a syntax error message.

 

Thanks,
Calvin

Hey guys,

 

I thought that the primary selling point of Force.com sites is creating public web pages where you can display data to users without requiring a login where our VF pages could be accessed by the Site guest user provided we gave the right object access to the guest user profile.

 

We want to display a custom object and its chatter feed and we need it to be read only. I thought this will be possible but it turns out that the Guest user does not have access to the Chatter APIs.

 

Has anybody else run into this problem? We are hoping to avoid having to ask the users to login.

Any thoughts on this problem would be much appreciated.

 

Thanks.

Hi,

 

I have a requirement to build an intranet site for one of  my clients. The main requirements are - 

1. authenticated website with a rich look and feel; different users could potentially see different contents.

2. strong content management capability

3. Contents are mostly read only, a few forms are to be present on the website

 

I have evaluated force.com site, company community, site.com. Looks like force.com site, with a content management solution like cmsforce 2 or Orchestra, using customer portal license is the best choice.

 

Any suggestions please.

 

Thanks,

vikash

Hi,

 

As you may know Salesforce released a new product recently which is based on Chatter. The out of the box product looks great but I have seen some demos where the uers have made advance customizations on the community pages. They have also changed the main chatter pages and added some sections to it.

 

How do we customize existing pages on a community. I have experience building new pages from scratch. Does anybody have any experience customizing communities using HTML/CSS?

 

Another question is we would need to use a force.com site to host the custom pages. How do we use chatter tags in Visualforce since the documentation says most chatter tags do not work with VF pages which are part of a force.com site?

 

Thanks!

I am trying to display a link on a custom VF page to a word document which has been uploaded to a folder in the Documents tab.

 

For some reason this is not working as expected. The link is not pointing to the document. Security is also not an issue. I am not doing something right in the VF I suppose.

 

Here is my controller code:

 

public with sharing class osv_portal_HomePageContoller {
public string strDocUrl;
public osv_portal_HomePageContoller()

{

    try
    {
        List<Document> lstDocument = [Select Name from Document where Name = 'SLA-Technology' limit 1];
        string strOrgId = UserInfo.getOrganizationId();
        strDocUrl = '/servlet/servlet.FileDownload?file='+lstDocument[0].Id;

    }
    catch (Exception e) 
    {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error in getDocumentLogoUrl() ' + e.getMessage()));
        System.debug('Error: ' + e.getMessage());
    }
        System.debug('The URL is ' + strDocUrl);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'The URL returned is ' + strDocUrl));   

    }

 This is my VF code:

<apex:outputLink value="{!strDocUrl}" id="theLink" styleclass="slabutton">
    <span class="delete">Service Level Agreement</span>
 </apex:outputLink>

Thanks,
Calvin

The basic question: Is Jitterbit Data Loader for Salesforce a better data loader than Apex Data Loader?

The deciding factors for us would be performance, stability, ease of configuration, and vendor support

I am looking for insight from someone who has used both and would like to get your opinion about which one you prefer and why

This is how we use Apex Data Loader today...
- Bulk Load .csv files into the cloud
- Insert, Update, Upsert, Delete, Export
- Called via Shell script from SSIS

A key feature of the Apex data Loader that makes it work for us today is this:
The ability to edit the "config.properties" file

For example...
We have found it necessary to tweak the following settings on an object by object, operation by operation basis to achieve the required level of performance and still stay within Salesforce API usage metering limits:
dataAccess.writeBatchSize
dataAccess.readBatchSize
sfdc.loadBatchSize
sfdc.extractionRequestSize

Does Jitterbit allow for this same level of configuration?

Thank you in advance for any insight you can offer!

 

Hello,

Please help me to write test case for the below class.

 

 

public with sharing class ABC{

Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
public string errormsg{get;set;}
public ApexPages.StandardSetController setCon {
get{ if(setCon == null){
String status='';
String contid='';
try {
status = ApexPages.currentPage().getParameters().get('status');
status = status.trim();
contid=ApexPages.currentPage().getParameters().get('Id');
contid = contid.trim();
} catch (System.StringException e) {
System.debug('Error in param Processing: ' + e);
}
size = 10;
string queryString = string queryString = 'SELECT Id, Name FROM Sample__c Order by Name WHERE InquiryContent__c = \''+contid+ '\' AND Status__c = \''+status +'\' Order by Name';
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon.setPageSize(size);
noOfRecords = setCon.getResultSize();
if(noOfRecords ==0) {
errormsg='No records to display';
} else {
errormsg='';
}
}
return setCon;
}set;
}
Public List<Sample__c> sampleList(){
List<Sample__c> inqList = new List<Sample__c>();
for(Sample__c a : (List<Sample__c>)setCon.getRecords())
inqList.add(a);
return inqList;
}
public pageReference refresh() {
setCon = null;
sampleList();
setCon.setPageNumber(1);
return null;
}
public Integer getpage{
get{ integer i;
if(math.mod(noOfRecords,size)==0) {
i=noOfRecords/size;
}else {
i=noOfRecords/size+1;
}
return i;
}
set;}
}

hey guys,

 

I have a customized visualforce page. I need to display some documents. I dont want to upload them as static resources but rather in a folder where I can control which groups/roles can see that folder.

 

How can I link to or display any documents which are uploaded to this folder?

 

Thanks,
Calvin

I have a customized Force.com site and Customer Portal working together.  The portal users are High Volume Customer Portal users.  There are some pages that require no authentication (i.e., public/guest) and some that require authentication.  

I'm having an issue where the authenticated user cannot see Documents files (e.g., a pdf) , even though the guest/public user can.

 

Here's what's happening:

1. A user comes to the Force.com site as a guest/public user and can click the link that was created with apex:outputLink with a value of "/servlet/servlet.FileDownload?file=<recId>" and see the pdf because I set up sharing on the folder that the file is in to include the Guest User.  No problem.  

2. User logs in becoming an authenticated High Volume Customer portal user.

3. User clicks on that same link and now they get a Insufficient Privileges error.  PROBLEM!!!

 

According to http://login.salesforce.com/help/doc/en/customer_portal_manage_users.htm the High Volume Portal User cannot be included in any sharing rules, so there is no way to share this document with them (as far as I can tell); however, it seems like there *should* be some way for them to view it since the use case I've described seems completely reasonable that if the whole world (i.e., guest user) can see the document the authenticated user should be able to as well.

 

Both the portal profile and the guest/public profile have Read CRUD set on the Documents.

 

How can I get the authenticated High Volume Portal user to be able to see the Document?  I feel like I must just be missing something obvious, because I can't see how this wouldn't be supported.

 

If there is no way then what is the recommended way to handle this situation?

 

Thanks.

We have implemented Customer Portal Authenticated Sites User for the current client. We created a custom page that we wanted to be the homepage once the user logs in to the portal. The name of this custom page is "Home Page" We assigned this page as "Default Landing Tab" using "Customize Portal Tab" button. Also for Login too, there is a custom page created called "Login"

This works fine. When we log in to system using custom "Login" page, it does show our landing page - custom "Home Page". When user logs out, he is taken back to the custom "Login" page.

However when user's session is time out due to inactivity, he is shown Salesforce default login page rather than the custom login page created by us. I see that the url to which it is redirected is:

http://na8.salesforce.com/secur/login_portal.jsp?orgId=00DM0000000Cswa&portalId=060M0000000X8c3&startURL=%2Fvisualforce%2Fsession

Now when user enters his username and password, he is redirected to the Salesforce Default Home page rather than my custom "Home Page".

 

I see that this is due to presence of "startURL" parameter in the URL. Is there a way I can get this parameter removed from the URL when there is a session timeout.

 

I tested my app in the DE org and everything worked fine.  I went to connect it to our main org and I got this:

{"message":"The Chatter Connect API is not enabled for this organization or user type.","errorCode":"API_DISABLED_FOR_ORG"}

 

I know that our admins are going to resist enabling anything that they don't think is necessary for business.

 

Question:

1) Is there a doc somewhere on how to enable it properly?  (I couldn't find it)

2) Is there a doc from Salesforce that outlines the security best practices and soothes the mind of an average admin.  Things that I am looking for in a doc like that is that via Chatter API no one will be able to get the customer data, change the customer data, get any opportunity data or anything like that.

 

Thank you!!


Hi, I come from C# land and am new to Apex.  I am simply trying to get access to the User.FirstName value in the controller.  I can do this in the view just fine:

{!$User.FirstName}

Below are examples of my attempts at doing this...

// In the view:
// -----------------

{!test}

// In the controller:
// -----------------

// Compiler error: Return value must be of type: String
public static string test { get { return User.FirstName; } }

// Compiler error: Incompatible types since an instance of Schema.SObjectField is never an instance of String
public static string test { get { return (string)User.FirstName; } }

// Compiles but always returns 'FirstName'
public static string test { get { return User.FirstName + ''; } }

// Compiler error: expecting a semi-colon, found ':'
public static string test { get { return :User.FirstName; } }

// Compiler error: line 33:10 no viable alternative at character '$'
public static string test { get { return $User.FirstName; } }

Surely there is a way to do this?

Thanks!

Hello. 

 

I had been seeing strange behavior on a page - and narrowed down the cause of thisodd behavior to the use of an ActionPoller.  After doing some research, it seems that using an ActionPoller with a dataTable causes problems.

 

Below is my code.  Does anyone have any suggestions how to refresh this table - but avoid known problems with ActionPoller & DataTable?

 

Any thoughts would be appreciated.  Thanks in advance.

 

<apex:pageBlock title="Customer Overview"> 
<apex:dataTable value="{!Customers}" var="cust" id="CustList" width="100%" > 
 <apex:column > 
  <apex:facet name="header"><b>Customer Name</b></apex:facet> 
  <apex:commandLink action="{!invokeService}"
                    value="{!cust.CustName__c}" rerender="blockA, blockB">
    <apex:param name="xxx" value="{!cust.id}"/>
  </apex:commandLink>
 </apex:column> 
</apex:dataTable> 
<apex:actionPoller rerender="CustList" interval="5"/>
</apex:pageBlock>

 

My code runs fine in visualforce but when I publish to site it gives me an error indicating that the api is disabled for a particular user.

 

Coincidentally, there isn't any custom code here - it's taken directly from the example in the ajax toolkit developer's guide:

 

 

<apex:page >
    <script type="text/javascript">
    var __sfdcSessionId = '{!GETSESSIONID()}';
    </script>
    <script src="../../soap/ajax/21.0/connection.js"
          type="text/javascript"></script>
    <script type="text/javascript">     window.onload = setupPage;
    function setupPage() {
      //function contains all code to execute after page is rendered  
    

      var state = { //state that you need when the callback is called  
    
          output : document.getElementById("output"),
          startTime : new Date().getTime()};

      var callback = {
          //call layoutResult if the request is successful  
    
          onSuccess: layoutResults,

          //call queryFailed if the api request fails  
    
          onFailure: queryFailed,
          source: state};

      sforce.connection.query(
          "Select Id, Name, Industry From Account order by Industry",
           callback);
  }

  function queryFailed(error, source) {
    source.output.innerHTML = "An error has occurred: " + error;
  }

  /**
  * This method will be called when the toolkit receives a successful
  * response from the server.
  * @queryResult - result that server returned
  * @source - state passed into the query method call.
  */  
    
  function layoutResults(queryResult, source) {
    if (queryResult.size > 0) {
      var output = "";

      //get the records array  
    
      var records = queryResult.getArray('records');

      //loop through the records and construct html string  
    
      for (var i = 0; i < records.length; i++) {
        var account = records[i];

        output += account.Id + " " + account.Name +
            " [Industry - " + account.Industry + "]<br>";
      }

    //render the generated html string  
    
    source.output.innerHTML = output;
    }
  }
  </script>

    <div id="output"> </div>
   
</apex:page>

 

So my questions are:

can the ajax toolkit be enabled on force.com sites for an anonymous, read only user?

if so, how? 

if not, is there a workaround?

 

 

 

Hi,

 

I've setup a page that allows a user to download a link that is an attachment to an account. The problem is that file is accesable to the guest user but when the portal user logs in and tries to download the file they receive an authorization required message.

 

The portal user has a High Volume Portal license and I've made sure that the profile has read access to the account object as well as the document object. How do I enable file access for High Volume Portal users. It seems ridiculous that the guest users can have higher levels of access then authenticated users.

 

Thanks!

Scott

  • September 01, 2010
  • Like
  • 0

I'm pretty sure I'm just trying to do some straightforward AJAX here.  When I use oncomplete or reRender widhin actionFunction, I see the following Javascript error (via Firebug):

 

element.selectNodes is not a function

 

And the Javascript engine basically choke at this point.   The error happens within the Salesforce AJAX library: 

3_3_0.GAorg.ajax4jsf.javascript.AjaxScript on line 101.  This occurs at a point where the code does a try{selectNodes()} to figure out of it should run either selectNodes() or getElementsByTagName().  If the try{} fails, the catch(){} should run the getElementsByTagName().

 

I've seen this in FF3.5.6, though things seem to work fine in FF3.0.16.   In IE7 and IE8 I get data back inconsistently.  Generally if I put trash data in yahooProduct and then try good data, I will things will work fine.  However, until I do this special sequence, the AJAX will not work in IE.  I know, this part this sounds like a bug of my own making... probably is... but for the life of me I cannot pin point it.  The code isn't all that complicated.

 

If I take out oncomplete and reRender, I get no Javascript errors.  Of course, I have no way to see if the AJAX did anything, either.

 

Strangely, I can find no references to this issue on the discussion boards.  I'm not doing anything particularly fancy.  Anything stand out in my code below?

 

 

My Visualforce:

 

 

<apex:page standardController="Purchase__c" extensions="PurchaseExtension" recordSetVar="purchases" title="New Purchase">

<apex:sectionHeader title="Purchase Edit" subtitle="New Purchase"/>

<apex:messages layout="table"/>

<style>
td.labelCol {
vertical-align: middle;
}
</style>
<apex:form styleclass="p-form" id="p_form">

<apex:pageBlock title="Purchase Edit" mode="edit">

<apex:actionFunction name="updateProductDetails" action="{!updateProductDetails}" immediate="true" reRender="field_table">
<apex:param name="firstParam" assignTo="{!yahooProduct}" value="" />
</apex:actionFunction>

<apex:outputPanel id="field_table">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="labelCol requiredInput">Contact</td>
<td class="dataCol col02" style="height:20px;">
<apex:inputField value="{!p.Contact__c}" required="true"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Purchase Date</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Purchase_Date__c}" required="true"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Yahoo! Product</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Yahoo_Product__c}" required="true" onchange="updateProductDetails(this.value)" />
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Item Description</td>
<td class="dataCol col02">
<input disabled="true" id="item-desc" type="text" value="{!productDesc}"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Item Price</td>
<td class="dataCol col02">
<input disabled="true" id="item-price" type="text" value="{!productPrice}"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Quantity</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Quantity__c}"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Total</td>
<td class="dataCol col02">
<input id="total" type="text"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Ship Date</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Ship_Date__c}" />
</td>
</tr>
</tbody>
</table>
</apex:outputPanel>

<apex:inputHidden value="{!p.Name}"/>
<apex:inputHidden value="{!p.Contact__c}"/>

<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>

</apex:pageBlock>

</apex:form>

</apex:page>

 

 

 

 and my Extension:

 

 

public class PurchaseExtension {
public Purchase__c p {
get {
if (p == null)
p = new Purchase__c();
return p;
}
set;
}

public Contact c {
get {
String contactId = Apexpages.currentPage().getParameters().get('id');
if (c == null) {
c = [select c.FirstName,c.LastName from Contact c where c.id = :contactId];
}
return c;
}
set;
}


String productDesc, productPrice;
public String getProductDesc() {
return productDesc;
}
public String getProductPrice() {
return productPrice;
}

String yahooProduct = 'init';
public void setYahooProduct(String p) {
yahooProduct = p;
}
public String getYahooProduct() {
return yahooProduct;
}

public PageReference updateProductDetails() {
if (yahooProduct != null) {
List<Yahoo_Products__c> yp = [select p.Item_Description__c,p.Price__c from Yahoo_Products__c p where p.Name = :yahooProduct];
if (yp.size() > 0) {
productDesc = yp[0].Item_Description__c;
productPrice = ''+yp[0].Price__c;
} else {
productDesc = 'No product details avalable';
productPrice = 'No product details avalable';
}
} else {
productDesc = 'No product?';
productPrice = 'No product?';
}
return null;
}

public PurchaseExtension(ApexPages.StandardSetController ctlr) {
p.Contact__c = c.Id;
p.Purchase_Date__c = Date.today();
}

public PageReference save() {
PageReference pr = null;
// stub
return pr;
}

public PageReference cancel() {
// stub
return null;
}

public static testMethod void testSave() {
Test.setCurrentPage(new PageReference('/?id=003A0000004JoTl'));
List<Purchase__c> pList = new List<Purchase__c>();
ApexPages.StandardSetController ctlr = new ApexPages.StandardSetController(pList);
PurchaseExtension e = new PurchaseExtension(ctlr);
e.c = new Contact(FirstName = 'Foo', LastName = 'Bar');
e.p.Yahoo_Product__c = 'a04A000000101DT';
e.save();
System.assertNotEquals(e, null);
}

public static testMethod void testUpdateProduct() {
Test.setCurrentPage(new PageReference('/?id=003A0000004JoTl'));
List<Purchase__c> pList = new List<Purchase__c>();
ApexPages.StandardSetController ctlr = new ApexPages.StandardSetController(pList);
PurchaseExtension e = new PurchaseExtension(ctlr);
e.setYahooProduct('HistProd');
e.updateProductDetails();
String newDesc = e.getProductDesc();
System.assertNotEquals(newDesc, null);
}
}

 

 

 

 

Message Edited by JasonGabler on 01-05-2010 11:13 AM
Message Edited by JasonGabler on 01-05-2010 02:37 PM