• Anand@SAAS
  • SMARTIE
  • 1034 Points
  • Member since 2008

  • Chatter
    Feed
  • 40
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 243
    Replies

Hi, I have two objects with Master / Detail relationship

Master: API Name: SD_User__c

Object Name:SD_User SD License

 

Detail: API Name: SD_License_in_Opportunity__c

Object Name: SD_License_in_Opportunity

Plural Label: SD Licenses in Opportunity

Singular Label: SD License in Opportunity

 

Custom field that connect to Master:

API Name: SD_User__c

Field Name: SD_User

Field Label: SD License

 

I have a nested query that works fine in Sandbox but i can’t run it properly in production because of incorrect

From nested section (from detail object)

 

There is a Sandbox query:

for (SD_User__c sdUserList : [SELECT Id,
(select IsGlobalOpportunity__c, Opportunity__c From R00NT00000014FUrMAM ), Contact_Name__c 
FROM SD_User__c WHERE Contact_Name__c in :conID and IsDeleted=false])
{
    SD_License_in_Opportunity__c[] sdOpp = sdUserList.R00NT00000014FUrMAM;
    for(Integer j=0;j<sdOpp.size();j++)
    {   }

R 00NT00000014FUrMAM is  ID of SD_License_in_Opportunity__c. SD_User__c

 

My problem is reproduce it in Production environment

I tried to take that production field Id  00N200000026lpO and to complete it to 18 chars (R00N200000026lpOEAB according to SF instructions, i hope i did correctly) –  from 00N200000026lpOEAB

 

I tried also to write From Plural Label (to delete all spaces and to add __r) -  from SDLicensesinOpportunity__r

 

SF doesn’t recognized it. I get an error:

Compile Error: line 1, column 30: Didn't understand relationship 'SDLicensesinOpportunity__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

 

PLEASE HELP

 

Thank you

 

I have a custom button on the Event Page Layout designed to summarize the account/contact/event information from an event.

 

However, we require that an account be associated to the event in order to use the button.

 

The What field can be a number of different object types.

 

How can I programmatically ensure that the what is in fact an account and not something else?

 

Using javascript, I attempted to use the accountid:

 

var eventAccount = '{!Event.accountId }';

 

but there is no actual accountid field on Events.

 

"Field Event.accountId does not exist. Check spelling."

 

Is there a way to access accountid via javascript?

 

Thanks for the help!

hi i have written a test method for a contoller class.when i run the test i am getting 100% class coverage. The problem is i am updating a custom object using this controller. I have created a trigger so that whenewver a update is done on the custom object filed.if the email in custom obect existing in lead or contact it should update those objects correspondingly. so the trigger coverage in the controller class is only 52% since the email is existing in only lead or contact.

 

the overall coverage came down to 65%. How can i avoid this and deploy the controller.

 

 

global with sharing class preferenc 
{

    public PageReference cancel() {
        PageReference p = Page.user_preference;
         p.setRedirect(true);
          return p;
    }


    

 public string guestid;
    public guestuser__c gus{get;set;}

    public preferenc() 
    {
    this.guestid=ApexPages.currentPage().getParameters().get('paramID');   
        if(guestid!=null||guestid!='')
        {
            getdetails(guestid); 
        }   

    }

    
    
    public void getdetails(string guestid)
    {
        List<guestuser__c> guests=[select id,Email__c,Phone__c,Title__c,Email_Optout__c,A_H_interests__c,After_Markets_interests__c,Construction_interests__c,D_O_interests__c,Energy_interests__c,Environmental_interests__c,Financial_Enterprises_interests__c,Healthcare_interests__c,Manufacturing_interests__c,Property_interests__c,RealEstate_interests__c,Technology_interests__c,Windstorm_notification_interests__c from guestuser__c where id=:guestid];
        if(guests.size()>0)
        {
            gus=guests[0];
        }
        else
        {
            
        }
    }
    public PageReference save()
    {
        
          update gus;
          PageReference t = Page.thanks;
          t.setRedirect(true);
          return t;  
    } 
    
    static testMethod void testpreferenc()
    {
     
       ApexPages.currentPage().getParameters().put('paramID','a0RQ0000000B0On');
       preferenc controller = new preferenc();
       controller.save();    
       controller.cancel();
      
      
       }
    
}

 

 

the is i passed in the test method is a custom object record with the email existing in lead. so the trigger is covering only the lead updation part.

the trigger code is below.

 

 

trigger LeadUpdate on guestuser__c (after update) {

//guestuser__c gu = new guestuser__c();
//list<guestuser__c> gst =[];
list<Lead> newlead = [select id,email,phone,title,HasOptedOutOfEmail,A_H_Interest__c,Aftermarket_Interest__c,Construction_Interest__c,D_O_Interest__c,Energy_Interest__c,Environmental_Interest__c,Financial_Enterprises_Interest__c,Healthcare_Interest__c,Property_Interest__c,Real_Estate_Interest__c,Manufacturing_Interest__c,Technology_Interest__c,Windstorm_Notification__c from Lead where email=:Trigger.new[0].Email__c];
list<Contact>newcon = [select id,email,phone,title,HasOptedOutOfEmail,A_H_Interest__c,Aftermarket_Interest__c,Construction_Interest__c,D_O_Interest__c,Energy_Interest__c,Environmental_Interest__c,Financial_Enterprises_Interest__c,Healthcare_Interest__c,Property_Interest__c,Real_Estate_Interest__c,Manufacturing_Interest__c,Technology_Interest__c,Windstorm_Notification__c from Contact where email=:Trigger.new[0].Email__c];
if(newlead.size()>0)
{
newlead[0].Email = Trigger.new[0].Email__c;
newlead[0].Phone = Trigger.new[0].Phone__c;
newlead[0].title = Trigger.new[0].Title__c;
newlead[0].HasOptedOutOfEmail = Trigger.new[0].Email_Optout__c;
newlead[0].A_H_Interest__c = Trigger.new[0].A_H_interests__c;
newlead[0].D_O_Interest__c = Trigger.new[0].D_O_interests__c;
newlead[0].Real_Estate_Interest__c = Trigger.new[0].RealEstate_interests__c;
newlead[0].Property_Interest__c = Trigger.new[0].Property_interests__c;
newlead[0].Healthcare_Interest__c = Trigger.new[0].Healthcare_interests__c;
newlead[0].Aftermarket_Interest__c = Trigger.new[0].After_Markets_interests__c;
newlead[0].Construction_Interest__c = Trigger.new[0].Construction_interests__c;
newlead[0].Energy_Interest__c = Trigger.new[0].Energy_interests__c;
newlead[0].Financial_Enterprises_Interest__c = Trigger.new[0].Financial_Enterprises_interests__c;
newlead[0].Environmental_Interest__c = Trigger.new[0].Environmental_interests__c;
newlead[0].Manufacturing_Interest__c = Trigger.new[0].Manufacturing_interests__c;
newlead[0].Technology_Interest__c = Trigger.new[0].Technology_interests__c;
newlead[0].Windstorm_Notification__c = Trigger.new[0].Windstorm_notification_interests__c;

update newlead;
}
else
{
  if(newcon.size()>0)
  {
  newcon[0].Email = Trigger.new[0].Email__c;
    newcon[0].Phone = Trigger.new[0].Phone__c;
    newcon[0].title = Trigger.new[0].Title__c;
    newcon[0].HasOptedOutOfEmail = Trigger.new[0].Email_Optout__c;
    newcon[0].A_H_Interest__c = Trigger.new[0].A_H_interests__c;
    newcon[0].D_O_Interest__c = Trigger.new[0].D_O_interests__c;
    newcon[0].Real_Estate_Interest__c = Trigger.new[0].RealEstate_interests__c;
    newcon[0].Property_Interest__c = Trigger.new[0].Property_interests__c;
    newcon[0].Healthcare_Interest__c = Trigger.new[0].Healthcare_interests__c;
    newcon[0].Aftermarket_Interest__c = Trigger.new[0].After_Markets_interests__c;
    newcon[0].Construction_Interest__c = Trigger.new[0].Construction_interests__c;
    newcon[0].Energy_Interest__c = Trigger.new[0].Energy_interests__c;
    newcon[0].Financial_Enterprises_Interest__c = Trigger.new[0].Financial_Enterprises_interests__c;
    newcon[0].Environmental_Interest__c = Trigger.new[0].Environmental_interests__c;
    newcon[0].Manufacturing_Interest__c = Trigger.new[0].Manufacturing_interests__c;
    newcon[0].Technology_Interest__c = Trigger.new[0].Technology_interests__c;
    newcon[0].Windstorm_Notification__c = Trigger.new[0].Windstorm_notification_interests__c;
  update newcon;  
  }
}
}

 

 

Hi All,

 

I am wondering if there is a clever way to avoid getting an error message when a query returns no results.  At the moment it throws a 'List has no rows for assignment to SObject' error.

 

An example of a query would be :

 

Fund_Asset_Class_Link__c draftFundAwaitingApproval = [ select Fund__r.Id from Fund_Asset_Class_Link__c where Fund_Asset_Class__r.Id =: fac.Parent__r.Id and Fund__r.Fund_Status__c='Awaiting Approval' ];

 

If there are no Fund_Asset_Class_Link__c's meeting the query criteria I get an error.

 

One way I've seen to possibly avoid this is to do something like:

 

if ( [ select Fund__r.Id from Fund_Asset_Class_Link__c where Fund_Asset_Class__r.Id =: fac.Parent__r.Id and Fund__r.Fund_Status__c='Awaiting Approval' ].size() >0 ) {

 

Fund_Asset_Class_Link__c draftFundAwaitingApproval = [ select Fund__r.Id from Fund_Asset_Class_Link__c where Fund_Asset_Class__r.Id =: fac.Parent__r.Id and Fund__r.Fund_Status__c='Awaiting Approval' ];

 

}

 

But this clearly creates two queries, and I'll quickly hit restriction limits this way.

 

Any thoughts on how to get around this?

 

Many thanks,

Andrew

 

 

 

All --

 

I am quite new to creating Apex classes and test methods so please be gentle.  I have been coming through posts on the forms and trying to follow some of the cookbook examples but I have not been able to figure htis out.  I have created an extension controller to get some support information that relates to an account.  Here is the code for the controller extension:

 

 

public class ServicesExtension {

    public ServicesExtension(ApexPages.StandardController controller) {

    }

        Public Integer getCaseCount(){
                return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id')];
        }
        Public Integer getCaseCountOpen(){
                return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = false];

        }
        Public Integer getCaseCountOpenThisYear(){
                return [Select Count() from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = true and CreatedDate = THIS_YEAR];

        }
        Public Case getLastOpenCase(){
                return [Select Id, CaseNumber, Subject, CreatedDate from Case where AccountId= :System.currentPageReference().getParameters().get('id') and isClosed = false Order By CreatedDate desc limit 1];
        }

}

 

 

