function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shambavishambavi 

please help me on this...

Please create a Custom List View Button "New Case" that will pre-populate the Contact, Account, Email, based on the current logged in User if the User is external (community profile) and use the standard functionality if he is not
The contact field should be updated with $User.ContactID if the Record Type is Case from Communities


Thanks in Advance.......


Thanks & Regards
Gopal. 
Best Answer chosen by shambavi
Paras_BhattParas_Bhatt

Hi Gopal,

The solution is listed below.

Step1: Create Custom list view button with JAVA Script

var url = parent.location.href;
window.location.href ='/apex/CaseCreateNew?retURL='+url;


Step 2: Create a VF Page with controller and 1 redirection method that will be called on page load

<apex:page controller="redirectTest" action="{!redirect}" > </apex:page>
 

Step 3: Define custom redirection in your with prepopulatedFields

 

 public PageReference redirect() {

         retURL= ApexPages.currentPage().getParameters().get('retURL');

         //GET Current user detailas and gather all the required fields need to be prepopulated

         if(Your_Condition){
          /* Pre populate the fields */
                 return new PageReference('/500/e?retURL='+retURL+&def_contact_id=0032800000Bspze&def_account_id=0012800000EKNzT');

         }else{ /* default create new page */
                 return new PageReference('/500/e?retURL='+retURL);
         }
    }

 

P.S: This can be done using JavaScript button as well, however using controller you will get more flexibility.

 

Please mark it, if it helps you.

Thanks and Regards,

Paras Bhatt

 

All Answers

Paras_BhattParas_Bhatt

Hi Gopal,

The solution is listed below.

Step1: Create Custom list view button with JAVA Script

var url = parent.location.href;
window.location.href ='/apex/CaseCreateNew?retURL='+url;


Step 2: Create a VF Page with controller and 1 redirection method that will be called on page load

<apex:page controller="redirectTest" action="{!redirect}" > </apex:page>
 

Step 3: Define custom redirection in your with prepopulatedFields

 

 public PageReference redirect() {

         retURL= ApexPages.currentPage().getParameters().get('retURL');

         //GET Current user detailas and gather all the required fields need to be prepopulated

         if(Your_Condition){
          /* Pre populate the fields */
                 return new PageReference('/500/e?retURL='+retURL+&def_contact_id=0032800000Bspze&def_account_id=0012800000EKNzT');

         }else{ /* default create new page */
                 return new PageReference('/500/e?retURL='+retURL);
         }
    }

 

P.S: This can be done using JavaScript button as well, however using controller you will get more flexibility.

 

Please mark it, if it helps you.

Thanks and Regards,

Paras Bhatt

 

This was selected as the best answer
shambavishambavi
Hello Paras Bhatt,

Thank you for given reply, if passible could please share the code. Give me mis call on this number +91 9739969134.

Thanks & Regards 
Gopal M.