• nununi
  • NEWBIE
  • 120 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 21
    Replies

Hello everyone,

I have apex based sharing rules setup as follows. When a user, creates a record in Object A, that record is shared with a public group based on a value in a look up field. 

Example:
If the record created looks up to master-record 1, it shares to public group 1
If the record created looks up to master-record 2, it shares to public group 2
and so on..

This works perfectly as long as the record is created by INTERNAL users.

Now I have a community setup with all my external users using the customer community login license type. When they create a record in the same object A, the above mentioned apex sharing code does not work. 

I have already checked the following:

  • They have the concerned apex classes enabled for their profiles
  • The apex classes are using ythe 'Without Sharing' keyword
Any help would be greatly appreciated!
  • September 29, 2016
  • Like
  • 0
The following formula is shoing an error. 
DATE( 
YEAR(CurrentEndDate__c + GracePeriod__c ),
(MONTH(CurrentEndDate__c + GracePeriod__c)+1), 
(1) 
)-1

CurrentEndDate__c = 11/30/2015
GracePeriod__c = 30

Please help!
  • December 09, 2015
  • Like
  • 0
Hello evryone,

I am trying to add a parent record (CFAMN2__Society_Onboarding__c) and multiple child records (CFAMN2__Onboarding_GL_Accounts__c) through a single VF page. As soon as the VF page loads it needs to show the related child records as well. The users need to ability to add a row to enter as many child records as they want. I am stuck at a point where I am not able to show the related child records nor am I able to save the related child records. Your help is highly appreciated. Thanks!

Controller:
public class SocietyOnboardingController {

    public string societyName     {get; set;}
    public string currencyCode    {get; set;}
    public string cfaId           {get; set;}
    public string socId           {get; set;}
    public string socUrl          {get; set;}
    public string socEmail        {get; set;}
    public string socPhone        {get; set;}
    public string socAddr         {get; set;}
    public string glDescrp        {get; set;}
    public string glRepCat        {get; set;}
    public string glType          {get; set;}
    public string glDetail        {get; set;}
    public id glSocOnb            {get; set;}
    
    public CFAMN2__Society_Onboarding__c socOnb                  {get; set;}
    public CFAMN2__Onboarding_GL_Accounts__c glAcc               {get; set;}
    public list<CFAMN2__Onboarding_GL_Accounts__c> listglAcc     {get; set;}
    
    private string socOnbId = '';
    
    public SocietyOnboardingController(ApexPages.StandardController Controller) {
    
        List<CFAMN2__Society_Onboarding__c> socOnbList = new List<CFAMN2__Society_Onboarding__c>();
        socOnbId = System.currentPageReference().getParameters().get('Id');
        glSocOnb = System.currentPageReference().getParameters().get('Id');
        socOnbList = [SELECT Id,
                             Name,
                             CurrencyIsoCode,
                             CFAMN2__CFA_Org_ID__c,
                             CFAMN2__CFA_Society_Id__c,
                             CFAMN2__Email__c,
                             CFAMN2__Mailing_Addess__c,
                             CFAMN2__Phone__c,
                             CFAMN2__Society_Homepage_URL__c
                      FROM CFAMN2__Society_Onboarding__c
                      WHERE Id = :socOnbId];
                  
         if(socOnbList.isEmpty() == false) {
             socOnb = socOnbList[0];
             societyName = socOnb.Name;
             currencyCode = socOnb.CurrencyIsoCode;
             socId = socOnb.CFAMN2__CFA_Society_Id__c;
             cfaId = socOnb.CFAMN2__CFA_Org_ID__c;
             socUrl = socOnb.CFAMN2__Society_Homepage_URL__c;
             socEmail = socOnb.CFAMN2__Email__c;
             socPhone = socOnb.CFAMN2__Phone__c;
             socAddr = socOnb.CFAMN2__Mailing_Addess__c;
         } else {
             ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'This record is invalid or has already been submitted');
             ApexPages.addMessage(msg);
         }
         
         
         List<CFAMN2__Onboarding_GL_Accounts__c> listglAcc = new List<CFAMN2__Onboarding_GL_Accounts__c>();
         listglAcc = [SELECT Id,
                             Name,
                             CFAMN2__Report_Category__c,
                             CFAMN2__Detail__c,
                             CFAMN2__Type__c,
                             CFAMN2__Society_Onboarding__c
                             FROM CFAMN2__Onboarding_GL_Accounts__c
                             WHERE CFAMN2__Society_Onboarding__c = :socOnbId];
                             
