• BryanTSC
  • NEWBIE
  • 50 Points
  • Member since 2009

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

I currently set up our custom buttons with

 

https://na8.salesforce.com/a0C/e? 

 

When I go into the sandbox I have to modify the intance number. Someone told me you can exclude the instance so you don't have to modify sandbox custom buttons.

 

What is the short cut?

  • October 21, 2011
  • Like
  • 0

I am looking to list an app I developed on the appExchange.  The app contains a VF component with a js library that talks to a label printer and also includes a few JS remoting calls to fetch some data from the component controller.  Does this fit within the context of a web service, therefore requiring a burp scan for the app security review?  It doesn't seem to me that it would, but I'm a little bit confused.

I am looking to query data from multiple objects and combine it into one list that can be sorted.

 

For example, I'd like to grab a string and datetime field from various records in different objects (related only by contact), combine the data into one list, and sort on datetime.  This data should then be made available for display on a visualforce page. The end result will be an ordered timeline of "events" for a particular contact record.

 

What are some recommended approaches to achieving this result?  I appreciate the help!

I am in the process of converting one of my VF pages to a component so that it can be easily reused across objects.

 

In my VF page I implement a standard controller with an extension class.  The constructor of my extension class pulls in the record from the standard controller so I can perform some describe methods on it:

 

public myControllerExtension(ApexPages.StandardController controller) {
        
        Schema.DescribeSObjectResult objDescribe = controller.getRecord().getSObjectType().getDescribe();
        ...
}

What is the best way to replicate this in the component controller?  I'm aware that the component controller does not have access to the standard controller, with the exception of using attributes to pass some information in.  Are attributes the right way to go?  Would I use an extension class in my page to generate the necessary values to assign to my controller attributes?

 

Thanks in advance for your assistance!

Oh this seems so simple, yet I'm stuck!

 

Here's what I have now in my controller:

    public date d {
        get{
            d = date.today();
            return d;
            }
            set;
       }
    
    
    public List<event> all {
    get {
    all = [select subject, activitydate, location from Event where activitydate = :d Order By location ASC];
    return all;
    }
    set;
    }

 

All is peachy and the page loads up Today()'s info just fine.

 

Now, what I really want to do is load up the page initially with today's date and resulting info, but also have a button called "Next" that will add 1 day to the current date and update an outputPanel on my page with the new query results when clicked.

 

I know I need to add a function for the button action, but I'm not sure how to change the code above to manipulate the date variable accordingly.

 

Thanks in advance for any help you might provide!

Hi Folks,


I have a custom child object of Contact called Inquiry_History__c.  I developed a trigger so that whenever an inquiry history record is created that meets certain criteria, a task is created and assigned to the user specified in the inquiry history custom "Owner" field (a lookup to USER, automatically assigned via workflow upon creation).

 

Everything works as anticipated when adding records the good 'ole fashioned way.  However, I have a form hosted on VF sites that creates a Contact and associated inquiry history record that is now flashing the "Authorization Required' page on submit.

 

Where should I begin to look for the cause of this?  I'm not sure how I can debug this process to figure out why the webform is being halted.

 

Trigger:

 

trigger callInquiry on Inquiry_History__c (after insert) {

List<Task> taskList = new List<Task>();

    for (Integer i=0; i<trigger.new.size(); i++) {
    
        if(
        (Trigger.new[i].XStudent_Type__c == 'FF') && 
        ((Trigger.new[i].XCollege__c == 'RSC') || (Trigger.new[i].XCollege__c == 'SCA'))) {
            taskList.add(
                new Task(
                    whatid=Trigger.new[i].Id,
                    whoid=Trigger.new[i].XContact__c,
                    OwnerId=Trigger.new[i].XOwner__c,
                    Subject='Call New Inquiry',
                    ActivityDate = Date.today()+7
            ));
        }
    
    }
    
    insert taskList;

 

Thanks for any insight you can provide!

I have a custom controller extension for a CampaignMember VF page that looks like:

 

public class landingSave {

public CampaignMember cm;
    
    public landingSave(ApexPages.StandardController stdController) {
        this.cm = (CampaignMember)stdController.getRecord();
    }

    
    public PageReference submit() {
   
        update cm;

        PageReference pageRef = new PageReference('http://www.someaddress.com');

    return pageRef;
  }

}

 My test class currently looks like:

 

@isTest
private class TestlandingSave{

static testMethod void mylandingSave() {


PageReference pageRef = Page.Discover;
Test.setCurrentPage(pageRef);

Lead l = new Lead(lastname='smith');
Campaign c = new Campaign(Name='test campaign');
CampaignMember cm = new CampaignMember(lead=l, campaign=c, status='sent');

ApexPages.StandardController sc = new ApexPages.StandardController(cm);
landingSave controller = new landingSave(sc);
	<!-- I THINK I'M MISSING SOMETHING HERE -->
cm.XEmail__c = 'acme@gmail.com';


String nextPage = controller.submit().getUrl();

System.assertEquals('http://www.someaddress.com', nextPage);

 }
}

 

Any pointers?!  Thanks :smileyhappy:

 

 

 

 

A couple of questions here:

 

1)  Does this URL Rewriter class look functional?  I thought I read that I didn't necessarily need the second generateURL function, but I'm not sure.

 

 