And I have the following created for the test method:

 

 

@isTest
private class ServicesExtentionTests {

    static testMethod void myUnitTest() {
    
    Account testAccount = new Account();
    testAccount.Name = 'Echo360 Test Company';
    testAccount.Classroom_Management_System__c='Blackboard';
	testAccount.Name='My Test Company';
	testAccount.Type='Customer';
	insert testAccount;
	
	Case testCase = new Case();
	testCase.Subject = 'My Test Case';
	testCase.Status = 'Open';
	testCase.AccountId = testAccount.Account_ID__c;
	insert testCase;

	PageReference pageRef = Page.AccountSummary;
    Test.setCurrentPage(pageRef);
    ApexPages.currentPage().getParameters().put('id', testAccount.id);
    
    ServicesExtension acctController = new ServicesExtension(new ApexPages.StandardController(testAccount));
    Account updatedAccount = [select Classroom_Management_System__c, name, type FROM account where id = :testAccount.Id];
    system.assertEquals('Blackboard', updatedAccount.Classroom_Management_System__c);
    system.assertEquals('My Test Company', updatedAccount.Name);
    system.assertEquals('Customer', updatedAccount.Type);
    
    ServicesExtension caseController = new ServicesExtension(new ApexPages.StandardController(testCase));
    integer caseCount = caseController.getCaseCount();
    Case updatedCase = [Select Subject, Status, AccountID from Case.ID where AccountId = :testCase.Id];
    system.assertEquals('My Test Case', updatedCase.Subject);
    system.assertEquals('Open', updatedCase.Status);
    }	        
}

 

 

The code coverage is only 27% and I think that this is because I am not covering the 3 count queries I have in the controller and the last open case query.  I am not sure how I would test this for these types of queries.

 

Again if this is something that is APEX 101 for many of you I am sorry.

 

Thanks,


Wes

Does anyone know of the performance and limit ramifications between using __c vs using __r.Id when querying against reference objects?  They both seem to work, but what's the difference in terms of resource usage?

 

For example... 

 

// querying for myaccounts by a list of state ids

List<MyAccount__c> accounts = [ Select Id From MyAccount__c Where State__c In :stateIdsList ];

// VS

List<MyAccount__c> accounts = [ Select Id From MyAccount__c Where State__r.Id In :stateIdsList ];

 

 

We ran into a non-selective query issue and one of the things that seem to alleviate it was to switch a query from using __r.Id to use __c instead.  Therefore, I believe that using __c probably requires less lookups and will return a smaller set in the SOQL engine?

 

Anyone have any insight or know where there is some documentation on this distinction?

 

Thanks

I want to get a list of classes at run time.  Such as spring would allow in java.  lIke a facorty.

 

Is there anyway to achive a similar result in APEX.

 

For example I want to get a list of all classes that implement a interface.  I have also named my classes consitantly so I can query for them

 

i.e.

 

Select Name from ApexClass where Status = 'Active' AND Name like 'My_XML%'

 

This returns 20 classes.  I want to create a new instance of each class and call a method on it.  Is this achiveable?

  • June 21, 2010
  • Like
  • 0