         if(listglAcc.isEmpty() == false) {
             glSocOnb = socOnb.Id;
             glDescrp = glAcc.Name;
             glRepCat = glAcc.CFAMN2__Report_Category__c;
             glType = glAcc.CFAMN2__Type__c;
             glDetail = glAcc.CFAMN2__Detail__c;
         } 
         
         
     
     }
     
     public pageReference saveOnly(){
             socOnb.Name = societyName;
             socOnb.CurrencyIsoCode = currencyCode; 
             socOnb.CFAMN2__CFA_Society_Id__c = socId;
             socOnb.CFAMN2__CFA_Org_ID__c = cfaId;
             socOnb.CFAMN2__Society_Homepage_URL__c = socUrl;
             socOnb.CFAMN2__Email__c = socEmail;
             socOnb.CFAMN2__Phone__c = socPhone;
             socOnb.CFAMN2__Mailing_Addess__c = socAddr;
             upsert socOnb;
             glAcc.CFAMN2__Society_Onboarding__c = socOnb.Id;
             glAcc.Name = glDescrp;
             glAcc.CFAMN2__Report_Category__c = glRepCat;
             glAcc.CFAMN2__Type__c = glType;
             glAcc.CFAMN2__Detail__c = glDetail;
             upsert glAcc;
         
     return returnToOrigination();
     }
     
     Public void addAccount() {
        CFAMN2__Onboarding_GL_Accounts__c gl = new CFAMN2__Onboarding_GL_Accounts__c();
        listglAcc.add(gl);
    }
     
     private pageReference returnToOrigination(){
         pageReference page = new pageReference('/a1n');
         page.setRedirect(true);
         return page;
     }
    
}

VF Page:
<apex:page sidebar="false" standardController="Society_Onboarding__c" extensions="SocietyOnboardingController">
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

    <ul id="myTab" class="nav nav-tabs">  
        <li class="active">
            <a href="#tab1" data-toggle="tab">General Information</a>
        </li>
        <li>
            <a href="#tab2" data-toggle="tab">Contact information</a>
        </li>
        <li>
            <a href="#tab3" data-toggle="tab">GL Accounts</a>
        </li>
        <li>
            <a href="#tab4" data-toggle="tab">Payment Terms</a>
        </li>
    </ul>  
    <apex:form id="theForm">
        <div id="myTabContent" class="tab-content">  
            <div class="tab-pane fade in active" id="tab1">
                <p>
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div class="form-horizontal">                                  
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">Society Name</label>
                                    <div class="col-xs-5">
                                        <apex:inputText value="{!societyName}" styleClass="form-control"/>
                                    </div>
                                </div>                         
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">Currency</label>
                                    <div class="col-xs-5">
                                        <apex:inputField value="{!Society_Onboarding__c.CurrencyIsoCode}" styleClass="form-control"/> 
                                    </div>
                                </div>                      
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">CFA Org Id</label>
                                    <div class="col-xs-5">
                                        <apex:inputText value="{!cfaId}" styleClass="form-control"/>
                                    </div>
                                </div>                     
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">CFA Society Id</label>
                                    <div class="col-xs-5">
                                        <apex:inputText value="{!socId}" styleClass="form-control"/>
                                    </div>
                                </div>                        
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">Society Homepage URL</label>
                                    <div class="col-xs-5">
                                        <apex:inputText value="{!socUrl}" styleClass="form-control"/>
                                    </div>
                                </div>                
                            </div>
                        </div>
                    </div>
                </p>
            </div>
            <div class="tab-pane fade" id="tab2">
                <p>
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div class="form-horizontal">                                  
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">Email</label>
                                    <div class="col-xs-5">
                                        <apex:inputText value="{!socEmail}" styleClass="form-control"/>
                                    </div>
                                </div>                         
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">Phone</label>
                                    <div class="col-xs-5">
                                        <apex:inputText value="{!socPhone}" styleClass="form-control"/>
                                    </div>
                                </div>                      
                                <div class="form-group">
                                    <label class="control-label col-xs-3 required-icon true">Mailing Address</label>
                                    <div class="col-xs-5">
                                        <apex:inputTextArea value="{!socAddr}" styleClass="form-control" rows="4"/>
                                    </div>
                                </div>                                     
                            </div>
                        </div>
                    </div>  
                </p>
            </div>
            <div class="tab-pane fade" id="tab3">
                <p>
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div class="form-vertical;">                                  
                                <div class="form-group">
                                    <label class="control-label col-xs-1 required-icon true">Description</label>
                                    <div class="col-xs-2">
                                        <apex:inputText value="{!glDescrp}" styleClass="form-control"/>
                                    </div>
                                </div>                         
                                <div class="form-group">
                                    <label class="control-label col-xs-1 required-icon true">Report Category</label>
                                    <div class="col-xs-2">
                                        <apex:inputText value="{!glRepCat}" styleClass="form-control"/>
                                    </div>
                                </div>                      
                                <div class="form-group">
                                    <label class="control-label col-xs-1 required-icon true">Type</label>
                                    <div class="col-xs-2">
                                        <apex:inputText value="{!glType}" styleClass="form-control"/>
                                    </div>
                                </div>  
                                <div class="form-group">
                                    <label class="control-label col-xs-1 required-icon true">Detail</label>
                                    <div class="col-xs-2">
                                        <apex:inputText value="{!glDetail}" styleClass="form-control"/>
                                    </div>
                                </div>  
                                <apex:commandButton value="Add New GL Account" action="{!addAccount}"/>                                   
                            </div>
                        </div>
                    </div>      
                </p>
            </div>
        </div>  
        <div class="text-center">
            <apex:commandButton value=" Save and Continue Later" action="{!SaveOnly}" styleClass="btn btn-primary btn-lg"/>
            <apex:commandButton Value="Submit" action="{!Save}" styleClass="btn btn-primary btn-lg"/> 
            <apex:commandButton value="Cancel" action="{!Cancel}" styleClass="btn btn-primary btn-lg"/> 
        </div>
    </apex:form>