global with sharing class myRewriter implements Site.UrlRewriter {

String VIP_PAGE = '/VIP/';
String VIP_VISUALFORCE_PAGE = '/VIP?id=';

global PageReference mapRequestUrl(PageReference
myFriendlyUrl){
String url = myFriendlyUrl.getUrl();
if(url.startsWith(VIP_PAGE)){
String name = url.substring(VIP_PAGE.length(),
url.length());

Lead ld = [select id from Lead where XUniqueSearchId__c =:
name LIMIT 1];

return new PageReference(VIP_VISUALFORCE_PAGE + ld.id);
}

return null;
}

global List<PageReference> generateUrlFor(List<PageReference>
mySalesforceUrls){

return null;
}

}

 

 

2) What should the test class for this consist of?

 

Thank you in advance for any assistance you may be able to provide!

Despite much researching and reading, I'm not quite grasping the controller test class documentation or examples.  If anyone can help me get going with a test class for this, I would greatly appreciate it!

 

Controller:

 

public class newInquiryController {
   
   Account account;
   Contact contact;
   Inquiry_History__c inquiry;
    

   public Contact getContact() {
      if(contact == null) contact = new Contact();
      return contact;
   }
   
   public Inquiry_History__c getInquiry() {
      if(inquiry == null) inquiry = new Inquiry_History__c();
      return inquiry;
   }
    
    
   public PageReference step1() {
      return Page.newInquiryStep1;
   }

   public PageReference step2() {
      return Page.newInquiryStep2;
   } 
    
   public PageReference save() {
    
      if(inquiry.XCollege__c == 'SCA') {
      contact.XOrigin__c='a0Q80000000OVUH';
      }
      if(inquiry.XCollege__c == 'RSC') {
      contact.XOrigin__c='a0Q80000000OVWP';
      }
      if(inquiry.XCollege__c == 'SAW') {
      contact.XOrigin__c='a0Q80000000OVQv';
      }
      if(inquiry.XCollege__c == 'SGS') {
      contact.XOrigin__c='a0Q80000000OVSu';
      }
      contact.XAddress_Type__c='Mailing; Residence';
      insert contact;
      inquiry.XContact__c=contact.id;
      insert inquiry;

    
PageReference pageRef = new PageReference('http://www.returnurl.com/thankyou.php');

return pageRef;
   }

}

 

 

Page:

 

<apex:page controller="newInquiryController" showHeader="FALSE" sidebar="FALSE">
<apex:stylesheet value="{!$Resource.StyleSheet}"/>
<apex:form >
<table border="0" width="650px" cellspacing="0" align="center">

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>First Name</td>
<td width="65%"><apex:inputField id="contactFirstName" value="{!contact.firstName}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Last Name</td>
<td width="65%"><apex:inputField id="contactLastName" value="{!contact.lastName}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%" valign="top"><font color="red">*</font>Address</td>
<td width="65%"><apex:inputField id="contactAddress" value="{!contact.MailingStreet}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>City</td>
<td width="65%"><apex:inputField id="contactCity" value="{!contact.MailingCity}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>State</td>
<td width="65%"><apex:inputField id="contactState" value="{!contact.MailingState}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Zip Code</td>
<td width="65%"><apex:inputField id="contactZip" value="{!contact.MailingPostalCode}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%">Country</td>
<td width="65%"><apex:inputField id="contactCountry" value="{!contact.MailingCountry}"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%">Mobile Phone</td>
<td width="65%"><apex:inputField id="contactCel" value="{!contact.MobilePhone}"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%">Home Phone</td>
<td width="65%"><apex:inputField id="contactHomePhone" value="{!contact.homePhone}"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Email</td>
<td width="65%"><apex:inputField id="contactEmail" value="{!contact.Email}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Gender</td>
<td width="65%"><apex:inputField id="contactGender" value="{!contact.TargetX_SRMb__Gender__c}" required="TRUE"/></td>
</tr>
<tr>
<td width="5%"></td>
<td width="30%">Birthdate <i>(mm/dd/yyyy)</i></td>
<td width="65%"><apex:inputField id="contactDOB" value="{!contact.Birthdate}"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Current/Most Recent School</td>
<td width="65%"><apex:inputField id="contactSchool" value="{!contact.AccountId}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%">Graduation Year</td>
<td width="65%"><apex:inputField id="contactGradYear" value="{!contact.TargetX_SRMb__Graduation_Year__c}"/></td>
</tr>