I have a trigger that pulls information from the owner of the account and places it in the custom object. There are 7 fields in the user object that I need to pull data from. 3 are standard objects, 4 are custom objects. My question is how do I pull the custom field information from the account owner's user record to the custom object fields?

 

My code:

 

trigger Escalation_Trigger on test1__c (before insert, before update) 
{

    list<id> accountIds = new list<id>();
    for (test1__c xxx : trigger.new)
        accountIds.add(xxx.account__c);
    //Map works fine on standard objects in User object.
	map<id,account> approvers = new map<id,account>([select id, owner.id, owner.manager.id, owner.UserRole.id from account where id in :accountIds]);

	//create map of Escalation Manager, Escalation Manager email, DDSM email, LOB email
	//Receiving error on line 12. I do not understand why. 
	map<id,account> managersescalation = new map<id,account>([select owner.Escalation_Manager_Email__c,  DDSM_email__c, LOB_Manager_s_email__c, RP_email__c from account where id in :account]);	

    for (test1 xxx : trigger.new)
    {
        Account approversAccount = approvers.get(xxx.account__c);
        // The first 3 work fine. THey are standard fields on the user object       
        if (xxx.Approving_M__c == null)
            xxx.Approving_M__c = approversAccount.owner.id; 
            
        if (xxx.Approving_Manager__c == null)
            xxx.Approving_Manager__c = approversAccount.owner.manager.id;
 
        if (xxx.Owner_Role__c == null)
            xxx.Owner_Role__c = approversAccount.owner.UserRole.id;
        //----------------
        // These 4 do not work. I do not know why. 
        // Do I reference the field name or API name?	

        if (xxx.Escalation_Email__c == null)
            xxx.Escalation_Email__c = managersescalationAccount.owner.Escalation_Manager_Email__c.id;	        
		
		if (xxx.DDSM_Email__c == null)
            xxx.DDSM_Email__c = managersescalationAccount.owner.DDSM_Email__c;
						
        if (xxx.LOB_Manager_s_email__c == null)
            xxx.LOB_Manager_s_email__c = managersescalationAccount.owner.LOB_Manager_s_email__c.id;	
			
        if (xxx.RP_email__c == null)
            xxx.RP_email__c = managersescalationAccount.owner.RP_email__c.id;	
    }
}   		
		

 

 

  • June 10, 2010
  • Like
  • 0

I'm building a vf page that will show details of a parent object, and then iterate over a list of related child records that have a certain status (where status__c != 'Leased').

 

I'm looking for an explanation on how to use System.Assert in regards to the related list of child objects.

 

Meaning, I have a query method that should result in a list of related child records.

 

So...I write a testmethod that calls my query method.

 

When I call my query method and it returns a list how, then, do I use System.Assert to assert that my query method has returned the list I expect?

 

All the examples I have seen of System.Assert seem to check one value against another. In my case, I'm not checking one value against another, I just want to verify that the query method has returned a list of related child objects where status__c != 'Leased'.

 

If there are no related child records where status__c != 'Leased', that is fine. I just won't display anything out on the vf page - that section will just be blank. Likewise, I don't really care how many related child records are returned in the list either. Meaning, the query method could return 1 record in the list or it could return 100 records in the list. Doesn't matter.

 

Furthermore, I'm using the vf page as part of a Force.com Site. Since it is public, I'm not allowing any saving, updating or editing of either the parent record being viewed or the related child objects being viewed. The vf page is only intended to query the db for related child records (where status__c != 'Leased') and iterate over them on the vf page in read-only mode. No data manipulation happening.

I am replacing the Notes and Attachments with separate visualforce page lists.

One of the elements shown on the visualforce page is the date/time created:

 

<apex:outputText value="{0,date,dd/MM/yyyy HH:mm}">,&nbsp;<apex:param value="{!FbkAtt.LastModifiedDate}" /></apex:outputText>

 This display in the visual force as: 09/06/2010 20:09.

 

However when I view in the Notes & Attachments related list is shows the correct time as: 09/06/2010 21:09.

 

I realise the difference is GMT to British Summer Time (+1) but how can i account for this in visualforce without have to change it when we revert back?

 

  • June 09, 2010
  • Like
  • 0

Hi,  We have a automatic way of creating our custom object of Product setups through our opportunity record, which was custom developed.

 When this occurs a expiration date is automatically brought in from our opportunity contract end date.

 

I noticed that the time is always set to 12:00 AM ,but when I create a Product setup manually through the account record the expiration date  time field always shows the time is at this moment.

 

Is this a salesforce standard functionality that it would always default to 12:00 AM no matter what the date is? Or would this be somewhere in their triggers/apex class or code? I am trying to find anything written out, but having no luck so wanted to know if was standard practice.

 

I found one s-control code that said this?


'expirationDate="'+ expDate.format("yyyy-mm-dd HH:MM:ss")+'" '+

Thanks

Hi Everyone,

 

I am trying to understand how Apex Batch works. Does Apex Batch do Job partioning? Below snippet is from the following link: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content%2Fapex_batch_interface.htm|SkinName=webhelp

 

"Each execution of a batch Apex job is considered a discrete transaction. For example, a batch Apex job that contains 1,000 records and is executed without the optional scope parameter from Database.executeBatch is considered five transactions of 200 records each. The Apex governor limits are reset for each transaction. If the first transaction succeeds but the second fails, the database updates made in the first transaction are not rolled back."

 

Based on above snippet, does Apex Batch executes the five transactions at a same time, like parellel processing? Or does it just executes the chunk of 200 records at a time sequentially? I am assuming it runs all five parllely. Please shed some lights.

 

Also, the start method of Database.Batchable Interface returns QueryLocator, does it return all the data in one call? Just trying to understand what QueryLocator does.

 

Thanks so much in advance! I'll look forward to your postings :-)

 

Regards!

Hello.  The Apex Developers Guide says there is a maximum of 10 sendEmail methods per transaction (page 310).  Is this counted by individual message sent, or by line of code executed?  Example: What if you have 11 messages in a Messaging.SingleEmailMessage array and call the sendEmail method once using this array?

 