</apex:page>

 
  • November 17, 2015
  • Like
  • 0
Hi, I am trying to copy data from Lead to a custom object using javascript button. When a lead rich text field contains line spaces, it gives me an error. So i used URLencode which resolves the error but the spaces are substituted with '+'. Is there a way to copy the text as is (including line spaces)?
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 


var p1 = new sforce.SObject("Place__c"); 
p1.Name = '{!Lead.Place_1__c}';
p1.Place_Text__c = '{!URLENCODE(Lead.Place_1_About__c)}';


var result = sforce.connection.create([p1]);


if(result[0].getBoolean("success")){
   alert('New record updated successfully');
}
else{
  alert('Error : '+result);
}

example:
Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro v v v vPlace 1 Intro Place 1 IntroPlace 1.

Intro Place 1 Intro Place 1 Intro. Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro v v Place 1 Intro

gets converted to

Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+v+v+v+vPlace+1+Intro+Place+1+IntroPlace+1.%3Cbr%3E%3Cbr%3EIntro+Place+1+Intro+Place+1+Intro.%C2%A0Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+v+v+Place+1+Intro
  • August 12, 2015
  • Like
  • 0
I have a requirement to create a button on the lead object that creates two custom object records with fields pre-opulated from the Lead record. Can someone provide me a sample code to start with? 
  • August 11, 2015
  • Like
  • 0
Hello developers,

I have a text field test__c on an object TestObject__c. This filed has values seperated by commas (a,b,c,d). In my apex class, I would like to pass these values into a list TestList. Can someone please provide me with the correct syntax?

Thanks!
  • January 21, 2015
  • Like
  • 0
How do I share an account record (and associated contacts), so that it is available to external customer community users? The account record will be owned by an Internal user. 

This is basically for a VF page in my customer community where there is a contact lookup field. The external users have to select contacts accociated with a particular account "ABC" only. I have put in a lookup filter, but it is only working for the internal users. The external users are not able to see anything, most probably because they do not have access to he "ABC" account record. Please help!!!
  • December 26, 2014
  • Like
  • 0
Hello everyone,

I am trying trying to display the list of contacts associated with a certain account in a picklist. And then display the selected value on an apex datalist on the same visualforce page after clicking a button. Here is the relevant code (I left out all the unnecessary part):
public without sharing class AccountExt {

public String selectedConId{get;set;}

public AccountExt(ApexPages.StandardController Controller) {

}

public List<SelectOption> getContactNames() {
                  List<SelectOption> ConOptions= new List<SelectOption>();
                  ConOptions.add( new SelectOption('','--Select--'));
                  for( Contact Con : [select Id,name from Contact where Accountid =: '001r0000002atum' ] ) {
                          ConOptions.add(new SelectOption(Con.Id,Con.name)); 
                  }
                 return ConOptions;
           }

Public void addSECCon(){
        listSECCon.add(SECCon);
        SECCon = new SEC_Contract__c();
        SECCon.Vendor_Name__c = accnt.id;

        }

}

And the VF code:
<apex:outputpanel id="addanother3">
                <apex:pageBlockSection columns="3" rendered="{!account.Previous_SEC_Contracts__c == 'Yes'}">                    
                     <apex:pageBlockSectionItem >
                         <apex:outputLabel >Contract Number</apex:outputLabel>
                         <apex:inputField value="{!SECCon.Contract_Number__c}"/>
                     </apex:pageBlockSectionItem>
                     <apex:pageBlockSectionItem >
                         <apex:outputLabel >Name</apex:outputLabel>
                         <apex:selectList value="{!selectedConId}" size="1">
                                               <apex:selectOptions value="{!ContactNames}" />
                         </apex:selectList>
                     </apex:pageBlockSectionItem>
                     <apex:pageBlockSectionItem > 
                         <apex:commandButton value="Add" action="{!addSECCon}"  reRender="addanother3"/>
                     </apex:pageBlockSectionItem>     
                </apex:pageBlockSection>                         
    
                <apex:pageBlockTable value="{!listSECCon}" var="sc" rendered="{!account.Previous_SEC_Contracts__c == 'Yes'}">
                <apex:column headerValue="Previous SEC Contract Number">
                <apex:outputField value="{!sc.Contract_Number__c}"/>
                </apex:column>
                <apex:column headerValue="Name">
                <apex:dataList value="{!selectedConId}" var="c">{!c}</apex:dataList>
                </apex:column>
                </apex:pageBlockTable>
            </apex:outputpanel>