<tr height="25px">
<td width="5%"></td>
<td width="30%"></td>
<td width="65%"></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>College of Interest</td>
<td width="65%"><apex:inputField id="inquiryCollege" value="{!inquiry.XCollege__c}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Program</td>
<td width="65%"><apex:inputField id="inquiryMajor" value="{!inquiry.XAnticipated_Major__c}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Start Term</td>
<td width="65%"><apex:inputField id="inquiryStartTerm" value="{!inquiry.XStart_Term__c}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Start Year</td>
<td width="65%"><apex:inputField id="inquiryStartYear" value="{!inquiry.XStart_Year__c}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Entry Type</td>
<td width="65%"><apex:inputField id="inquiryStudentType" value="{!inquiry.XStudent_Type__c}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Intended Load</td>
<td width="65%"><apex:inputField id="inquiryEnrollmentStatus" value="{!inquiry.XAnticipated_Enrollment_Status__c}" required="TRUE"/></td>
</tr>

<tr>
<td width="5%"></td>
<td width="30%"><font color="red">*</font>Residency</td>
<td width="65%"><apex:inputField id="inquiryResidencyStatus" value="{!inquiry.XAnticipated_Housing__c}" required="TRUE"/></td>
</tr>

<tr height="25px">
<td width="5%"></td>
<td width="30%"></td>
<td width="65%" align="right" valign="bottom"><apex:commandButton action="{!step2}" value="Preview" styleClass="btn"/></td>
</tr>
</table>
  </apex:form>


<style type="text/css">
.datePicker, .datePicker .dateBar ,.datePicker .calBody, .datePicker .calDays, .datePicker .buttonBar, .dateFormat, .datePicker Select
{
visibility:hidden;
}
</style>

</apex:page>

 

Step 2 simply displays the data entered on the form and provides a "back" button to go back and edit the information and a "submit" button to execute the save() action.

 

Situation:  Picklist has 4 values and controls the values of other fields on the layout.  I am building a VF input page and only want to show 2 of the 4 values in the picklist but need to make sure it controls the dependent fields accordingly.


Is this possible?  What is the recommended blueprint?

 

Thanks!

I am looking to create a Visualforce page that will serve as a data collection form on our website.  The user will ultimately be creating a contact record (linked to an existing account via a lookup) and then several child records (inquiry history, extra curricular interests, family relationships, etc.)  I would like the user to have the ability to create more than one of any of these child records during this process.

 

Visual:

 

Contact (1)
--Inquiry History (1)
--Extra Curricular Interests (Many)
--Family Relationships (Many)
--Test Scores (Many)

 

1)  Is this feasible?

2) What technique is best suited for this type of action?

 

Hi Folks!

 

We are looking to link to files stored locally on our file server via a URL field on a custom object.

 

Thinking about how to do this securely, I initially thought about configuring the directory to only allow external connections from the salesforce domain.  Our network admin brought up the possibility of IP spoofing which would then give access to our files (containing sensitive data).

 

What other security measures / features can you think of that would help us make this secure?

 

I have a visualforce page with a custom controller hosted on Sites.  The page creates a contact record and several other custom object records simultaneously.  In order to link the contact to an account, I have added the Account Lookup field from the contact object.

 

I have set the guest user profile to allow Read permissions on Accounts and also checked the field level security.  Everything looks okay, but when I go out onto the Site and attempt to use the lookup it complains about authentication.  Is it possible to get around this or is there another method I should be considering?

Still learning the ropes here and probably have some very ill formed code - so, any help/advice is greatly appreciated.

 

Here is the scenario of what I am trying to accomplish:

 