(Each message in the array has slightly different content, which is why I'm not using mass email.)

 

Thanks

David

I have a custom object that linked to account that contains revenue information.

 

The Custom Object can have many rows, and I need to find the Sum of one column for the all rows.

 

I have created a trigger that fires on the update of the custom object.

 

If I add the account ID and the revenue into a map, how can I add them all together?

 

Something Like?

 

Map<Id, Double> AccUpdate = new Map<Id, Double>();

 

Sum WHERE Account ID's are the same?


Thanks in Advance.

 

Matt

 

Hello,

 

Through my trigger code is there any way to lock an Opportunity so that only  users with system administrator profile can edit it and not others ?

 

Please help.

Thank You.

  • April 11, 2010
  • Like
  • 0

I am trying to create a query to group our Project Billing Item (custom object) by Project (another custom object).  Below is a copy of my initial query:

 

 

SELECT Name, (SELECT Project__c, Name, Employee__c, Description_of_Work__c, Hours_Worked__c, Date__c FROM Project_Billing_Item__c) FROM Project__c

Which generates the following error when executing: "Didn't understand relationship 'Project_Item__c' in FROM part of query call.  If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name."

 

 

I also tried changing it to the following:

 

 

SELECT Name, (SELECT Project__c, Name, Employee__c, Description_of_Work__c, Hours_Worked__c, Date__c FROM Project_Billing_Item__r) FROM Project__c

 

 

....and still receiving same error message stated above.  If it helps Project Billing Item (Project_Billing_Item__c) has a Master-Detail relationship to Project (Project__c).  Some additional information in case it helps:ks

 

 

Master-Detail Options
Related To: Project
Child Relationship Name: Project_Billing_Items
Related List Label: Project Billing Items

Master-Detail Options
Related To:   Project
Child Relationship Name:   Project_Billing_Items
Related List Label:    Project Billing Items

 

 

 

Thanks for the help and if I can provide any additional information that might help just let me know!

Hi I need to increment decimals in my for loop but it is incrementing by 1...

 

for(Decimal zz=9.1;zz<9.4;zz++){ }

 It goes from 9.1 to 10 right away...

I need it to go from 9.1 to 9.2 to 9.3 to 9.4

 

Of course in my code the zz<9.4 will be a value from a list so something like student[0].term

Any suggestions on the incrementing?

 

 

 

Background:

We load a lot of data (10,000) records into a custom object.

We have to process these 10,000 records and have the Apex scheduler kick of a Job (Apex Class) once a day.

We are receiving an error: System.Exception: Too many script statements: 200001 

 

We have optimized the code to use maps and lists for processing records to avoid DML governers limits. 

 

Questions:

  1. Is this the right approach to do bulk data processing?
  2. We are doing a lot of looping which we believe is causing this scripts statements error.  Can this error be avoided by processing smaller batch sizes (eg 500 records at a time) while still being within the same Apex Scheduled Job?  This way we avoid governors limits.  If so, how??
  • March 15, 2010
  • Like
  • 0

Hi:

   I have a table that has a selectoption Picklist... and it is shown when a checkbox is true..

Now when you click off the checkbox , the picklist is hidden but the value stays in there as it was selected from the user....

 

Does anyone know a way to set the value of the picklist to a particular value if checkbox is not true????

 

Thanks 

Can we display a lookup field without Account Name being populated in the textbox?

 

 

We are grabbing Accountid from Contact Object. Account Name is being populated in the lookup textBox when the component is rendered. Can we remove Account name being populated in the lookup field when the page is rendered?

 

 Please advise

 

<apex:inputField value="{!con.Accountid}"/>

 

lookup 

 

we just need the LookUp field with empty TextBox

  • March 08, 2010
  • Like
  • 0

Anyone know if VF Email templates run as "With Sharing"? I have a VF template that sends emails to contacts ie. recipientType="Contact"

I use Apex Email to send the email and set the "Target Object Ids" to the Contact Ids. However I get an "System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []".

Contact is "Public Read Only" but the Contact is not associated with an "Account".

If I use a regular email HTML template, and send an email using Apex Email, it goes through as expected.

I have the following code:

 

Sales_Organization__c slsOrg= [    Select  SLS_ZONE_MGR_FULL_NM__c,
	                                   SLS_ZONE_MGR_EMAIL_TXT__c
	                           From    Sales_Organization__c s
	                           where   Market__r.Market_ID__c='38'
	                           and     SLS_ORG_LVL_NR__c='Z'
                                   and SLS_ZONE_CD__c='313'];
System.debug('>>>>>>>>>>>>>>'+slsOrg);
String phoneNbr = 'Phone:'+slsOrg.SLS_ZONE_MGR_PHON_NR__c;

System.debug('>>>>>>>>>>>>>>Phone:'+phoneNbr);

 In my debug Log I see this:

 

10:01:23.055|USER_DEBUG|[14]|DEBUG|>>>>>>>>>>>>>>Phone:Phone:4.20725E+11

 

Sales_Organization__c.SLS_ZONE_MGR_PHON_NR__c is defined as a "Phone" Datatype in the Custom Object. What am I missing here? I'm concatenating a CustomLabel to phone value in an apex controller and then displaying to the user in a visual force page.

 

 

 

 

I have a simple VF page /controller as below.  When the “onChange” event fires, my controller method is invoked but the “pbsiState” section does not re-render correctly. The “theValues” outputPanel get’s re-rendered and displays the updated value.

 

 

<apex:page standardController="Lead" extensions="ABN_TestController">

<apex:outputPanel id="theValues">
State Required:{!isStateReq}
</apex:outputPanel>
<apex:form id="theForm">
<apex:pageBlock id="pbMain">
    <apex:pageBlockSection columns="2" id="pbStateCountry">
            <apex:pageBlockSectionItem id="pbsiCountry">
                <apex:InputField value="{!myLead.Country__c}" id="customerCountry">
                    <apex:actionSupport event="onchange" action="{!IsStateRequiredForCountry}" 
                                        reRender="theValues,theForm.pbMain.pbStateCountry.pbsiState"/>
                </apex:InputField>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem id="pbsiState">
                <apex:InputField value="{!myLead.State_Province__c}" id="customerState" required="{!isStateReq}" 
                                style="{!IF(isStateReq,'border-size:2px; border-color:#C00;border-style:solid;','')}"/>
                 State Required:{!isStateReq}               
            </apex:pageBlockSectionItem>
            
                
    </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

 

 

Controller:

 

public with sharing class ABN_TestController {

    public Lead myLead {get; set;}
    public Boolean isStateReq {get; private set;}
    
    public ABN_TestController (ApexPages.StandardController controller) {
        myLead = new Lead();
    }
    
    public PageReference IsStateRequiredForCountry(){
      List<LeadStateProvRequiredCountries__c> theList=
          [Select Name from LeadStateProvRequiredCountries__c where Name=:myLead.Country__c];
      if(theList.size()==1){
          isStateReq=true;
      }
      return null;
    }
}

 

 

 

Page size is 10, Total records = 17.code that is being called:

 

 

this.setCtlr.next();
//populateData iterates using getRecords()
populateData();

 

 

Debug Log is below:

 

18:51:36.359|USER_DEBUG|[4]|DEBUG|>>>>>>>>>>>>>>>> MyMarketController>>>>>>>>>>>setCtlr.TotalSize=17
18:51:36.359|METHOD_EXIT|[4]|System.debug(ANY)
18:51:36.359|METHOD_EXIT|[202]|ALMLogUtils.log(String, String)
18:51:36.359|METHOD_ENTRY|[203]|01pQ00000004ZfQ|ALMLogUtils.log(String, String)
18:51:36.359|METHOD_ENTRY|[203]|ApexPages.StandardSetController.getHasNext()
18:51:36.359|METHOD_EXIT|[203]|ApexPages.StandardSetController.getHasNext()
18:51:36.359|METHOD_ENTRY|[4]|System.debug(ANY)
18:51:36.359|USER_DEBUG|[4]|DEBUG|>>>>>>>>>>>>>>>> MyMarketController>>>>>>>>>>>setCtlr.HasNext=true
18:51:36.359|METHOD_EXIT|[4]|System.debug(ANY)
18:51:36.359|METHOD_EXIT|[203]|ALMLogUtils.log(String, String)
18:51:36.359|METHOD_ENTRY|[204]|ApexPages.StandardSetController.next()
18:51:36.359|EXCEPTION_THROWN|[EXTERNAL]|System.VisualforceException: Modified rows exist in the records collection!
18:51:36.360|METHOD_EXIT|[204]|ApexPages.StandardSetController.next()
18:51:36.360|CODE_UNIT_FINISHED|MyMarketController invoke(next)

I have a simple VF page below:

 

<apex:page standardController="Lead"> 
<apex:form > 
<apex:inputField value="{!Lead.OwnerId}"/> 
</apex:form> 
</apex:page> 

 I don't see "Partner User" as a option the drop down. My Org has PRM enabled and I see that option in the standard "Change Owner" page. Any ideas?

 

I am using hte example from the developer guide below:

 

<apex:page standardController="Account" recordSetvar="accounts">
  <apex:pageBlock title="Viewing Accounts">
  <apex:form id="theForm">
    <apex:panelGrid columns="2">
      <apex:outputLabel value="View:"/>
      <apex:selectList value="{!filterId}" size="1">
        <apex:actionSupport event="onchange" rerender="list"/>
        <apex:selectOptions value="{!listviewoptions}"/>
      </apex:selectList>
    </apex:panelGrid>
    <apex:pageBlockSection >
      <apex:dataList var="a" value="{!accounts}" id="list">
        {!a.name}
      </apex:dataList>
    </apex:pageBlockSection>
  </apex:form> 
  </apex:pageBlock>
</apex:page>

 I have a list view defined that use the criteria "Partner Account is not empty". When I select this list view in my visual force page I get the following error:

 

LastName FROM Account WHERE (((ACCOUNT.IS_PARNTER != FALSE))) ^ ERROR at Row:1:Column:106 No such column 'IS_PARNTER' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

 

 

I have a page template that has some JQuery code to display a tooltip (uses the SimpleTip jquery plugin). When I render the page template directly i see no javascript errors. When I call a page that uses the template and adds content to the template, I am seeing the below error:

 

 

Any idea what might be wrong ? The Javascript error prevents me from using an actionFunction that I have defined in the template. The action function works fine in Firefox and mozilla.

I want to create a visual force page that leverages an existing List view that the user might have created. I need to put custom buttons on the page along with the list view and have the custom buttons act on the records selected in the list view.

 

The code at http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_sosc_list_views.htm gets me there to an extent but I now have to write VF code to display the columns.

 

I don't want to create custom list view buttons as we don't want to display the buttons to all users. AFAIK we cannot customize the standard list view layouts by profile.

 

Are there any alternatives?

Have a visual force email template below:

 

<messaging:emailTemplate subject="{!$Label.Action_Alert_Subject}" recipientType="User" language="{!recipient.LanguageLocaleKey}" relatedToType="User">
<messaging:plainTextEmailBody >
<apex:repeat value="{!relatedTo.Action_Alerts__r}" var="alert">
<apex:outputText value="{!alert.Count__c}"/>
<c:NewLine />
</apex:repeat>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 I have three records owned by a User and when I use the "Send and verify" on the email template, i see the 3 records merged in the final email However when I send the email via apex email from an apex batch the 3 records don't get merged. 

 

 

Tried changing the owner of hte related records to the user executing the batch but it still did'nt work. Any ideas would be much appreciated.

Have a test method for an apex batch and for some reason it is not calling the "Start()" or "Execute()" when i run the tests. If I run the apex batch via execute anonyomous the apex batch runs as expected. Here's my test method:

start():

 

global Database.QueryLocator start(Database.BatchableContext BC){
ALMLogUtils.log(CLASSNAME,'start() called !!!!');
....
..
}

 testMethod:

 

 

 

 

	public static testmethod void testActionAlertBatch(){
		TestDataHelper testData = new TestDataHelper();
        String acctNbr = '123456';
        User usr = testData.createLeaderUser(acctNbr);

		usr.Action_Alert_Enabled__c=true;
		usr.Action_Alert_1__c='Orders Not submitted';
		usr.Action_Alert_Frequency__c='Daily';
		update usr;
        List<Leader_Downline_Summary__c> ldrData = testData.createLdrSmryData(usr.MRKT_ID_ACCT_NR_KEY__c,usr.Id);
		
		Test.startTest();
		ActionAlertBatch alertBatch = new ActionAlertBatch(testData.market,System.now());
		Database.executeBatch(alertBatch,200);
		List<Action_Alert__c> alerts = [select Id from Action_Alert__c where OwnerId=:usr.Id];
		System.assert(alerts.size()==1); 
		System.assert(alerts[0].Type__c=='Orders Not submitted'); 
	}

 

 

Logs when running the test method:

 

15:2:28.189 (2083121000)|CONSTRUCTOR_EXIT|[140,33]|<Constructor>(SOBJECT:Market__c, Datetime)
15:2:28.189 (2083193000)|STATEMENT_EXECUTE|[141,3]|Database.executeBatch(ActionAlertBatch, Integer)
15:2:28.189 (2083324000)|METHOD_ENTRY|[141,3]|Database.executeBatch(ActionAlertBatch, Integer)
15:2:28.290 (2184134000)|METHOD_EXIT|[141,3]|Database.executeBatch(ActionAlertBatch, Integer)
15:2:28.290 (2184217000)|STATEMENT_EXECUTE|[142,3]|DeclareVar: LIST<Action_Alert__c> alerts
15:2:28.290 (2184250000)|SOQL_EXECUTE_BEGIN|[142,34]|Aggregations:0|select Id from Action_Alert__c where OwnerId=:usr.Id
15:2:28.320 (2214411000)|SOQL_EXECUTE_END|[142,34]|Rows:0
15:2:28.320 (2214499000)|HEAP_ALLOCATE|[142,34]|Bytes:4
15:2:28.320 (2214550000)|HEAP_ALLOCATE|[142,34]|Bytes:4
15:2:28.320 (2214633000)|STATEMENT_EXECUTE|[143,3]|System.assert(Boolean)
15:2:28.320 (2214751000)|METHOD_ENTRY|[143,3]|System.assert(Boolean)
15:2:28.321 (2214808000)|METHOD_ENTRY|[143,17]|LIST<Action_Alert__c>.size()
15:2:28.321 (2214838000)|METHOD_EXIT|[143,17]|LIST<Action_Alert__c>.size()
15:2:28.321 (2214885000)|EXCEPTION_THROWN|[143,3]|System.AssertException: Assertion Failed

 Not sure what I'm missing. 

 

 


Tried the following in "Execute anonymous":

 

Messaging.SingleEmailMessage	mail = new Messaging.SingleEmailMessage();
mail.setReplyTo('someemail@gmail.com');
mail.setSenderDisplayName('Sender Name');
mail.saveAsActivity=false;
mail.setToaddresses(new List<String>{'recipient@gmail.com'});
mail.setTemplateId('00XQ0000000QH2B');
mail.setTargetObjectId('00580000001gXtK');
mail.setUseSignature(false);
Messaging.sendEmail(new List<Messaging.Email>{mail});

 

The email is received successfuly by when I "hit" reply it show s the email address of the "Admin" user that I executed the above code with. Should it not be "someemail@gmail.com"?

 

Can the actionStatus facet have images embedded in them? Below is my visual force page:

 

<apex:page controller="DrilldownController" action="{!init}" showHeader="true">

<apex:form >
    <apex:actionFunction action="{!showRepDetail}" name="viewRepDetail" rerender="repDetail" status="rep_detail_sts">
        <apex:param name="repDetailAcctNbr" assignTo="{!repDetailAcctNbr}" value="" />
    </apex:actionFunction>    
                 
	<apex:outputPanel id="repDetail" layout="none">
		<c:RepDetail critAcctNbrs="{!repDetailAcctNbr}" rendered="{!repDetailAcctNbr!=null}" print="0" currUsr="{!currUsr}"/>	
	</apex:outputPanel>
                 
	<apex:actionStatus id="rep_detail_sts" stopText="">
		<apex:facet name="start">
            <apex:image url="{!URLFOR($Resource.AvonSiteAssets,'images/processing.gif')}"/><br/>
            {!$Label.Processing_Status_Message}
		</apex:facet>
	</apex:actionStatus>

    <table width="950" border="0" cellpadding="0" cellspacing="0">
        <apex:repeat value="{!reportRows}" var="rptRow">
			<tr>
				<td>
					<a href="javascript&colon;viewRepDetail('{!rptRow.row.MRKT_ACCT_KEY__c}');">
					{!rptRow.row.Representative__r.FirstName} {!rptRow.row.Representative__r.LastName}
					</a>
				</td>
			</tr>
		</apex:repeat>
	</table>
</apex:form> 

</apex:page>

 The text is displaying but the image is not getting displayed. Do I have do something different? I tried regular HTML <img> as well.

 

will a custom component controller 's constructor get called even if the "Rendered" expression evaluates to "false"? Below is a visual force page that has two components. Only one of them is rendered depending on the user's Profile name:

 

<apex:page showHeader="true" sidebar="false" controller="SiteHeaderController" action="{!init}">
<apex:form >
User Profile:{!userProfile}<br/>
<apex:outputText value="SL Component" rendered="{!userProfile='Leader'}"/><br/>
<apex:outputText value="ZoneDiv Component" rendered="{!OR(userProfile='Division Manager',userProfile='Zone Manager')}"/><br/>
<apex:commandLink value="{!$Label.Earning_Opportunity}" action="{!showEarningOpportunity}" rerender="earningOpportunity" rendered="{!userProfile='Leader'}"/>
<apex:outputPanel id="earningOpportunity">
   	<apex:outputPanel rendered="{!showEarningOppty}">
    	<c:SalesLeaderEarningOpportunity rendered="{!userProfile='Leader'}"/>
    	<c:ZoneDivEarningOpportunity rendered="{!OR(userProfile='Division Manager',userProfile='Avon Zone Manager')}"/>
   	</apex:outputPanel>
</apex:outputPanel>                
</apex:form>

</apex:page>

 

ShowEarningOpportunity method is below:

 

public PageReference showEarningOpportunity(){
	this.showEarningOppty=true;
	return null;
}

 

 

When I executed the page and click on the "command link", both constructors are getting called. Am I missing something?

 

I want to have a newline in a visual force email template. Here's what the template looks like:

 

<messaging:emailTemplate subject="{!$Label.Action_Alert_Subject}" recipientType="User" language="{!recipient.LanguageLocaleKey}" relatedToType="User">
<messaging:plainTextEmailBody >
<apex:repeat value="{!relatedTo.Action_Alerts__r}" var="alert">
<apex:outputText value="{!alert.Type}({!alert.Count__c}) ;" rendered="{!alert.Type__c='Orders Not Submitted'}"/>
<apex:outputText value="{!$Label.Orders_below_Minimum}({!alert.Count__c}) ;" rendered="{!alert.Type__c='Orders Under Minimum'}"/>

</apex:repeat>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

 

If I have two record in "Action Items", i expect the two records in two separate lines. However it does'nt get sent that way. If I use the following:

 

<messaging:emailTemplate subject="{!$Label.Action_Alert_Subject}" recipientType="User" language="{!recipient.LanguageLocaleKey}" relatedToType="User">
<messaging:plainTextEmailBody >
<apex:repeat value="{!relatedTo.Action_Alerts__r}" var="alert">
{!alert.Type__c}({!alert.Count__c};
</apex:repeat>
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

The email does have a newline after every record. I cannot use this option as the Type is a english picklist value and I need to be able to send the email in different languges based on the recipient's language preference.

 

I'm trying to create  visual force page that downloads as Excel or CSV . This works fine for English but for UTF 8 characters like Polish etc. some of the characters get replaced with "?" etc. I'm not sure there's a way to specify encoding when using contentTypes.

Does bind parameters work when they appear in the "INCLUDES" clause of SOQL. Here's my observation

 

 
String userTypes='\'All\',\'Avon Leader\'';
String titleLevels='\'All\',\'4\'';
String SPLASHPAGE_TYPE='Splash Page';
System.debug('>>>>>>>>>>>>>>>userTypes='+userTypes);
System.debug('>>>>>>>>>>>>>>>titleLevels='+titleLevels);
List<Market_Content__c> mcList = [select        Type__c,Content_Type__c,Content__c, User_Type__c,
Title_Levels__c, Market__r.Name
from Market_Content__c
where Type__c='Splash Page'
and Market__r.Market_Id__c = 'RO'
and User_Type__c includes (:userTypes)
and Title_Levels__c includes (:titleLevels)
 order by CreatedDate];

 

This SOQL returns 0 rows. However the following SOQL returns 1 row:

 

List<Market_Content__c> mcList = [select       Type__c,Content_Type__c,Content__c, User_Type__c,                                                                                                                               Title_Levels__c, Market__r.Name                                                                         from Market_Content__c
where Type__c='Splash Page'
and Market__r.Market_Id__c = 'RO'
and User_Type__c includes ('All','Avon Leader')
and Title_Levels__c includes ('All','4')
order by CreatedDate];

 

What am I missing?

 

All,

We are trying to capture some POST parameters that are passed from an External Site in a Visual Force page. We cannot do GET due to the client's security compliance policies.

One doing simple test (see code below), we are seeing that the POST parameters is not available when we do "getParameters()" on the Controller. It looks like the "domain" for visual force pages is the reason for this behavior.

Does anyone have a recommendation on what is the best way to accomplish this. Is the domain for the "Visual force pages" fixed per org /instance?

Additional details:
============================
While doing a httpsPost to a visual force page in the dev org I am not able to get the Post parameters even though the VF page is rendered.

This works fine in another sandbox environment where the visual force page remains in the same domain (atleast when seen through the Browser's address bar).

Shown below is the code used to send a Post request to VF page . This is an SControl in the same org.







frameUrl:

Page:

Page:






Upon POST the VF page is rendered with the following URL: https://c.cs2.visual.force.com/apex/Redirect (Domain changed to c.cs2.visual.force.com)

If I try to post directly to the changed domain, I am able to retrieve the POST parameters as shown below:




frameUrl:

Page:

Page:






Let me know whether we can POST directly to the changed domain.If the domain is dynamic it will cause problems.

will a custom component controller 's constructor get called even if the "Rendered" expression evaluates to "false"? Below is a visual force page that has two components. Only one of them is rendered depending on the user's Profile name:

 

<apex:page showHeader="true" sidebar="false" controller="SiteHeaderController" action="{!init}">
<apex:form >
User Profile:{!userProfile}<br/>
<apex:outputText value="SL Component" rendered="{!userProfile='Leader'}"/><br/>
<apex:outputText value="ZoneDiv Component" rendered="{!OR(userProfile='Division Manager',userProfile='Zone Manager')}"/><br/>
<apex:commandLink value="{!$Label.Earning_Opportunity}" action="{!showEarningOpportunity}" rerender="earningOpportunity" rendered="{!userProfile='Leader'}"/>
<apex:outputPanel id="earningOpportunity">
   	<apex:outputPanel rendered="{!showEarningOppty}">
    	<c:SalesLeaderEarningOpportunity rendered="{!userProfile='Leader'}"/>
    	<c:ZoneDivEarningOpportunity rendered="{!OR(userProfile='Division Manager',userProfile='Avon Zone Manager')}"/>
   	</apex:outputPanel>
</apex:outputPanel>                
</apex:form>

</apex:page>

 

ShowEarningOpportunity method is below:

 

public PageReference showEarningOpportunity(){
	this.showEarningOppty=true;
	return null;
}

 

 

When I executed the page and click on the "command link", both constructors are getting called. Am I missing something?

 

I'm trying to create  visual force page that downloads as Excel or CSV . This works fine for English but for UTF 8 characters like Polish etc. some of the characters get replaced with "?" etc. I'm not sure there's a way to specify encoding when using contentTypes.

 

Page size is 10, Total records = 17.code that is being called:

 

 

this.setCtlr.next();
//populateData iterates using getRecords()
populateData();

 

 

Debug Log is below:

 

18:51:36.359|USER_DEBUG|[4]|DEBUG|>>>>>>>>>>>>>>>> MyMarketController>>>>>>>>>>>setCtlr.TotalSize=17
18:51:36.359|METHOD_EXIT|[4]|System.debug(ANY)
18:51:36.359|METHOD_EXIT|[202]|ALMLogUtils.log(String, String)
18:51:36.359|METHOD_ENTRY|[203]|01pQ00000004ZfQ|ALMLogUtils.log(String, String)
18:51:36.359|METHOD_ENTRY|[203]|ApexPages.StandardSetController.getHasNext()
18:51:36.359|METHOD_EXIT|[203]|ApexPages.StandardSetController.getHasNext()
18:51:36.359|METHOD_ENTRY|[4]|System.debug(ANY)
18:51:36.359|USER_DEBUG|[4]|DEBUG|>>>>>>>>>>>>>>>> MyMarketController>>>>>>>>>>>setCtlr.HasNext=true
18:51:36.359|METHOD_EXIT|[4]|System.debug(ANY)
18:51:36.359|METHOD_EXIT|[203]|ALMLogUtils.log(String, String)
18:51:36.359|METHOD_ENTRY|[204]|ApexPages.StandardSetController.next()
18:51:36.359|EXCEPTION_THROWN|[EXTERNAL]|System.VisualforceException: Modified rows exist in the records collection!
18:51:36.360|METHOD_EXIT|[204]|ApexPages.StandardSetController.next()
18:51:36.360|CODE_UNIT_FINISHED|MyMarketController invoke(next)

Hi,

 

I am trying to expand and collapse a list upon clicking a link. The expanded list is a list of links that display some information. Everything is working as expected but, when I expand the list and  click on any link the list get collapsed (My JQuery code displays the collapsed list on page load). What I want to do is even after the refresh I do not want the list to Collapse unless I click on it to collapse. I wonder is this possible. My Jquery is as follows:

 

<script type="text/JavaScript" src="{!URLFOR($Resource.jQuery)}"></script>
       <script type="text/JavaScript">
           jQuery.noConflict();
           
           jQuery(document).ready(function($) {
           
               $("#ProductPanel").hide();
     
               $("#HorBulb").hide();
         
           
               $('#ProductDetails').click(function() {
                   if($("#ProductPanel").is(":hidden")) {
                       $("#ProductPanel").slideDown("slow");
                       $("#HorBulb").show();
                       $("#VerBulb").hide();
                       return false;
                   }
                   else{
                      $("#ProductPanel").hide("slow");
                       $("#HorBulb").hide();
                        $("#VerBulb").show();
                      return false;
                   }
               });
                         
           
       </script>  

 

When the list expands, I am displaying an horizontal bulb and when the list collapses i am displaying vertical bulb.

 

Thanks in advance

  • February 11, 2011
  • Like
  • 0

Hi guys,

 

I've got a new VF page that is using a customer controller (VF controller extension).   All's well.   The VF page has an autorun event defined as its action that is invoked via a custom button on a Task sObj.  

 

I can run this little "app" from within SF just fine and preview the SF Debug Logs looking for output from my System.debug statements.   However, this is pretty clumsy and I'm thinking there's got to be a better way to run this little VF applet from the Force.com Debug perspective under Eclipse.  

 

Right now all I have in my Eclipse project is my src->pages-> myPage and src->classes->myClass.   Can I add the stock SF Task sObj to my project and somehow run my tests from Eclipse where I can set breakpoints, etc??   Please, there's got to be a way and I'm just missing some area of the documentation that might explain how to set this up.

 

Thanks very much in advance for any direction one of you might be able to extend.

 

Best regards,

Paul 

  • August 09, 2010
  • Like
  • 0

This might be a silly question but i am unable to fix it.

I have an custom object created in sfdc which has more than 1000 records say 10000 records. But i am able to retrieve only 1000 records above that it is throwing an error , so how to  retrieve the 10000 records using soql query.

 

 Note: i dont want to apply limit here. I want to retrieve all the records.

 

Please let me know if any soln for this...

thanks

shaan

       

Hi,

 

I want to login to other salesforce organization and check wheather particular vf page exist or not on that org.

If present i want to redirect to that page on that org. Else want to show error page on my org.

I want to write the code in my Apex class.

For login I have used REST call. Configured https://login.salesforce.com in remote site settings.

Following is my code for login.

 

        HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('https://login.salesforce.com/?un='+userName+'&pw='+password+'&startURL=/apex/ABCPage');
       
        Http http = new Http();
        PageReference p;       
   
        try {
            HTTPResponse res = http.send(req);   
            showError = true;

            if(res.getStatusCode()== 302)
            {
                p = new PageReference('https://login.salesforce.com/?un='+userName+'&pw='+password+'&startURL=/apex/ABCPage');           
                showError = false;
            }

        } catch(System.CalloutException e) {
            //Exception handling goes here....
             System.debug('In catch '+e);           
        }

I don't know is it a right way? Please let me know if any other alternative possible? i am able to login and show that page using this code.

 

Same way is it possible to call Metadata API? Is there any endpoint available?

Or is there any other way to check if particular vf page i.e 'ABCPage' exist or not on other org through Apex code in my org?

 

i can get list of page in my org using

List<ApexPage> lstPages = [Select id, name from ApexPage];

Is there any way to get this list for other org?

 

Thanks..

 

Could someone point me towards any documentation on how to access a custom object's History tracking information through APEX?  I looked through the APEX reference but I may have missed it - if it's in there can you cite a page #?

Hey all, I am ramping up to start my first big visualforce project. I think it's not terribly complicated, but I could still use some design tips. Basically what we are trying to build is simple survey tool. I have 3 objects involved.

 

1) Contact

2) Question__c

3) Question_Answer__c

 

Question has 6 fields:

Active(checkbox)

Linked_field (text field)

Picklist_Values (text area)

Question_Name (text field)

Question_text (text area)

Question_Type (pickilist)

 

Question Answer has 3 fields:

Contact (Lookup to contact)

Question(Lookup to question)

Answer (text field)

 

What I want to happen is to host a visualforce page through Salesforce sites. The page invokes a controller that finds some random questionthis contact has not yet answered (defined as: no Question_answer__c record exists for this contact for this question__c), and presents them the question_text, and a fitting method of answering the question based on the question_type found in the related Question__C object. Once the question is answered, a Question_answer__c record is created and saved with the provided information. Then another question is picked at random that the user has not answered and the cycle repeats until all questions are answered, or the user stops.

 

So my questions are

1) Should I write a custom controller, or just extend one? Mostly this revolves around a Question__c object, because that contains all the information required for creating the question. Not sure exactly though, this being my first one and all.

2) How can I pick a record at random, that the user has NOT answered before? I imagine some kind of SOQL outer join type deal but the exact method for doing this escapes me.