I got the first part where I need to display all contacts in a picklist, but not able to show the names on the apex:datalist. Instead it is showing the record Ids. Can you show me how to display the names instead?
  • December 22, 2014
  • Like
  • 0
I have built a VF page to show a bunch of account fields. The record id is pulled from the logged in user details. The fields all work fine and the page shows the correct record. Now, I need to show a few related lists at the bottom. The apex code for the bottom part is:
<apex:pageBlock title="Previous Contracts">
     <apex:relatedList list="Contract_Vehicles__r" subject="{!$CurrentPage.parameters.Id}" id="ContractVehicles">
     </apex:relatedList>
     <apex:relatedList list="Previous_Federal_Contracts__r" subject="{!$CurrentPage.parameters.Id}" id="FedContracts">
     </apex:relatedList>
     <apex:relatedList list="SEC_Contracts1__r" subject="{!$CurrentPage.parameters.Id}" id="SECContracts">
     </apex:relatedList>
     </apex:pageBlock>
     <apex:relatedList list="Contacts" subject="{!$CurrentPage.parameters.Id}" id="Contact" >     
     </apex:relatedList>
     <apex:relatedList list="Company_Documents__r" subject="{!$CurrentPage.parameters.Id}" id="CompDocs">
     </apex:relatedList>

And my controller is as follows:
public class myAccountController{

    public Account Account{get; set;}
    public List<Contact> Contact{get; set;}

    public myAccountController() {
        
        String uid = UserInfo.getUserId();
        String Accid = [SELECT accountid FROM User WHERE id =: uid LIMIT 1].accountid;
        if(Accid != NULL){
        Account = [SELECT Id, Name, Fax, Phone, ShippingStreet, ShippingCity, ShippingState, ShippingPostalCode, ShippingAddress, ShippingCountry, Website,
                                 Agencies__c, Annual_Revenue__c, Business_Classification__c, 
                                 Contract__c, Contract_Number1__c, Contract_Number_2__c, Contract_Number_3__c,
                                 Contract_Number_4__c, Contract_Number_5__c, Contract_Vehicles__c, COR_Names__c,
                                 Dates_O__c, EIN__c, Intake_Question__c, Legal_Entity_Type__c, 
                                 MWOB_Status__c, NAICS_Code_Only__c, NAICS_Code__c, No_of_Employees__c, POC_First_Name__c,
                                 POC_Last_Name__c, Previous_Federal_Contracts__c, Previous_SEC_Contracts__c, SAM_Registry__c,
                                 SEC_Contract__c, Secondary_NAICS_Code__c, Year_Established__c, DUNS_Number__c    
                                 FROM Account WHERE Id =: Accid LIMIT 1];
                                 
        Contact = [SELECT id, Name, Email, Phone, Title FROM CONTACT where Accountid = : Accid];
                                 
        
        }
    }

    
    
    
    public PageReference save() {
        update Account ;
        return null;
    }
}

The related lists are not appearing on the page. Can someone please let me know what modification I need to make to the controller? 
  • December 12, 2014
  • Like
  • 0
Can you guys please tell me what I am doing wrong here? I am trying to render a field based on the value of another picklist field. Does not work.
<apex:page standardController="Event">
    <apex:form id="blue">
        <apex:sectionHeader title="Event"/> 
        <apex:pageblock id="pgblk" title="Event Information">
            <apex:pageBlockButtons location="both">
                <apex:commandButton value="Save" action="{!Save}"/>
                <apex:commandButton value="Cancel" action="{!Cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection id="pgBlockSectionEventInfo" title="Event Information" collapsible="false" columns="1" >
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>Date</apex:outputLabel>
                    <apex:inputField id="Date" value="{!Event.ActivityDate}" showDatePicker="true"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >                    
                    <apex:outputLabel>Contact Type</apex:outputLabel>
                    <apex:actionregion>
                    <apex:inputField id="Type" value="{!Event.Type}"/>
                    <apex:actionSupport event="onchange" rerender="output" />
                    </apex:actionregion> 
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="EventName">
                    <apex:outputLabel>Event Name</apex:outputLabel>
                    <apex:outputpanel id="output">
                    <apex:inputField id="Name" value="{!Event.Event_Name__c}" rendered="{!Event.Type == 'External Outreach Event'}"/>
                    </apex:outputpanel>
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel>Contact Person</apex:outputLabel>
                    <apex:inputField id="Person" value="{!Event.Contact_Person__c}"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
  • December 09, 2014
  • Like
  • 0
Hello Developers,
I need to write a schedulable apex class that sends email notifications to users who have not logged in the past 30 days. This is what I have so far but I am getting the error "Error: Compile Error: Method does not exist or incorrect signature: [Messaging.MassEmailMessage].setTargetObjectIds(LIST<User>) at line 12 column 17"