We have two custom objects (related via lookup field on Essay object):  Applications & Essays.  I have created a custom field on the Applications object called XEssays_On_File.  When an Essay record is added/updated, I would like the XEssays_On_File field to get updated with the number of related Essay Records. (Can't use rollup fields as this is not a master-detail relationship)

 

I have drafted the following code - which works for single situations - but fails mercilessly in bulk update:

 

trigger CountRelatedEssays on TargetX_SRMb__Essay__c (after insert, after update) {

        TargetX_SRMb__Essay__c [] ess = Trigger.new;
        String appid = null;
        appid = ess[0].TargetX_SRMb__Application__c;
       
        Integer i = [select count() from TargetX_SRMb__Essay__c where TargetX_SRMb__Application__c =     :appid];
       
        TargetX_SRMb__Application__c [] app =[select id, XEssays_On_File__c from TargetX_SRMb__Application__c where id = :appid];

        app[0].XEssays_On_File__c = i;   
       
        update app[0];
       

}

 

I would also like this to fire and update on Delete as well.

 

Thanks in advance for any help you can provide!

I have a custom object called Zip_Table that holds Zip Code specific information.  Is it possible to set a trigger on so that when a contact record is saved, it pulls the information related to their Zip Code into some custom fields on the Contact layout?

 

Any help is appreciated.  Thanks! 

We are using JS remoting. Found this interesting race condition:

  1. JS Remoting AJAX request made by user.
  2. Before it completes the user moves to another page
  3. When user moves browser to another page the js remoting ajax request is aborted.
  4. The abort invokes the error handler and we have a generic error handler which pops up a dialog showing exception info.
  5. In some cases, the dialog will flash up for a second because the page navigation away hasn't completed.

This looks ugly and we would prefer if the error handler knew there was a page unload happening and not show the error dialog if this was happening.

So, I tried adding a page unload listener and setting a flag in that which can be subsequently checked.

jQuery(window).unload(function() {
    unloadhappening = true;
});

This approach will work in most ajax designs but won't with JS remoting. JS remoting, calls the error handler before the unload event. Not sure why?

I tried the earlier beforeunload event:

jQuery(window).on('beforeunload', function() {
    unloadhappening = true;
    return '';  
}); 

This won't work because this event just shows up another dialog.

So I tried to add a listener to all anchor tags that have a http(s) hyperlink

jQuery('a[href^=http]').click( function() {
    unloadhappening = true; 
})

This won't work for relative URLs.

So I tried to adding a listener to all anchor tags that have a href

jQuery('a[href]').click( function() {
    unloadhappening = true; 
})

This will filter out components that won't work because it won't filter out components that don't trigger a page unload such as:

   <a href="#adviceTab">Advice</a>

So before I go and write a selector to filter out anything with a fragment identifier, there are also some anchors that are coming form JQuery UI that do:

   <a href="javascript&colon;%20void%280%29%3B" class="calToday"    onclick="DatePicker.datePicker.selectDate('today');return false;">Today</a>

I am starting to think this is a more of a hack that will never work as opposed to a solution. Do you have a good idea for this problem?

The only idea I can think of is to check the exception, error, event info returned by JS remoting for an aborted request. I see: Strings:

Unable to connect with Server 

and

Communication Failure

But they might be also used in another error that has nothing to do with a page unload. So wondering has anyone else seen this and if so what is your solution?

Note I have to use JS Remoting. Using forceTK etc is not an option.

Thanks

I am in the process of converting one of my VF pages to a component so that it can be easily reused across objects.

 

In my VF page I implement a standard controller with an extension class.  The constructor of my extension class pulls in the record from the standard controller so I can perform some describe methods on it:

 

public myControllerExtension(ApexPages.StandardController controller) {
        
        Schema.DescribeSObjectResult objDescribe = controller.getRecord().getSObjectType().getDescribe();
        ...
}

What is the best way to replicate this in the component controller?  I'm aware that the component controller does not have access to the standard controller, with the exception of using attributes to pass some information in.  Are attributes the right way to go?  Would I use an extension class in my page to generate the necessary values to assign to my controller attributes?

 

Thanks in advance for your assistance!

Oh this seems so simple, yet I'm stuck!

 

Here's what I have now in my controller:

    public date d {
        get{
            d = date.today();
            return d;
            }
            set;
       }
    
    
    public List<event> all {
    get {
    all = [select subject, activitydate, location from Event where activitydate = :d Order By location ASC];
    return all;
    }
    set;
    }

 

All is peachy and the page loads up Today()'s info just fine.

 

Now, what I really want to do is load up the page initially with today's date and resulting info, but also have a button called "Next" that will add 1 day to the current date and update an outputPanel on my page with the new query results when clicked.

 

I know I need to add a function for the button action, but I'm not sure how to change the code above to manipulate the date variable accordingly.

 

Thanks in advance for any help you might provide!

Hi Folks,


I have a custom child object of Contact called Inquiry_History__c.  I developed a trigger so that whenever an inquiry history record is created that meets certain criteria, a task is created and assigned to the user specified in the inquiry history custom "Owner" field (a lookup to USER, automatically assigned via workflow upon creation).

 

Everything works as anticipated when adding records the good 'ole fashioned way.  However, I have a form hosted on VF sites that creates a Contact and associated inquiry history record that is now flashing the "Authorization Required' page on submit.

 

Where should I begin to look for the cause of this?  I'm not sure how I can debug this process to figure out why the webform is being halted.

 

Trigger:

 

trigger callInquiry on Inquiry_History__c (after insert) {

List<Task> taskList = new List<Task>();

    for (Integer i=0; i<trigger.new.size(); i++) {
    
        if(
        (Trigger.new[i].XStudent_Type__c == 'FF') && 
        ((Trigger.new[i].XCollege__c == 'RSC') || (Trigger.new[i].XCollege__c == 'SCA'))) {
            taskList.add(
                new Task(
                    whatid=Trigger.new[i].Id,
                    whoid=Trigger.new[i].XContact__c,
                    OwnerId=Trigger.new[i].XOwner__c,
                    Subject='Call New Inquiry',
                    ActivityDate = Date.today()+7
            ));
        }
    
    }
    
    insert taskList;

 

Thanks for any insight you can provide!

I currently set up our custom buttons with

 

https://na8.salesforce.com/a0C/e? 

 

When I go into the sandbox I have to modify the intance number. Someone told me you can exclude the instance so you don't have to modify sandbox custom buttons.

 

What is the short cut?

  • October 21, 2011
  • Like
  • 0

I have a custom controller extension for a CampaignMember VF page that looks like:

 

public class landingSave {

public CampaignMember cm;
    
    public landingSave(ApexPages.StandardController stdController) {
        this.cm = (CampaignMember)stdController.getRecord();
    }

    
    public PageReference submit() {
   
        update cm;

        PageReference pageRef = new PageReference('http://www.someaddress.com');

    return pageRef;
  }

}

 My test class currently looks like:

 

@isTest
private class TestlandingSave{

static testMethod void mylandingSave() {


PageReference pageRef = Page.Discover;
Test.setCurrentPage(pageRef);

Lead l = new Lead(lastname='smith');
Campaign c = new Campaign(Name='test campaign');
CampaignMember cm = new CampaignMember(lead=l, campaign=c, status='sent');

ApexPages.StandardController sc = new ApexPages.StandardController(cm);
landingSave controller = new landingSave(sc);
	<!-- I THINK I'M MISSING SOMETHING HERE -->
cm.XEmail__c = 'acme@gmail.com';


String nextPage = controller.submit().getUrl();

System.assertEquals('http://www.someaddress.com', nextPage);

 }
}

 

Any pointers?!  Thanks :smileyhappy:

 

 

 

 

A couple of questions here:

 

1)  Does this URL Rewriter class look functional?  I thought I read that I didn't necessarily need the second generateURL function, but I'm not sure.

 

 

global with sharing class myRewriter implements Site.UrlRewriter {

String VIP_PAGE = '/VIP/';
String VIP_VISUALFORCE_PAGE = '/VIP?id=';

global PageReference mapRequestUrl(PageReference
myFriendlyUrl){
String url = myFriendlyUrl.getUrl();
if(url.startsWith(VIP_PAGE)){
String name = url.substring(VIP_PAGE.length(),
url.length());

Lead ld = [select id from Lead where XUniqueSearchId__c =:
name LIMIT 1];

return new PageReference(VIP_VISUALFORCE_PAGE + ld.id);
}

return null;
}

global List<PageReference> generateUrlFor(List<PageReference>
mySalesforceUrls){

return null;
}

}

 

 

2) What should the test class for this consist of?

 

Thank you in advance for any assistance you may be able to provide!

I am looking to create a Visualforce page that will serve as a data collection form on our website.  The user will ultimately be creating a contact record (linked to an existing account via a lookup) and then several child records (inquiry history, extra curricular interests, family relationships, etc.)  I would like the user to have the ability to create more than one of any of these child records during this process.

 

Visual:

 

Contact (1)
--Inquiry History (1)
--Extra Curricular Interests (Many)
--Family Relationships (Many)
--Test Scores (Many)

 

1)  Is this feasible?

2) What technique is best suited for this type of action?

 

 Has anyone used  the Lightbox Visualforce component provided by force.com labs to call a visualforce page

 

The link for the App on Appexchage is 

 

http://sites.force.com/appexchange/apex/listingDetail?listingId=a0N30000001g3u0EAA

 

 This is a free app which has a visual force component <c:lightbox>

 

I want to show some visuaforce code in it. 

 

 

thanks