3) Any clever ideas how I can create my dynamic answer__c field? This will probably be the hardest part. For example, if the qustion is a picklist (as specified in the question_type__c field on the question__c object), it needs create a piclist field, and populate it with the picklist_values field from the question__c object. If it is specified as a text field, it needs to render as a text field, etc.

 

4) Ideally the visualforce page could take the ID of a specific question to answer and it will grab that question instead of grabbing a random one. That should be pretty easy, just making note of it here so I remember :P

 

5) Kind of a side bar thing that will probably be handled later, but worth asking. Does anyone know if Salesforce sites offers the equivilent of session variables? I am going to need to write a login system eventually, so a contact can login with their username and password, and then begin answering questions. For now I'll probably just pass the contactId around in the URL so I know which contact to create the question_answer__c objects for, but eventually I'd like to move to something more secure.

 

Thanks for any insight. I really appreciate it!

I have a page template that has some JQuery code to display a tooltip (uses the SimpleTip jquery plugin). When I render the page template directly i see no javascript errors. When I call a page that uses the template and adds content to the template, I am seeing the below error:

 

 

Any idea what might be wrong ? The Javascript error prevents me from using an actionFunction that I have defined in the template. The action function works fine in Firefox and mozilla.

How to pass values to the show method on MRUHover.getHover({!cc1.Id}.show()...So,that when i move a mouse on to the item it should display some text  on Hover.

 

 

 

<div class="" onblur="MRUHoverDetail.getHover('{!cc1.Id}').hide();"
                                       onfocus="MRUHoverDetail.getHover('{!cc1.Id}').show();"
                                       onmouseout="MRUHoverDetail.getHover('{!cc1.Id}').hide();"
                                       onmouseover="MRUHoverDetail.getHover('{!cc1.Id}').show();">

Hey all,

I'm still getting the hang of object oriented programming, and I'm not sure how to solve this problem without "global variables".

 

Basically I have a large testing class. There is a seperate sub class for each trigger, page, and class that need to be tested. A lot of these tests though need the same type of data (contacts, accounts, leads, etc). How can I create one contact, one account, one lead, and let all the sub classes read from it and write to it? These being test classes, I cannot control what data is passed to them. So for example I have something like.

 

 

public static contact createTestContact()
{
    Contact testContact = new Contact(Firstname='Frank', Lastname='Jones');

       insert testContact;
       return testContact;
}

public testMethod void testContactTrigger1()
{
       Contact myContact = createTestContact();
       //Do some stuff
}

public testMethod void testContactOtherTrigger()
{
       Contact myContact = createTestContact();
       //Do some different stuff
}

 

How can I let testContactTrigger and testContactOtherTrigger share the same contact? I don't need two copies of the same contact, or the additional overhead that comes from instantiating it twice. Just once would be fine. Can I modify the createTestContact method to know when it has already created a contact once, and just return the same contact next time it is called?

 

While doing a mass insert using a batch process. If I get an error on a record , would it not insert the other records.

 

For example:

 

If I have to insert a list of Leads and a couple of leads in the list throw some errors , would it stop the operation for the whole list or just those records.

 

Hi Guys,

 

I have written a batch apex controller for my vf page.

In execute method of batch apex controller, i have a string variable "sample" and it is defined as

public String sample {get; set;} in that class.

 

but when i pass this variable to my page, it gives me null value.

i have used system.debug to check its value in my class and its showing the required value inside execute method.

 

So please help me on how this value can be passed to page correctly.Thanks

Hi,

since yesterday the code work properly and I saw the popup of url, but now it doesn't show me any popup

I want open popup with url every time if the stagename of opportunity is closed/won.

I have active the popup on chrome, ie , firefox.

What kind of problem is it ?

thank

 

 

<apex:page standardController="opportunity" >
    
  <script src="/soap/ajax/10.0/connection.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/functions.js"></script>
<script>

if ('{!Opportunity.StageName}' == 'closed/won') {
var url1= 'http://www.mysite.com/'
window.open(url1)
}
</script>

 

 

I need to find out listview for a specific user. How can I do that using Metadata API?

 

Any help?

 

Thanks.

could someone tell me (in English :) ) what the functional difference is between these two access modifiers?  from what I see, they both prevent access from outside classes, but what else?  what are the benefits of one vs. the other?

Is it possible to update the ID in a custom object in a managed package?  I want to be able to update the ID (which is an Autonumber with string) to add another string value such as:

 

From:

Intake-{0000001}

 

To:

Intake-{0000001} - Doe, Jane

 

This is because all the emails and tasks associated with the Intake only show the ID and it would be convenient to show the name of the person without needing to click into the record.  I was thinking an after update trigger could update the ID.

 

Thanks for any advice.

  • July 23, 2010
  • Like
  • 0

Hello,

Has anyone developed any multiple choice or survey applications in Salesforce.com out there? I have a similar project to develop multiple choices test in Salesforce.com but don't know how. Please advice. Please also send me some sample codes if available.

 

thanks

Paul