I am not sure where I am going wrong here.
global class NotifyUsers implements Schedulable {

global void execute(SchedulableContext ctx){

    dateTime dt = date.today()-30;    
    id sysAdm = [SELECT id from Profile where Name =: 'System Administrator' LIMIT 1].id;
    List <User> userList = [SELECT Name, Email, LastLoginDate, ISActive, Id From User WHERE IsActive = true AND LastLoginDate <: +dt AND Name != 'IRIS Help' AND ProfileId !=: sysAdm LIMIT 10000];
    
    if(userList.size() > 0)
        {
                Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
                mail.setTargetObjectIds(userList); // List of  ids of the contact, lead, or User
                mail.setTemplateId('00***********XU'); // Id of the email template
                Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
        }
   
}
}

 
  • November 05, 2014
  • Like
  • 0
Hello,
I am trying to write a schedulable apex class where emails are sent to users who have not logged in past 30 days. Here is what I have but I get the following error:
Error: Compile Error: Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setTargetObjectIds(LIST<User>) at line 14 column 17

global class Class implements Schedulable {

global void execute(SchedulableContext ctx){

    dateTime dt = date.today()-30;    
    id sysAdm = [SELECT id from Profile where Name =: 'System Administrator' LIMIT 1].id;
    List <User> userList = [SELECT Name, Email, LastLoginDate, ISActive, Id From User WHERE IsActive = true AND LastLoginDate <: +dt AND ProfileId !=: sysAdm LIMIT 10000];
    
    if(userList.size() > 0)
        {
            for(User usr : userList)
            {
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTargetObjectIds(userList); // List of  ids of the contact, lead, or User
                mail.setTemplateId('00***********XU'); // Id of the email template
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            }
        }
    update userList;
}
}
  • November 05, 2014
  • Like
  • 0
Hello Evryone,
I am trying to render two sections based on two checkbox values. If Export is TRUE then show Sample1 and in Import is TRUE then show Sample 2.

VF Page:
<apex:page standardcontroller="Opportunity" tabStyle="Opportunity" extensions="OppExt">
  <apex:form >
      <apex:pageBlock title="Opportunity Edit">
       <apex:pageBlockButtons >
        <apex:commandButton action="{!getcontinue}" value="continue"/>
        <apex:commandButton action="{!Cancel}" value="Cancel"/>
       </apex:pageBlockButtons>
       
       <apex:pageBlockSection id="block" title="Service Type Field Information" columns="2" >
             <apex:inputField value="{!Opportunity.Export_ck__c}">
                  <apex:actionsupport event="onclick" rerender="Sample1" status="AjaxStatus1"/>
             </apex:inputField>
             <apex:inputField value="{!Opportunity.Import_ck__c}">
                  <apex:actionsupport event="onclick" rerender="Sample2" status="AjaxStatus2"/>
             </apex:inputField>
         
       </apex:pageBlockSection> 
 
       <apex:pageBlockSection title="Opportunity Information" columns="2">
            <apex:outputField title="Opportunity Owner" value="{!Opportunity.OwnerId}"/>
            <apex:inputField required="true" value="{!Opportunity.Type}"/>
            <apex:inputField value="{!Opportunity.Name}"/>
            <apex:inputField value="{!Opportunity.LeadSource}"/>
            <apex:inputField value="{!Opportunity.AccountId}"/>
            <apex:inputField value="{!Opportunity.CloseDate}"/>
            <apex:inputField required="true" value="{!Opportunity.Priority__c}"/>
            <apex:inputField required="true" value="{!Opportunity.Lead_Source_Details_del__c}"/>
            <apex:inputField value="{!Opportunity.Contact__c}"/>
            <apex:inputField value="{!Opportunity.Mobile__c}"/>
        </apex:pageBlockSection>
        
        <apex:outputpanel id="Sample1">
        <apex:actionStatus id="AjaxStatus1">
               <apex:facet name="stop"> 
                 <apex:pageBlockSection title="Additional Information" columns="2" rendered="{!IF(Opportunity.Export_ck__c == true, true, false)}">
                    <apex:inputField required="true" value="{!Opportunity.NextStep}"/>
                    <apex:inputField required="true" value="{!Opportunity.Description}" />
                    <apex:inputField required="true" value="{!Opportunity.Followup_DateTime__c}"/>
                 </apex:pageBlockSection> 
               </apex:facet> 
        </apex:actionStatus> 
        </apex:outputpanel>  
        
        <apex:outputpanel id="Sample2">
        <apex:actionStatus id="AjaxStatus2">
              <apex:facet name="stop">
                <apex:pageBlockSection title="Other Information" columns="2" rendered="{!IF(Opportunity.Import_ck__c == true, true, false)}">
                    <apex:inputField required="false" value="{!Opportunity.Probability}" />
                    <apex:inputField value="{!Opportunity.Test_Month_Closed_Today_s_Month__c}"/>
                </apex:pageBlockSection> 
              </apex:facet>
        </apex:actionStatus> 
        </apex:outputpanel> 
         
      </apex:pageBlock>
  </apex:form>
</apex:page>

Controller:
public with sharing class OppExt {

    Public Opportunity opp {get;set;}
    
    Public Boolean Export_ck {get;set;}
    Public Boolean Import_ck {get;set;}
    
    Private ApexPages.StandardController sController;
    
    public OppExt(ApexPages.StandardController controller) 
    {
        this.opp=(Opportunity)Controller.getRecord();
        sController=controller;
        
    }
    Id DomesticRecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Domestic').getRecordTypeId();
    public PageReference getcontinue()
    {
    
      sController.save();
      
     PageReference pr = new PageReference('/006/e?retURL=%2F006%2Fo&RecordType='+DomesticRecordTypeId+'&ent=Opportunity');  
     pr.setRedirect(true);
     return pr;
    }

}


  • October 15, 2014
  • Like
  • 0
Hello,

We had a site.com site who's URL was oursite.com. The BL wanted www.oursite.com as well which was not working (refirecting to the SF site).
Under the domains section of our org, we had a domain oursite.com. We modifed it to www.oursite.com and it saved without any errors. A few days later we noticed that www.oursite.com started working but now oursite.com was not. It was being redirected to the salesforce.com site.

When we try to change the domain back to oursite.com or try to create a new domain called oursite.com we get the follwoing error:

Salesforce.com can't validate the domain. The CNAME record may still be processing (which can take up to 24 hours), or the domain may not belong to you. Make sure the domain name oursite.com uses oursite.com.[ORG ID].live.siteforce.com as its CNAME target and try again later. It presently uses oursite.com.live.siteforce.com as the CNAME target, which does not equal the expected value.

We changed the CNAME of the domain oursite.com to the value salesforce was asking for in the error. But it still throws the same error. SF support has been working on it but have not found a solution yet. Any help would be highly appreciated. 
  • August 20, 2014
  • Like
  • 0
Hello! I would like to display my account records on a VF page in the following JSON format. I need help with the class and the VF page. Thanks a bunch!
[
    {
        "AccountId": 1,
        "AccountName": "account1",
        "AddressBook": [
            {
                "Id": 1,
                "Name": "test",
                "Attn": "test",
    "StreetName": "test",
                "CityName": "test",
                "State": "TT",
                "PostCode": 89098,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 2,
                "Name": "test2",
                "Attn": "test2",
    "StreetName": "test2",
                "CityName": "test2",
                "State": "TU",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            
        ]
    },
    {
        "AccountId": 2,
        "AccountName": "Account2",
        "AddressBook": [
            {
                "Id": 1,
                "Name": "Test3",
                "Attn": "Test3",
    "StreetName": "Test3",
                "CityName": "Test3",
                "State": "TI",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 2,
                "Name": "Test4",
                "Attn": "Test4",
    "StreetName": "Test4",
                "CityName": "Test4",
                "State": "TO",
                "PostCode": 75000,
                "Tel": "(000)- 000-0000",
                "Favorite": false,
                "AccountId": 1
            },
            
        ]
    },
    
]
I am trying to serialize my account object to a JSON format which needs to be something like this:
[
    {
        "AccountId": 1,
        "AccountName": "Dixit company account",
        "AddressBook": [
            {
                "Id": 1,
                "Name": "John Smith",
                "Attn": "Name",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 2,
                "Name": "Samantha Parker",
                "Attn": "Name",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 3,
                "Name": "Cameron Adams",
                "Attn": "Name",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": false,
                "AccountId": 1
            }
        ]
    },
    {
        "AccountId": 2,
        "AccountName": "Diageo account",
        "AddressBook": [
            {
                "Id": 1,
                "Name": "Lee Fong",
                "Attn": "LF",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 2,
                "Name": "Robert Dujardin",
                "Attn": "Name",
    "StreetName": "123/12 King St",
                "CityName": "Paris",
                "State": "Ile",
                "PostCode": 75000,
                "Tel": "(000)- 000-0000",
                "Favorite": false,
                "AccountId": 1
            },
            {
                "Id": 3,
                "Name": "Pavlia Rokaski",
                "Attn": "Pav",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": false,
                "AccountId": 1
            }
        ]
    },
    {
        "AccountId": 4,
        "AccountName": "Personal",
        "AddressBook": [
            {
                "Id": 1,
                "Name": "Marc Samson",
                "Attn": "Name",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 2,
                "Name": "Francis Maher",
                "Attn": "Name",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 3,
                "Name": "Fanny Emerson",
                "Attn": "Name",
    "StreetName": "123/12 King St",
                "CityName": "Melbourne",
                "State": "VIC",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": false,
                "AccountId": 1
            }
        ]
    }
]
I am trying to create a custom delete button on an objectA which deletes the particular record only if the value in fieldA matches the Role of the logged in user. If it does not match it needs to throw an error. I was trying to use 'OnClick javascript". Can anyone help me wit the code? Thanks!
I am trying to create a custom delete button on an objectA which deletes the particular record only if the value in fieldA matches the Role of the logged in user. If it does not match it needs to throw an error. I was trying to use 'OnClick javascript". Can anyone help me wit the code? Thanks!
I am trying to create a custom delete button on an objectA which deletes the particular record only if the value in fieldA matches the Role of the logged in user. If it does not match it needs to throw an error. I was trying to use 'OnClick javascript". Can anyone help me wit the code? Thanks!

I am trying to write an apex test class for the following trigger

 

Trigger updateParentAccountName on Contact(before insert, before update){

List<Id> idList = new List<Id>();

for(Contact con : trigger.new ){
    if(con.AccountId != '001Q000000b32BD'){
        idList.add(con.AccountId);
        Map<Id,Account>accMap = new Map<Id,Account>([select ParentId from Account where id in:idList]);
        con.Parent_Account__c = accMap.get(con.AccountId).ParentId;
        }
    }
}

 

this is what i came up with so far:

 

@isTest
private class TestUpdateParentaccountName
{
  static testMethod void mytest()
  {
    //Create the 2 different categories the contact name may fall in

    List<Contact> testContacts = new List<Contact>();
    Contact testCase = new Contact();
    testCase.LastName = 'test1';
    testCase.AccountId = '001Q000000agMR5';
    testCase.RPCD_Functional_Area__c = 'General';
Test.startTest();
 insert testCase;
    testCase.Parent_Account__c = 'Department of Health and Human Services';
    update testCase;
 Test.stopTest();
Contact ct=[select  Parent_Account__c from Contact where id =: testCase.Id];
system.assert(ct.Parent_Account__c =='Department of Health and Human Services', ' Parent not changed');
    }
}

 

I get 100% code coverage but the test method fails. This is the error that i get

 

Time Started2/13/2013 9:45 AM
ClassTestUpdateParentaccountName
Method Namemytest
Pass/FailFail
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateParentAccountName: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.updateParentAccountName: line 9, column 1: []
Stack Trace

Class.TestUpdateParentaccountName.mytest: line 14, column 1

 

Any help would be appreciated! Thanks!!

  • February 13, 2013
  • Like
  • 0
Hi, I am trying to copy data from Lead to a custom object using javascript button. When a lead rich text field contains line spaces, it gives me an error. So i used URLencode which resolves the error but the spaces are substituted with '+'. Is there a way to copy the text as is (including line spaces)?
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} 


var p1 = new sforce.SObject("Place__c"); 
p1.Name = '{!Lead.Place_1__c}';
p1.Place_Text__c = '{!URLENCODE(Lead.Place_1_About__c)}';


var result = sforce.connection.create([p1]);


if(result[0].getBoolean("success")){
   alert('New record updated successfully');
}
else{
  alert('Error : '+result);
}

example:
Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro v v v vPlace 1 Intro Place 1 IntroPlace 1.

Intro Place 1 Intro Place 1 Intro. Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro Place 1 Intro v v Place 1 Intro

gets converted to

Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+v+v+v+vPlace+1+Intro+Place+1+IntroPlace+1.%3Cbr%3E%3Cbr%3EIntro+Place+1+Intro+Place+1+Intro.%C2%A0Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+Place+1+Intro+v+v+Place+1+Intro
  • August 12, 2015
  • Like
  • 0
I have a requirement to create a button on the lead object that creates two custom object records with fields pre-opulated from the Lead record. Can someone provide me a sample code to start with? 
  • August 11, 2015
  • Like
  • 0
Hello developers,

I have a text field test__c on an object TestObject__c. This filed has values seperated by commas (a,b,c,d). In my apex class, I would like to pass these values into a list TestList. Can someone please provide me with the correct syntax?

Thanks!
  • January 21, 2015
  • Like
  • 0
How do I share an account record (and associated contacts), so that it is available to external customer community users? The account record will be owned by an Internal user. 

This is basically for a VF page in my customer community where there is a contact lookup field. The external users have to select contacts accociated with a particular account "ABC" only. I have put in a lookup filter, but it is only working for the internal users. The external users are not able to see anything, most probably because they do not have access to he "ABC" account record. Please help!!!
  • December 26, 2014
  • Like
  • 0
Hello,
I am trying to write a schedulable apex class where emails are sent to users who have not logged in past 30 days. Here is what I have but I get the following error:
Error: Compile Error: Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setTargetObjectIds(LIST<User>) at line 14 column 17

global class Class implements Schedulable {

global void execute(SchedulableContext ctx){

    dateTime dt = date.today()-30;    
    id sysAdm = [SELECT id from Profile where Name =: 'System Administrator' LIMIT 1].id;
    List <User> userList = [SELECT Name, Email, LastLoginDate, ISActive, Id From User WHERE IsActive = true AND LastLoginDate <: +dt AND ProfileId !=: sysAdm LIMIT 10000];
    
    if(userList.size() > 0)
        {
            for(User usr : userList)
            {
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setTargetObjectIds(userList); // List of  ids of the contact, lead, or User
                mail.setTemplateId('00***********XU'); // Id of the email template
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            }
        }
    update userList;
}
}
  • November 05, 2014
  • Like
  • 0
Hello! I would like to display my account records on a VF page in the following JSON format. I need help with the class and the VF page. Thanks a bunch!
[
    {
        "AccountId": 1,
        "AccountName": "account1",
        "AddressBook": [
            {
                "Id": 1,
                "Name": "test",
                "Attn": "test",
    "StreetName": "test",
                "CityName": "test",
                "State": "TT",
                "PostCode": 89098,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 2,
                "Name": "test2",
                "Attn": "test2",
    "StreetName": "test2",
                "CityName": "test2",
                "State": "TU",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            
        ]
    },
    {
        "AccountId": 2,
        "AccountName": "Account2",
        "AddressBook": [
            {
                "Id": 1,
                "Name": "Test3",
                "Attn": "Test3",
    "StreetName": "Test3",
                "CityName": "Test3",
                "State": "TI",
                "PostCode": 3000,
                "Tel": "(000)- 000-0000",
                "Favorite": true,
                "AccountId": 1
            },
            {
                "Id": 2,
                "Name": "Test4",
                "Attn": "Test4",
    "StreetName": "Test4",
                "CityName": "Test4",
                "State": "TO",
                "PostCode": 75000,
                "Tel": "(000)- 000-0000",
                "Favorite": false,
                "AccountId": 1
            },
            
        ]
    },
    
]

I am trying to write an apex test class for the following trigger

 

Trigger updateParentAccountName on Contact(before insert, before update){

List<Id> idList = new List<Id>();

for(Contact con : trigger.new ){
    if(con.AccountId != '001Q000000b32BD'){
        idList.add(con.AccountId);
        Map<Id,Account>accMap = new Map<Id,Account>([select ParentId from Account where id in:idList]);
        con.Parent_Account__c = accMap.get(con.AccountId).ParentId;
        }
    }
}

 

this is what i came up with so far:

 

@isTest
private class TestUpdateParentaccountName
{
  static testMethod void mytest()
  {
    //Create the 2 different categories the contact name may fall in

    List<Contact> testContacts = new List<Contact>();
    Contact testCase = new Contact();
    testCase.LastName = 'test1';
    testCase.AccountId = '001Q000000agMR5';
    testCase.RPCD_Functional_Area__c = 'General';
Test.startTest();
 insert testCase;
    testCase.Parent_Account__c = 'Department of Health and Human Services';
    update testCase;
 Test.stopTest();
Contact ct=[select  Parent_Account__c from Contact where id =: testCase.Id];
system.assert(ct.Parent_Account__c =='Department of Health and Human Services', ' Parent not changed');
    }
}

 

I get 100% code coverage but the test method fails. This is the error that i get

 

Time Started2/13/2013 9:45 AM
ClassTestUpdateParentaccountName
Method Namemytest
Pass/FailFail
Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateParentAccountName: execution of BeforeInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.updateParentAccountName: line 9, column 1: []
Stack Trace

Class.TestUpdateParentaccountName.mytest: line 14, column 1

 

Any help would be appreciated! Thanks!!

  • February 13, 2013
  • Like
  • 0

Hello! This is my trigger. If the Account filed on Contact is not equal to "Not Available" then it populates Parent Account Field on Contacts with the Account.Parent.

 

Trigger updateParentAccountName on Contact(before insert,before update){

List<Contact> conList = new List<Contact>();
List<Contact> accList = new List<Contact>();
List<Id> idList = new List<Id>();

for(Contact con :Trigger.new){
if(con.Account.Name != 'Not Available'){
idList.add(con.AccountId);

}
}

Map<Id,Account>accMap = new Map<Id,Account>([select ParentId from Account where id in:idList]);

for(Contact c : trigger.new){
if(c.Account.Name != 'Not Available'){
c.Parent_Name__c = accMap.get(c.AccountId).ParentId;
}
}
}

Can anyone help me write a test class for this?

 

I have written the following but doesnt seem to work.

 

@isTest
private class TestUpdateParentaccountName
{
  static testMethod void mytest()
  {
    //Create the 2 different categories the contact name may fall in
    List<Contact> testContacts = new List<Contact>();
    Contact testCase = new Contact();
    testCase.LastName = 'test1';
    testCase.Account.Name = 'Food and Drug Administration';
    testContacts.add(testCase);
    
    Contact testCase2 = new Contact();
    testCase2.LastName = 'test2';
    testCase2.Account.Name = 'Not Available';
    testContacts.add(testCase2);
    
    insert testContacts;
    
    }

  • February 06, 2013
  • Like
  • 0

Can anyone help me with the following trigger?

 

I have "Contacts" object. On the "Contacts" object i have a field called "Parent Account Name" and "Account Name"

On the "Accounts" object i have a field called "Parent Name".

 

If "Account Name" is not equal to "Not Available", then "Parent Account Name" should populate the value from "Parent Name" from the "Accounts" object for that particular account. I hope i am clear!

 

Thanks!!!

  • February 06, 2013
  • Like
  • 0