• Dushyant Sonwar
  • PRO
  • 3530 Points
  • Member since 2014
  • Salesforce Developer


  • Chatter
    Feed
  • 75
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 608
    Replies
I am using apex:chart tag on visualforce page, to display a chart to community users having a "Customer Community Login" license.

I've added the VF component on builder, enabled the respective VF page and controller class. But when I publish the changes, those changes don't reflect on the community for users.

What is the problem here? How should I resolve it?
 
Hi and appreciate any insight on this.

My save button no longer works.  It was a VS button.  I made a new List View button calling VFP/ APEX  Not sure what went wrong here.  

Button
 
User-added image

VFP.
<apex:page standardController="Case" recordSetVar="cases" lightningStylesheets="true" extensions="setQuickCaseExtensionController"> 
    <apex:form >
        <apex:pageBlock title="Quick Case Entry" mode="edit">
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            
            <apex:pageBlockSection title="Case Details" columns="1">                 
                                
              <apex:inputField label="Source Type" required="true" value="{!case.Source_Type__c}" /> 
              <apex:inputField label="Origin" required="true" value="{!case.Origin}"/>  
              <apex:inputField label="Contact" value="{!case.ContactId}"/> 
              <apex:inputField label="Subject" required="true" value="{!case.Subject}"/> 
              <apex:inputTextArea style="width:300px;height:100px" required="true" label="Description (Min 10 chars)"  value="{!case.Description}"/>
              <apex:inputField label="Category" required="true" value="{!case.Category__c}"/> 
              <apex:inputField label="Sub-Catagory 1" required="true" value="{!case.Sub_Catagory_1__c}"/>  
              <apex:inputField label="Sub-Catagory 2" required="true" value="{!case.Sub_Category_2__c}"/>  
              <apex:inputField label="Sub-Catagory 3" required="true" value="{!case.Sub_Category_3__c}"/>              
              <apex:inputField value="{!case.Related_Account__c}" label="Account"/>          
              <apex:inputField value="{!case.Incident_Occurence_Date__c}" label="Incident Occurrence Date"/>
              <apex:inputField value="{!case.Incident_Occurrence_Time__c}" label="Incident Occurrence Time"/>  
             </apex:pageBlockSection>   
            
            <apex:pageBlockButtons > 
                <apex:commandButton value="Save & Close Quick Case" action="{!save}"/> 
                <apex:commandButton value="Cancel" action="{!cancel}"/> 
            </apex:pageBlockButtons> 
                       
          
        </apex:pageBlock> 
    </apex:form>
</apex:page>

APEX Class

public class setQuickCaseExtensionController {
   private Case QC; 
   public ApexPages.StandardSetController stdController; 
   public setQuickCaseExtensionController(ApexPages.StandardSetController controller){
        controller.setPageSize(10);
        this.QC = (Case)controller.getRecord(); 
        RecordType RecId = new RecordType();
        RecId=[SELECT Id FROM RecordType where Name='Customer First' LIMIT 1];
        QC.RecordTypeId=RecId.Id;
        QC.Quick_Case__c = True;
        QC.Origin = 'Phone';
        QC.Source_Type__c = 'Consumer';
        QC.Description='Quick Case';
        QC.Quick_Case_Closed__c = True;
        QC.Subject='New Quick Case';
        stdcontroller=controller;        
    }

}
I have a visualforce page where a user inputs serial numbers for an asset (New_Asset_Install_LOC_Serial_Number__c), I need this serial number input field to update the main serial number field on the asset Object (SerialNumber). Currently the New_Asset_Install_LOC_Serial_Number__c field is being updated on the asset, but I also need this value to populate the SerialNumber field on the asset.

Here is my visualforce code:
<apex:page docType="html-5.0" standardController="Case" extensions="installTicketUpdateAssetClass" id="thePage"> 
   
    
    <style>
    .installSerialNumber{
        }
    .setupSerialNumber {
        }
    .setupModel {
        }
    .setupModelForId {
        }
    .verify{
        }
    .update{
        }
    .autoSerialCheck{
        }
    .idNumber{
        }
    .ipAddress{
        }
    .locationRemarks{
        }
    .installNotes{
        }
    .serialDoesntMatch{
        }
    .serialDoesntMatchCheckBoxOnAsset{
        }
   
    </style>
    <p></p>


    <apex:form id="theForm"> 
        <apex:pageblock id="Assets">

            <apex:pageBlockSection id="pbs" columns="1"> <!-- to allow the apex:input to show the label -->
                
                <apex:pageBlockTable rows="1" id="pbt3" value="{!Case.Assets__r}" var="asset">
                
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModelForId" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
            		<apex:column style="width:11%;" headerValue="ID Number"><!-- to take the label dynamically -->
                        <apex:inputText required="true" style="width:80%;" styleClass="idNumber" value="{!asset.New_Asset_Install_LOC_ID_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:10%;" headerValue="B/W Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText required="true" styleClass="bwMeter" style="width:80%;" value="{!asset.New_Asset_Install_B_W_Meter__c}"  />
                    </apex:column>
                
               		<apex:column style="width:10%;" headerValue="Color Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="colorMeter" style="width:80%;" value="{!asset.New_Asset_Install_Color_Meter__c}"  />
                    </apex:column>
                
                <apex:column style="width:10%;" headerValue="I.P. Address"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="ipAddress" style="width:90%;" value="{!asset.New_Asset_Install_Equipment_IP_Address__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText disabled="true" style="width:.01%;" styleClass="setupIdNumber" value="{!asset.New_Asset_Setup_LOC_ID__c}"  />
                    </apex:column>
                
            </apex:pageBlockTable>
                
                <apex:pageBlockTable id="pbt" value="{!Case.Assets__r}" var="asset">
                                 
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModel" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:12%;" headerValue="Serial Number Install"><!-- to take the label dynamically -->
                        <apex:inputText style="width:80%;" disabled="" styleClass="installSerialNumber" value="{!asset.New_Asset_Install_LOC_Serial_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:6%; text-align:center;" value="{!asset.Serialized__c}"/>
                    
                    <apex:column style="width:13%;" headerValue="I Verified the Serial Number"><!-- to take the label dynamically -->
                        <apex:inputCheckbox styleClass="serialDoesntMatchCheckBoxOnAsset" value="{!asset.I_Verify_the_Serial_Number_is_Correct__c}"/>
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText style="width:.01%;" disabled="true" id="pbi" styleClass="setupSerialNumber" value="{!asset.Serial_Number_Service_Setup__c}"  />
                    </apex:column>
                    
                </apex:pageBlockTable>
                </apex:pageBlockSection>
            
            
            
            <apex:pageBlockTable rows="1" id="pbt2" value="{!Case.Assets__r}" var="asset">
                
            		<apex:column style="" headerValue="Location Remarks"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="locationRemarks" style="width:99.45%;" value="{!asset.New_Asset_Install_Equipment_Location__c}"  />
                    </apex:column>
                    
                    <apex:column style="" headerValue="Install Notes"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="installNotes" style="width:99.45%;" value="{!asset.Install_Notes__c}"  />
                    </apex:column>
                
               		<apex:column headerValue="Customer DocuSign Link" >
                        <apex:outputLink target="_blank" style="width:99.45%;" value="{!case.Customer_DocuSign_Link__c}">
                            Customer DocuSign Link
                        </apex:outputLink>
                	</apex:column>
                
            </apex:pageBlockTable>
            
            <apex:pageBlockSection id="pbs2" columns="2">
                <apex:inputField id="cheaterOnSite" onchange="cheaterLeftOnSite(); return false;" value="{!case.Cheater_Left_On_Sight__c}"/>
                <apex:inputCheckbox styleClass="autoSerialCheck" onchange="" id="serialNumberVerified" disabled="" value="{!Case.Serial_Numbers_Verified__c}"/>
                <apex:inputText id="cheaterId" value="{!case.Cheater_ID__c}"/>
				<apex:inputCheckbox onchange="enableUpdateButton(); return false;" id="manualSerialNumberVerification" disabled="" value="{!Case.Manual_Serial_Number_Verification__c}"/>
                <apex:inputCheckbox id="cheaterCheckBox" value="{!case.Cheater_was_used_at_install__c}"/>
                <apex:inputCheckbox id="install" value="{!Case.Install_Complete__c}"/>
                
              
                
            </apex:pageBlockSection>
            <p class="serialDoesntMatch">
                <apex:inputCheckbox id="serialDoesntMatchCheckBox" value="{!Case.Asset.I_Verify_the_Serial_Number_is_Correct__c}"/> 
                The above serial number(s) have been verified by <strong>{!$User.FirstName} {!$User.LastName}.</strong>
                <br/>
                <strong>{!$User.FirstName} {!$User.LastName}</strong> has uploaded a document that verifies the correct serial number
               
            </p>
            <apex:pageBlockButtons location="bottom">  
                 <apex:commandButton styleClass="verify" id="verify" onclick="verifySerialNumbers(); return false;" value="Verify" />
                <apex:commandButton oncomplete="congrats(); return false;" styleClass="update" id="update" disabled="" value="Update" action="{!saveSerialIdNumber}" />
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>

</apex:page>

And here is my apex class:
public class installTicketUpdateAssetClass {
    private ApexPages.StandardController controller;

    //Constructor 
    public installTicketUpdateAssetClass(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public void saveSerialIdNumber() {
        // here we use the standard controller's capability of fetching related records to update them ourselves 
        // (Casting is needed because YourChildRelationshipName__r is specific to your case object)
        update ((Case) controller.getRecord()).Assets__r;
        // here we call the standard controller's "update"
        controller.save();
    }
}

​​​​​​​Any help would be greatly appreciated

Hello, I have been a bit perplexed by this issue and could use some help.  I have a method in before update trigger that is writing the changes of a changed field ( the field name, the oldvalue, and the newvalue) of a field changed within a fieldset.  

 

The output is just the first line which is "These fields are changed and need approval: " and then nothing else prints.  Also, debugging I find that I have this in a try/catch and I am seeing the "Error:  String validation Exception on name ID" which has me very confused as well. 

 

Here is the code 

 

public static void getChangedFieldValues(Map<Id, Account> newMap, Map<Id, Account> oldMap) {

        List<Schema.FieldSetMember> approvalFields = Util.getAddressApprovalFields();

        for (Account newAcc : newMap.values()) {
            Account oldAcc = oldMap.get(newAcc.Id);

            for (FieldSetMember fsm : approvalFields ) {
                String field = fsm.getFieldPath();
                try {
                    System.debug('newAcc.get(Field) ====== ' + newAcc.get(field));
                    System.debug('oldAcc.get(Field) ====== ' + oldAcc.get(field));
                    if (newAcc.get(field) != oldAcc.get(field)) {
                        newAcc.Start_Address_Approval_Description__c = 'These address fields are changed and need approval:\n';
                        newAcc.Start_Address_Approval_Description__c += fsm.getLabel() + ' changed from: ' + oldMap.get(fsm.getFieldPath()) + ' to: ' +
                                newAcc.get(fsm.getFieldPath()) + '\n';
                    }
                } catch (Exception e) {
                    System.debug('Address Error: ' + e);
                }
            }
}


Like i said, it is updating the Description field with the first line, "These address fields are changed and need approval" , but then nothing else is getting added to the field, and at the same time I am also seeing that weird error:

Error: System.StringException: Invalid id: Name

 

Any help on why the rest is not being printed or the error would help immensely.  

Hello, all

I have added a percentage 'yearly increase' field to my Opp Product.

I am looking for a way to calculate the lifetime total of the product after x years (x being the 'term' field) if the price is increased by 'yearly increase' every year and how to track each year's price. This needs to work for any given term

for example.
  • product price = $100
  • yearly increase = 3%
  • term = 5​​​​​​​
    • year 1 price = 100
    • year 2 price = 103
    • year 3 price = 106.09
    • year 4 price = 109.27
    • year 5 price = 112.55
    • lifetime total = 530.91
If I could use a for loop in the formula editor I could calculate the lifetime total, but I can't figure out how to do that in the formula editor. Is there a way to do that or to write the for loop in an apex class and use that to populate the lifetime total field? I have no clue how to track each year's price espically when the term will vary.

Thank you for your time and help.
<id,Sobject> map1 = <id, Sobject>();
<id,Sobject> map2 = <id, Sobject>();

if map1 and map2 contain same key with different values.
how to add map2 values to map1 without deleting map1 values.
Hi,

I have a requriment to create list view from VF page.

Is there any way to create listview from apex
trigger for updating a value depending on another object field.
A very simple trigger.
I want to update by incrementing the total_applicant(Type:Number, object: Job__c) field by 1, which is to be done only after a record is inserted or updated in the Candidate__c object.
I can't figure out why line 7 is always red(errorneous) which leads to no change in the databse.
A little help would be appreciated. A newbiew here by the way.
I want to be able to create a Case and when the Case is created automatically link a File or Attachment.

I have a word document that I want attached to cases when they are created.

What is the best way to achieve this? Presumably it will require Apex code? Will I need to make a copy of the Word document from somewhere then create the required File records to attach it to the Case?
 
  • May 15, 2020
  • Like
  • 0
I am learning Apex and am trying to get my controller to query for Resource_List__c records where the Survey_Form__c field = :RecordId (the current Survery_Form__c record I am viewing)

VF Page
<apex:page Controller="ResourceListController">
    <apex:form>
    <apex:pageBlock>
<apex:pageBlockTable value="{! ResourceList }" var="RL">
    <apex:column value="{! RL.Id }"/>
    
</apex:pageBlockTable>
    </apex:pageBlock>
        </apex:form>
</apex:page>

Class
public class ResourceListController {
   public Id RecordId {get;set;}    
public List<Resource_List__c> getResourceList() {
    
    List<Resource_List__c> results = Database.query(
        'SELECT Id, Account__c, Distance__c, type__c ' +
        'FROM Resource_List__c ' + 
        'Where Survey_Form__c = :RecordId '
    );
    return results;
}
}

VF Page Output when on the Lightning page
User-added image
but when I put the query into the query editor and hard code the record Id there are values in this table

User-added image

Is there any way to pass the record id into the VF page without invoking aura or LWC? I just want to learn the fundamentals before I step into those new languages
hi,
I have used <apex:image> in Visualforce email template.
the image is showing fine in Outlook app but image is not coming in outlook.com
Is there a way to allow the user to single click to open the select, and then single click to select a value?

I have a table with a "Pay?" column that is a select list field that uses inline-edit on dbl click, which works, but I would like it to work on a single click. Unfortunately, when I change the event to onclick, it will open up the select box but toggle off and on when I try to select a value because I am using a single click on the cell.

Is there a way to allow the user to single click to open the select, and then single click to select a value?

Page:
<apex:page controller="DTTestPageController" lightningStylesheets="true">
    <apex:pageMessages />

 <apex:form id="form">  
    
    <apex:pageBlock mode="inlineEdit" id="pageblock1">  
        <div id="header" class="headerborder">
            <p id="title">DT Worksheet</p>

            <p id="select">
            <apex:selectList size="1" id="filter" value="{!pickValue}">
                <apex:actionSupport event="onchange"  action="{!GetMedicals}" rerender="table1"/>
                <apex:selectOption itemLabel="All" itemValue="All" ></apex:selectOption>
                    <apex:selectOption itemLabel="Needs Review" itemValue="Review" ></apex:selectOption>
                    <apex:selectOption itemLabel="Pay" itemValue="Pay"></apex:selectOption>
                    <apex:selectOption itemLabel="Don't Pay" itemValue="Dont Pay"></apex:selectOption>
            </apex:selectList>
            <apex:commandButton id="alert" value="Alert" rerender="" action="{!alertUser}"/>
        </p>

        </div>
        <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="saveButton" value="Save" rerender="" action="{!saveme}"/>  
               <apex:commandButton id="cancelButton" value="Cancel" rerender="table1"/>  
        </apex:pageBlockButtons> 
    
        

        <div class="tableborder" id="border">
    <apex:pageBlockTable value="{!lstMedicals}" var="med" id="table1">
        
        <apex:column headerValue="Medical Bill Number" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputLink value="/{!med.Id}" styleClass="link">
                            {!med.Name}
                      </apex:outputLink>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Provider" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Provider_Name__c}">
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Pay?" headerClass="headerStyle" id="column1">
            
            
                <apex:actionRegion id="actionRegion1">
                      <apex:outputField value="{!med.Disburse__c}" id="pay">
                              <apex:inlineEditSupport event="onClick" showOnEdit="saveButton,cancelButton"/>
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Notes" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disbursement_Note__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="note"/>
                      </apex:outputField>
                </apex:actionRegion> 
        </apex:column>
    </apex:pageBlockTable>
</div>
 </apex:pageBlock>  
</apex:form>

Controller:
public class DTTestPageController {
    /* private String sortOrder = 'LastName'; */
    public string pickValue{get; set;}
    public litify_pm__Matter__c matterId{get; set;}
    public Id recordTypeId = Schema.SObjectType.Medical_Bill__c.getRecordTypeInfosByName().get('Medical').getRecordTypeId();
    public list<Medical_Bill__c> lstMedicals{get; set;}

    public DTTestPageController(){
        pickValue = 'All';
        GetMedicals();
    }

    public void GetMedicals() {
        
        matterId = [SELECT Id, litify_pm__Principal_Attorney__c, Litigation_Attorney__c  FROM litify_pm__Matter__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
        

        


        if (pickValue == 'All') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
            
        }
        else if (pickValue == 'Review') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = null];
        }
        else if (pickValue == 'Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'Yes'];
        }
        else if (pickValue == 'Dont Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'No'];
        }
        else {
             lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
        }
        
    }

    public pagereference saveme()
    {
    try
    {
        System.debug(lstMedicals);
        update lstMedicals;
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Medical Bill List Updated!'));
    }   
    catch(DmlException ex)
    {
        ApexPages.addMessages(ex);

    }
    return NULL;
    }   

  /*   public void sortByFirstName() {
        this.sortOrder = 'LastName';
    } */

    public void alertUser() {
        Id profileId=userinfo.getProfileId();
        String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
        Id ownerId;
        String assignedRole;
        String subject;

        if (profileName == 'Disbursements Team' || profileName == 'Disbursements Team Lead') {

            if (matterId.Litigation_Attorney__c == null) {
                ownerId = matterId.litify_pm__Principal_Attorney__c;
            }
            else {
                ownerId = matterId.Litigation_Attorney__c;
            }

            assignedRole = 'Attorney';
            subject = 'Verify The List Of Medical Bills We Are Paying Is Correct';

        }
        else {
            ownerId = '0056A000000mKxc';
            assignedRole = 'Disbursements';
            subject = 'The Attorny Has Reviewed The List of Medical Bills';
        }

        Task taskRecord = new Task();
        taskRecord.OwnerId = ownerId;
        taskRecord.Assigned_Role__c = assignedRole;
        taskRecord.Subject = subject;
        taskRecord.WhatId = matterId.Id;
        taskRecord.litify_pm__Matter__c = matterId.Id;
        taskRecord.ActivityDate = System.today();
        taskRecord.Priority = 'Normal';

        insert taskRecord;
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Alert Sent!'));  
    }
}

​​​​​​​​​​​​​​
I have a Visualforce table that isn't populating on page load. It will populate after I select a picklist value from #filter, but not until then. How can I make the data populate automatically on page load?

Page:
<apex:page controller="DTTestPageController" tabStyle="Lead" lightningStylesheets="true">
    <apex:messages/>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

<apex:form id="form">  
    
    <apex:pageBlock mode="inlineEdit" id="pageblock1">  
        <div id="header" class="headerborder">
            <p id="title">DT Worksheet</p>

            <p id="select">
            <apex:selectList size="1" id="filter" value="{!pickValue}">
                <apex:actionSupport event="onchange"  action="{!GetMedicals}" rerender="table1"/>
                <apex:selectOption itemLabel="All" itemValue="All" ></apex:selectOption>
                    <apex:selectOption itemLabel="Needs Review" itemValue="Review" ></apex:selectOption>
                    <apex:selectOption itemLabel="Pay" itemValue="Pay"></apex:selectOption>
                    <apex:selectOption itemLabel="Don't Pay" itemValue="Dont Pay"></apex:selectOption>
            </apex:selectList>
            <apex:commandButton id="alert" value="Alert" rerender=""/>
        </p>

        </div>
        <apex:pageBlockButtons location="bottom">  
               <apex:commandButton id="saveButton" value="Save" rerender="" action="{!saveme}"/>  
               <apex:commandButton id="cancelButton" value="Cancel" rerender=""/>  
        </apex:pageBlockButtons> 
    
        

        <div class="tableborder" id="border">
    <apex:pageBlockTable value="{!lstMedicals}" var="med" id="table1">
        
        <apex:column headerValue="Medical Bill Number" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputLink value="/{!med.Id}" styleClass="link">
                            {!med.Name}
                      </apex:outputLink>
                </apex:actionRegion>  
        </apex:column>

            <apex:column headerValue="Provider" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Provider_Name__c}">
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Pay?" headerClass="headerStyle" id="column1">
            

            

            <apex:facet name="header">
               <!--  <apex:commandLink action="{! sortByFirstName }" 
                    reRender="contacts_list">Pay
                </apex:commandLink> -->
            </apex:facet>
            
                <apex:actionRegion id="actionRegion1">
                      <apex:outputField value="{!med.Disburse__c}" id="pay">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton"/>
                      </apex:outputField>
                </apex:actionRegion>  
        </apex:column>

        <apex:column headerValue="Notes" headerClass="headerStyle">
                <apex:actionRegion >
                      <apex:outputField value="{!med.Disbursement_Note__c}">
                              <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" id="note"/>
                      </apex:outputField>
                </apex:actionRegion> 
        </apex:column>
    </apex:pageBlockTable>
</div>
 </apex:pageBlock>  
</apex:form>  

    </html>

</apex:page>
Controller:
public class DTTestPageController {
    private String sortOrder = 'LastName';
    public string pickValue{get; set;}
    public litify_pm__Matter__c matterId{get; set;}
    public Id recordTypeId = Schema.SObjectType.Medical_Bill__c.getRecordTypeInfosByName().get('Medical').getRecordTypeId();
    public list<Medical_Bill__c> lstMedicals{get; set;}
    public void GetMedicals() {

        System.debug(pickValue);

    
        if (pickValue == 'All') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
            
        }
        else if (pickValue == 'Review') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = null];
        }
        else if (pickValue == 'Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'Yes'];
        }
        else if (pickValue == 'Dont Pay') {
            lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c From Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId AND Disburse__c = 'No'];
        }
        else {
             lstMedicals = [Select Id, Name, Provider_Name__c, Disburse__c, Disbursement_Note__c from Medical_Bill__c WHERE Matter__c =: matterId.Id AND RecordTypeId =: recordTypeId];
        }
        
    }

    public pagereference saveme()
    {
    try
    {
        System.debug(lstMedicals);
        update lstMedicals;
        
    }   
    catch(DmlException ex)
    {
        ApexPages.addMessages(ex);

    }
    return NULL;
    }   

  /*   public void sortByFirstName() {
        this.sortOrder = 'LastName';
    } */

}


 
Hi all and Happy new year.

I had this task to create a custom Related list on the Account Page Layout with Visualforce and it all works fine. I've got all the records that i need and all the required fields and of course "New Project" button.

New Project button

However the only issue is that when i added the "New BD Project" button, when the new page is opened and the user change his mind and press "Cancel" it returns to the Visualforce page only, not to the Account Page Layout.

Cancel

I tried different solution, but i could not make it work.
Here is the commandlink button
<div style="margin-left: 30%;">
<apex:commandLink value="New BD Project" action="       {!URLFOR($Action.BD_Project__c.New)}" target="_parent"     styleClass="btn" style="text-      decoration:none;padding:4px;"/>
</div>

I found the whole Visualforce page and Controller in another solution which was for Contact Related list and i modified it to fit my requirements. The only change is that in the working Contact solution(where when you press cancel it returns you to the previous page) is that the code for the New Object is in the Controler:
 
public pageReference newContact()
{
pageReference pageRef = new pageReference(URL.getSalesforceBaseUrl().toExternalForm() + '/003/e?&retURL=' + accounts.id);
return pageRef;
}

Did any of you guys had a similar issue and found a solution.

Kind regards,
Dimitar
 

Here is the controller and the Visualforce that i'm using.:


 
I'm going to override the standard controller for my object .  Do insertion a new record  ( record in base still there is no).  Page

<apex:page standardController="CallReportHosp__c" extensions="CtrlCallHospEdit" >
<apex:outputPanel rendered="{!IF($CurrentPage.parameters.theType = 'app', false, true)}" >
            <apex:pageBlockSection columns="2">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.CallReportHosp__c.fields.AccountID__c.label}" for="organisation"/>
                    <apex:inputField value="{!CallReportHosp__c.AccountID__c}" id="organisation" >
                         <apex:actionSupport event="onchange"  reRender="pblock" status="status" action="{!SelectService}" />
                    </apex:inputField>
                </apex:pageBlockSectionItem>
Controller
public with sharing class CtrlCallHospEdit {


public Boolean booleanValue {get;set;}
pablic CallReportHosp__c rep;

 public CtrlCallHospEdit(ApexPages.StandardController controller)
    {
       this.booleanValue=false;
       rep = (CallReportHosp__c)controller.getRecord();

       System.debug(' bool= '+booleanValue);
       SelectService();      
    }
 
 
    
public void SelectService(){
system.debug('selectservice=');
        if(rep.AccountID__c !=null)
           { booleanValue = true; System.debug('acc= '+rep.AccountID__c); }
           else {booleanValue=false; System.debug('acc= '+rep.AccountID__c); }
    }     
}
I changed value in field AccountID__c in page, but i don't have its value in controller ( i have rep.AccountID__c = null).
I remind you that I need to get the value of the field BEFORE saving the record in the database (before the call Save).
Tell me what I'm doing wrong
 
Hi there,

I have created an Apex trigger for my organization and deployed it to production and it seems to be conflicting with my attempts to update a bunch of records in Data Loader.

We have a custom object that governs a special form, which I will call Forms__c (it is not actually named Form), and we have put on this object a trigger to prevent duplicates from being created. On create or update, the trigger checks the name of a given record, which will always be a 4-digit number, and returns an error if the number/name is already in use.
 
trigger FormNumberDuplicate on Form__c (before insert, before update) {
    list<id> formId = new list<id>();
    list<string> formNumber = new list<string>();
    
    if (Trigger.isInsert || Trigger.isUpdate) {
        for (Form__c t : Trigger.New) {
            System.debug(t);
            formId.add(t.Id);
            formNumber.add(t.Name);
        }
        
        List<Form__c> allForms = [SELECT Id, Name FROM Form__c WHERE IsDeleted = false];
        Integer flag = 0;
        for(Form__c t : allForms) {
            System.debug(t);
            if(!formId.contains(t.Id)) {
                if(formNumber.contains(t.Name)) {
                   flag = flag+1; 
                }
            }
        }
        System.debug(flag);
        if(flag > 0) {
            for(Form__c t : Trigger.New) {
                t.Name.addError('This Form number is already in use.');
            }
        }    
    }
    
    
}

The trigger works as intended: if a user tries to create a Form and uses the same number, it prevents them from entering a duplicate of the form and it tells them the form number is already in use.

However, I was trying to bulk update these Form__c records today with data from an external source, and ran into the issue where every single Form__c record would not update and threw the error in this trigger.

What am I missing here?

Thanks.
 

Hi all,

I'm trying to create a validation rule via trigger when two multiselect picklist values are the same then the validation to fire.

trigger differentValues on User (before insert) {

    for(User u : Trigger.New) {
        if(u.Restrict_access_by_Country__c =='DE' && u.TestMultiSelectCountry__c== 'DE' ) {
        u.addError('Values cannot be the same');
    }
    }
}

This trigger it's not firing.. I'm confused why not?
Hey there, I'm new to development and APEX classes, so apologies if this is easy. But basically we have Zuora package (for billing) and I'm updating one of the classes for default values when creating a quote. Most of the code works, except when I add in a reference to Billing Country on the Account it says it doesn't exist. My code for that particular part is below, and full code below that.

Error: 
Error: Compile Error: Variable does not exist: billingcountry at line 23 column 20
// Retrieve the account ID from the quote
      Id accountId = (Id) record.get('zqu__Account__c');
      
      List<Account>accounts = [SELECT Id, BillingCountry FROM Account WHERE Account.ID = :accountID];
      
      if (accounts.billingcountry == 'Canada')
      {
      record.put('zqu__PaymentGateway__c', 'Standard');
      } else {
      record.put('zqu__PaymentGateway__c', 'USD2');
      }
Full code:
global class ZuoraDefaultValues extends zqu.CreateQuoteController.PopulateDefaultFieldValuePlugin{  
   global override void populateDefaultFieldValue
(SObject record, zqu.PropertyComponentController.ParentController pcc)
   {    
      super.populateDefaultFieldValue(record, pcc);  
      
      //Populate default values in the quote header  
      Id OpptId = (Id) record.get('zqu__Opportunity__c');    
      List<Opportunity> Opportunity= [SELECT Id, Name FROM Opportunity WHERE Opportunity.Id = :OpptId ]; 
       
      record.put('Name', 'Quote For ' + Opportunity[0].Name + ' ' + Date.today().format());
      record.put('zqu__InitialTerm__c', 12);    
      record.put('zqu__RenewalTerm__c', 12);    
      record.put('zqu__ValidUntil__c', Date.today().addDays(30));    
      record.put('zqu__StartDate__c', Date.today());
      record.put('zqu__PaymentMethod__c', 'Credit Card');  
      
      // Retrieve the account ID from the quote
      Id accountId = (Id) record.get('zqu__Account__c');
      
      List<Account>accounts = [SELECT Id, BillingCountry FROM Account WHERE Account.ID = :accountID];
      
      if (accounts.billingcountry == 'Canada')
      {
      record.put('zqu__PaymentGateway__c', 'Standard');
      } else {
      record.put('zqu__PaymentGateway__c', 'USD2');
      }
    

      // Find the contacts associated with the account         
      List<Contact>contacts = [SELECT Id, Name FROM Contact WHERE Account.Id = :accountId];
      
      // Assuming the contacts are present set the billTo and soldTo to the first contact
      if  (contacts.size() > 0) {
         // System.debug('mp: about to add ' + contacts[0].Id + ' as a contact ID');
         record.put('zqu__BillToContact__c', contacts[0].Id);
         record.put('zqu__SoldToContact__c', contacts[0].Id);

         // Beforeretrieving  the lookup  options, needs to populate the map first
         super.setLookupOptions(pcc);
      
         // Now retrieve the lookup component options
         zqu.LookupComponentOptions billToOptions = super.getLookupOption('zqu__BillToContact__c');
         billToOptions.targetId = contacts[0].Id;
         billToOptions.targetName = contacts[0].Name;
         zqu.LookupComponentOptions soldToOptions  = super.getLookupOption('zqu__SoldToContact__c');
         soldToOptions.targetId = contacts[0].Id;
         soldToOptions.targetName = contacts[0].Name;
      }
   }
}

 
I am trying to write test coverage for a method and receiving the error "Attempt to de-reference a null object" when I run the test.  Below is my test class, can anyone guide me in the right direction with this?

Test class:

static testmethod void getselectOptionsTest(){
        Id RecordTypeIdPropAccount = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Franchisee').getRecordTypeId();
        
        Account fAcct = new Account(Name = 'Test', RecordTypeId=RecordTypeIdPropAccount);
        insert fAcct;
        sObject objObject = [SELECT Id, Name FROM Account WHERE Name = 'Test' LIMIT 1];
        String fld = 'RetailerCategory';
        
        Test.startTest();
        multiPicklistCtrl.getselectOptions(objObject, fld);
        Test.stopTest();
        
    }

Original method:

@AuraEnabled
    public static List <String> getselectOptions(sObject objObject, string fld) {
          system.debug('objObject --->' + objObject);
          system.debug('fld --->' + fld);
          List < String > allCats = new list < String > ();
          // Get the object type of the SObject.
          Schema.sObjectType objType = objObject.getSObjectType();
        
        // Describe the SObject using its object type.
          Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
 
          // Get a map of fields for the SObject
          map < String, Schema.SObjectField > fieldMap = objDescribe.fields.getMap();

          // Get the list of picklist values for this field.
          list < Schema.PicklistEntry > values =
           fieldMap.get(fld).getDescribe().getPickListValues();

          // Add these values to the selectoption list.
          for (Schema.PicklistEntry a: values) {
           allCats.add(a.getValue());
          }
          system.debug('allCats ---->' + allCats);
          allCats.sort();
          return allCats;    
        }
New to coding and would really appreciate any help that can be provided.

I am trying to write a test class for a function I have written that creates Opportunities for each account in a list.  On compile I am receiving the error 'Method does not exist or incorrect signture: void CreateOpptys(Id, List) from the type multiPicklistCtrl.  Can someone please tell me what I am doing wrong?

This is my test class:

static testmethod void CreateOpptysTest(){
        Id RecordTypeIdPropAccount = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Property').getRecordTypeId();
        
        Account pAcct = new Account(Name = 'Test Property account', RecordTypeId=RecordTypeIdPropAccount);
        insert pAcct;
        
        PropertySpace__c pSpace = new PropertySpace__c(Name='Test Property Space', Property__c = pAcct.Id, SquareFootage__c = 2000);
        insert pSpace;

        List<Account> accts = new List<Account>();
        for (Integer i=0; i<20; i++) {
            accts.add(new Account(Name = 'Test Account -' +i, RecordTypeId=RecordTypeIdPropAccount));
        }
        insert accts;
        
        accts = [Select Id from Account];
        
        Test.startTest();
          multiPicklistCtrl.CreateOpptys(pSpace.id,accts);
          Test.stopTest();
    }

Here is the function I am trying to write the test for:

@AuraEnabled
    public static void CreateOpptys(Id propertyId, List<Id> selectedAccts){
        system.debug('From Create Oppty propertyId1>>>'+propertyId);
        system.debug('From Create Oppty selectedAccts>>>'+selectedAccts);
        //Need to search through existing Opportunities and if there is an active Opty created for the Account and Property, do not create another Oppty.
        PropertySpace__c propSpace = new PropertySpace__c();
        Id propSpaceId;
        if(string.valueof(propertyId).startsWith('006')){
            opportunity opp= [SELECT PropertySpace__c FROM Opportunity WHERE Id = :propertyId];
               propSpace= getProp(opp.PropertySpace__c);
            propSpaceId = opp.PropertySpace__c;
        }
        else{
            propSpace = [SELECT Name,SquareFootage__c, Property__c FROM PropertySpace__c WHERE Id = :propertyId];
            propSpaceId = propertyId; 
        }
            
        Id recTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Vacancy Fill').getRecordTypeId();
        
         
        list<Opportunity> lstOpptys = new List<Opportunity>();
        for(integer i=0; i< selectedAccts.size(); i++){
            Opportunity o = new Opportunity(Name = propSpace.Name +i,
                                            CloseDate = date.today().addDays(90),
                                            StageName = 'Prospect',
                                            RecordTypeId = recTypeId,
                                            AccountId = selectedAccts[i]);

        lstOpptys.add(o);
        }    
        insert lstOpptys;
        
            
    }

 
Hi all. I have a VF page with an <apex:form> component with Account as the standard controller however when I enter details and click save in the preview page or on the community where I placed it as a component, it doesn't add the record to my Salesforce org - what am I missing here?
 
<apex:page standardController="Account">
    <h1>Enter Account</h1>
    <apex:form >
    <apex:pageBlock title="Edit Account">
        <apex:pageBlockSection columns="2">
            <apex:inputField value="{! Account.Name}"/>
            <apex:inputField value="{! Account.Phone}"/>
            <apex:inputField value="{! Account.Industry}"/>
        </apex:pageBlockSection>
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Thanks
Hi,

Below is my VF page, but it isn;t available to me to direct a Detail Page button to it - can anyone help as to why?
 
<apex:page standardController="Custom_Object__c" recordSetVar="Opportunities" showHeader="false" sidebar="false">
   <apex:sectionHeader title="eVA Qualification Form Edit" subtitle="New eVA Qualification Form"/>

    <apex:form>
        <apex:pageBlock title="eVA Qualification Form Edit" mode="edit">
             <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
             </apex:pageBlockButtons>
                        
            <apex:pageBlockSection title="Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Opportunity__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.OwnerId}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Website_URL__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Website_Visits_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Existing_SAV_User__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Stock_Level__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Sales_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Part_Exchange__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.Number_of_Part_Ex_valuations_per_Month__c}" required="true"/>
                <apex:inputField value="{!Custom_Object__c.How_do_they_know_this__c}" required="false"/>
                <apex:inputField value="{!Custom_Object__c.Do_they_have_a_valuation_CAP_license__c}" required="true"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.What_are_thier_Business_objectives__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Consumer_Journey_thoughts__c}" required="false"/>
                <apex:pageBlockSectionItem/>
                <apex:inputField value="{!Custom_Object__c.Additional_Information__c}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
            <apex:pageBlockSection title="System Information" columns="2">
                <apex:inputField value="{!Custom_Object__c.Name}" required="false"/>
                <apex:pageBlockSectionItem/>
            </apex:pageBlockSection>            
            
        </apex:pageBlock>
    </apex:form>
   

</apex:page>

 
here its my code:-
// Apex controller
public class Filtered_Contacts {
    public List<opportunity> oppList{get;set;}
    //public string stagename{get;set;}
    public Boolean show{set;get;}
    public Boolean showbtn{set;get;}
    public opportunity opp{get;set;}
    public List<WrapperClass> wrapList {get; set;}
    public String selectedTemplateName { public get; public set; }
    // counstructor
    public Filtered_Contacts(){
        oppList = new List<opportunity>();   
        opp = new opportunity();
        show =false;
        showbtn=false;
        wrapList = new List<WrapperClass>();
        
    }
    
    public pageReference fetchopp(){
        show =true;
        showbtn=true;
        system.debug('====='+show);
        oppList = New List<opportunity>();
        system.debug('====='+show);
        for(Opportunity op : [select  id, Name , StageName from opportunity where AccountId=:opp.AccountId and StageName=:opp.StageName]) {
            wrapList.add(new WrapperClass(op));
            system.debug('wrapList'+wrapList);
        }  
        return null; 
    }
    
    public PageReference sendEmail() {
        List<Opportunity> selectedopportunity = new List<Opportunity>();
        for(WrapperClass oppt : wrapList) {
            if(oppt.selected == true) {
                selectedopportunity.add(oppt.opps);
            }
        }
        
        System.debug('These are the selected opportunities…'+selectedopportunity);
        String body = '';
        body = '<table border="1" style="border-collapse: collapse"><tr><th>id</th><th>Name</th></tr>';
        for(Opportunity oppp : selectedopportunity) {
            String url='<a href="'+system.Url.Getsalesforcebaseurl().toexternalform()+'/'+oppp.Id+'"> '+oppp.Name+'</a>';
            String name = oppp.Name;
            
            body += '<tr><td>' + url +  '</td><td>' + name +  '</td></tr>' ;
        } 
        body += '</table>';
        system.debug('body '+body);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {'rishabhrathor05@gmail.com'};
            system.debug(toAddresses);
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('rishabhrathor05@gmail.com');
        mail.setSenderDisplayName('Salesforce');
        mail.setSubject( 'See Link');
        mail.setBccSender(false);
        mail.setUseSignature(false);
        mail.setPlainTextBody('Hello');
       // mail.setTemplateId(t.id);
        mail.HtmlBody = body;
        system.debug('======='+body);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        List<Messaging.SendEmailResult> results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });  
        if(results[0].success){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.CONFIRM, 'Success!'));
        }
        return null;
    }
    
    public List<SelectOption> getMyPersonalTemplateOptions() {
        showbtn=true;
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','-None-'));
        for (EmailTemplate t : [select Id,Name,Body from EmailTemplate ])
        {
            options.add(new SelectOption(t.Id,t.Name));
        } 
        system.debug('========'+options);
        return options;
    }
    
    
    public class WrapperClass {
        public Opportunity opps {get; set;}
        public Boolean selected {get; set;}
        public WrapperClass(Opportunity op) {
            opps = op;
            selected = false;
        }
    }
}
<!--- vf page--->
<apex:page Controller="Filtered_Contacts" lightningStylesheets="true"  sidebar="false">
    <script>
    function checkAll(cb,cbid)
    {
        var inputElem = document.getElementsByTagName("input");                     
        for(var i=0; i<inputElem.length; i++)
        {             
            if(inputElem[i].id.indexOf(cbid)!=-1){                                        
                inputElem[i].checked = cb.checked;
            }
        }
    }
    </script>  
    
    
    <article class="slds-card">
        <div class="slds-card__header slds-grid">
            <header class="slds-media slds-media_center slds-has-flexi-truncate">
                <div class="slds-media__figure">
                    <span class="slds-icon_container slds-icon-standard-account" title="Opportunity">
                        <svg class="slds-icon slds-icon_small" aria-hidden="true">
                            <!--  <use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#account"></use>-->
                        </svg>
                        <span class="slds-assistive-text">Opportunity</span>
                    </span>
                </div>
                <div class="slds-media__body">
                    <h2 class="slds-card__header-title">
                        <a href="javascript:void(0);" class="slds-card__header-link slds-truncate" title="Opportunity">
                            <span>Opportunities</span>
                        </a>
                    </h2>
                </div>
            </header>
        </div>
    </article>
    
    
    
    <apex:slds />
    <apex:form id="theform">
        
        <div class="demo-only demo-only--sizing slds-grid slds-wrap slds-m-top_large">
            <label ><strong> Account Name </strong></label>
            <div class="slds-size_1-of-4">
                <!--   <apex:outputLabel value="{!$ObjectType.Account.fields['Name'].label}" /> -->
                <apex:inputField value="{!opp.AccountId}"  />
            </div>
            <label ><strong> Stage Name </strong></label>
            <div class="slds-size_1-of-4">
                <apex:inputfield value="{!opp.StageName}"  />  
            </div>
          <label><strong> Template Name </strong></label>
            <div class="slds-size_1-of-4">
                <apex:selectList value="{!selectedTemplateName}" multiselect="false" size="1">
                    <apex:selectOptions value="{!myPersonalTemplateOptions}"/>
                </apex:selectList>
            </div>         
        </div><br/>
        <div class="slds-grid">
            <div class="slds-size_1-of-12">
                <apex:commandButton action="{!fetchopp}" value="Search" styleClass="slds-button slds-button_brand"/>
            </div>
            <div class="slds-size_1-of-12">
                <apex:outputPanel rendered="{!showbtn}" >
                    <apex:commandButton action="{!sendEmail}" value="Send Email" styleClass="slds-button slds-button_brand"/>
                </apex:outputPanel>              
            </div>            
        </div> 
        <div class="slds-p-top_small">
            <apex:outputPanel rendered="{!show}">
                <table  class="slds-table slds-table_cell-buffer slds-table_bordered slds-p-top_small" >
                    <thead>
                        <tr>
                            <th class="" scope="col">
                                <div class="slds-truncate" >
                                    <input type="checkbox" value="" onclick="checkAll(this,'checkedone')"/>
                                </div>
                            </th>
                            
                            <th class="" scope="col">
                                <div class="slds-truncate" >Id</div>
                            </th>
                            
                            <th class="" scope="col">
                                <div class="slds-truncate" title="Last Name">Opportunity Name</div>
                            </th> 
                            <th class="" scope="col">
                                <div class="slds-truncate" title="Email">Stage </div>
                            </th>                            
                        </tr>
                    </thead>                   
                    <tbody>
                        <apex:repeat value="{!wrapList}" var="con">
                            <tr class="slds-hint-parent">
                                <td><apex:inputCheckbox value="{!con.selected}" id="checkedone"/></td>
                                <td data-label="Id" >
                                    <div class="slds-truncate" title="Id"><apex:outputField value="{!con.opps.Id}"/> </div>
                                </td>
                                <td data-label="Opportunity Name" >
                                    <div class="slds-truncate" title=" Opportunity Name"> <Apex:outputfield value="{!con.opps.Name}"/></div>
                                </td> 
                                <td data-label="Stage Name">
                                    <div class="slds-truncate" title="Stage Name"> <apex:outputfield value="{!con.opps.StageName}"/></div>
                                </td>                               
                            </tr>
                        </apex:repeat> 
                    </tbody>
                </table>
            </apex:outputPanel>
        </div>
    </apex:form>
</apex:page>
Hi all,

we have a VF Page and Apex Class for Inline Edit Table to update each month in a separate column.  We have an Edit, Save and Cancel function for the table itself, however, whenever we update the actual record or refresh the page the values wipe and reset.  Below is the details of the VF Page.  Any recommendations on how to get these values to stick?

<apex:page standardController="Case" extensions="MonthTableExample">
    <apex:form >
        <apex:pageBlock title="Inline Visualforce Page Example">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
                <apex:commandButton action="{!save}" id="saveButton" value="Save" style="display: none;"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel" style="display: none;"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!caseList}" var="month" id="thePageBlockTable">
                <apex:repeat value="{!months}" var="month" >
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputText value="{!month}"/>
                        </apex:facet>
                        <apex:outputField value="{!caseList[0].Jan__c}" rendered="{!If(month == 'January', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Feb__c}" rendered="{!If(month == 'February', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Mar__c}" rendered="{!If(month == 'March', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Apr__c}" rendered="{!If(month == 'April', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].May__c}" rendered="{!If(month == 'May', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Jun__c}" rendered="{!If(month == 'June', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Jul__c}" rendered="{!If(month == 'July', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Aug__c}" rendered="{!If(month == 'August', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Sep__c}" rendered="{!If(month == 'September', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Oct__c}" rendered="{!If(month == 'October', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Nov__c}" rendered="{!If(month == 'November', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                        <apex:outputField value="{!caseList[0].Dec__c}" rendered="{!If(month == 'December', true, false)}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                        </apex:outputField>
                    </apex:column>
                </apex:repeat>
            </apex:pageBlockTable>
        </apex:pageBlock>
        
    <!--
<apex:pageBlock id="thePageBlock">
        <apex:pageBlockTable value="{!caseList}" var="month" id="thePageBlockTable">
            <apex:column >
                <apex:outputField value="{!month.Jan__c}" />
                <apex:facet name="January">Name</apex:facet>
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Feb__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Mar__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Apr__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.May__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Jun__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Jul__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Aug__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Sep__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Oct__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Nov__c}" />
            </apex:column>
            <apex:column >
                <apex:outputField value="{!month.Dec__c}" />
            </apex:column>
            <apex:inlineEditSupport event="ondblClick" 
              showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
            
           </apex:pageBlockTable>
        </apex:pageBlock> -->

       </apex:form>
</apex:page>
Hi,

I am trying to create the VF page. However, I am seeing the erros that I am normally not seeing in outside code editor: the errors are:

Error: Proof_Templatetest line 15, column 134: The element type "br" must be terminated by the matching end-tag "</br>"
Error: The element type "br" must be terminated by the matching end-tag "</br>".

While </br> are line break tags and should be used as it is. You don't keep opening tags for </br>. I am confused. 
The code is: 
 
<messaging:emailTemplate subject="Mac Pro PO# {!relatedTo.TLS_PO_Number__c} Order on Hold Clarification Required. Case #{!relatedTo.TRNumber}, Order #{!relatedTo.TLS_Order_Number__c}, {!relatedTo.ThreadID_FK__c}" 
recipientType="Contact"  relatedToType="case">

    <messaging:htmlEmailBody >

<html>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:.5in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt">
<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"></span><span style="font-size:10.0pt;font-family:'source sans pro;;color:#1F497D">&nbsp;</span><span class="separator"></span></p>
<table class="MsoNormalTable" border="1" cellpadding="0" width="100%" style="width:100.0%">
<tbody>

 <p align="center" style="text-align:center"><b>THANKS FOR ORDERING FROM Mac Pro</b><br>All we need now is your proof approval!</p>
 
  <p align="center" style="text-align:center">Please be advised that your order is <u><b>ON HOLD</b></u> until your proof is approved without revisions. Production will begin as soon as we get your go-ahead.</p>
  
  <p> <b>Please click the link below to view your proof.</b> Issues opening the link? Simply copy and paste it into your browser.</p>
 

<p class="MsoNormal"></p>


<p><b>PO Number:</b> {!relatedTo.PO_Number__c} &nbsp; &nbsp; <b>Order Number:</b> {!relatedTo.TLS_Order_ID__c}</p>

<p class="MsoNormal"><br/>
______________________________________________________________________ <br/><br/>
Please carefully review for the following:<br/><br/>

Typographical Errors &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Correct Layout   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;Exact Position and Size              <br/><br/>
Correct Imprint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Valid Color Separation&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
Colors  Missing Type/Copy/Logos  <br/>
______________________________________________________________________</p>
<p>Issues: <br/>
<br/><c:clarQuestions rcaseID="{!relatedTo}"/>
<br/>
</p>
<p>
______________________________________________________________________<br/>
<p>You can continue to track this order right on our website! It’s quick and easy when you <a href="https://www.MACPRO.com/US/login">log in</a>  to your account or <a href="https://www.MACPRO/US/RegisterCustomerAccount">create a login</a> at <a href="https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fwww.TLS.com&amp;c=E,1,RSHyRGRSU_HM5UwVlcvcLAvN46Oi2USrS1x_vOlFPyA1ub67wthQhaxFnltmUfMEkBiyy_SfDlmhvN2rw1E9xbIn3vH7Wz7XqIgRclBx50yAfPncCE3sn6CQ9uE,&amp;typo=1">www.MACPRO.com</a></p></br>

<p>All the best, </br>
The Macpro Customer Care Team</p>

</div>
</body>
</html>
    </messaging:htmlEmailBody>

</messaging:emailTemplate>

 
I am using apex:chart tag on visualforce page, to display a chart to community users having a "Customer Community Login" license.

I've added the VF component on builder, enabled the respective VF page and controller class. But when I publish the changes, those changes don't reflect on the community for users.

What is the problem here? How should I resolve it?
 
Hi Experts,

I have a controller like below.

public class paramtest {
    public string value { get; set;}
    public string Availability_Mon { get; set;}
    public string Availability_Tue { get; set;}
    public string Availability_Wed { get; set;}
    public string Availability_Thur { get; set;}
    public string Availability_Fri { get; set;}
    
    public map<String,String> AvailabilityMap = new map<String, String>();
    
public void loadValues()
    {
    AvailabilityMap.put('Monday', 'Karthic1');
    AvailabilityMap.put('Tuesday', 'Karthic2');
    AvailabilityMap.put('Wednesday', 'Karthic3');
    AvailabilityMap.put('Thursday', 'Karthic4');
    AvailabilityMap.put('Friday', 'Karthic5');
    assignValues();
    }
    
    public void assignValues()
    {
    Availability_Mon = AvailabilityMap.get('Monday');
    Availability_Tue = AvailabilityMap.get('Tuesday');
    Availability_Wed = AvailabilityMap.get('Wednesday');
    Availability_Thur = AvailabilityMap.get('Thursday');
    Availability_Fri = AvailabilityMap.get('Friday');
    }
}

My VF is like below.

<apex:page controller="paramtest" docType="html-5.0">
<apex:form >
<apex:pageBlock title="Core Categories" id="pgCoreCategories">
           <table border="0.3px" width="100%" height="80%" style="page-break-inside:auto; text-align: center;">
                   <tr style="text-align: center;">
                       <th style="font-size:125%;"></th>
                       <th style="font-size:125%; text-align: center;">Standard Timing</th>
                       <th style="font-size:125%; text-align: center;">Monday</th>
                       <th style="font-size:125%; text-align: center;">Tuesday</th>
                       <th style="font-size:125%; text-align: center;">Wednesday</th>
                       <th style="font-size:125%; text-align: center;">Thursday</th>
                       <th style="font-size:125%; text-align: center;">Friday</th>
                       <th style="font-size:125%; text-align: center;">During Week</th>
                   </tr>
                  <tr>
                       <th style="font-size:125%;">Pre-Vet Reviews</th>
                       <th style="font-size:125%; text-align: center;">180 Mins</th>
                       <td><apex:inputText value="{!Availability_Mon}" id="inputPrevetReviewMon" html-class="CoreMonday" onkeyup="testMethod()"  style="text-align: center;" html-placeholder="Enter # of files"/></td>
                       <td><apex:inputText value="{!Availability_Tue}" id="inputPrevetReviewTue" html-class="CoreTuesday" onkeyup="testMethod()"  style="text-align: center;" html-placeholder="Enter # of files"/></td>
                       <td><apex:inputText value="{!Availability_Wed}" id="inputPrevetReviewWed" html-class="CoreWednesday" onkeyup="testMethod()" style="text-align: center;" html-placeholder="Enter # of files"/></td>
                       <td><apex:inputText value="{!Availability_Thur}" id="inputPrevetReviewThur" html-class="CoreThursday" onkeyup="testMethod()" style="text-align: center;"  html-placeholder="Enter # of files"/></td>
                       <td><apex:inputText value="{!Availability_Fri}" id="inputPrevetReviewFri" html-class="CoreFriday" onkeyup="testMethod()"  style="text-align: center;" html-placeholder="Enter # of files"/></td>
                       <td><apex:inputText value="{!Availability_Fri}" id="inputPrevetReviewDummy" html-class="CoreDummy" onkeyup="testMethod()" style="text-align: center;" html-placeholder="Enter # of files"/></td>
                       
                   </tr>
                </table>
                </apex:pageBlock>   
                


</apex:form>
</apex:page>

I wanted the assign the values from my map to all the input feilds available on my visualforce page on pageload.

Kindly help me on how to achieve this.

Regards
Karthic Sankar V P
Hi and appreciate any insight on this.

My save button no longer works.  It was a VS button.  I made a new List View button calling VFP/ APEX  Not sure what went wrong here.  

Button
 
User-added image

VFP.
<apex:page standardController="Case" recordSetVar="cases" lightningStylesheets="true" extensions="setQuickCaseExtensionController"> 
    <apex:form >
        <apex:pageBlock title="Quick Case Entry" mode="edit">
            <apex:pageMessages id="showmsg"></apex:pageMessages>
            
            <apex:pageBlockSection title="Case Details" columns="1">                 
                                
              <apex:inputField label="Source Type" required="true" value="{!case.Source_Type__c}" /> 
              <apex:inputField label="Origin" required="true" value="{!case.Origin}"/>  
              <apex:inputField label="Contact" value="{!case.ContactId}"/> 
              <apex:inputField label="Subject" required="true" value="{!case.Subject}"/> 
              <apex:inputTextArea style="width:300px;height:100px" required="true" label="Description (Min 10 chars)"  value="{!case.Description}"/>
              <apex:inputField label="Category" required="true" value="{!case.Category__c}"/> 
              <apex:inputField label="Sub-Catagory 1" required="true" value="{!case.Sub_Catagory_1__c}"/>  
              <apex:inputField label="Sub-Catagory 2" required="true" value="{!case.Sub_Category_2__c}"/>  
              <apex:inputField label="Sub-Catagory 3" required="true" value="{!case.Sub_Category_3__c}"/>              
              <apex:inputField value="{!case.Related_Account__c}" label="Account"/>          
              <apex:inputField value="{!case.Incident_Occurence_Date__c}" label="Incident Occurrence Date"/>
              <apex:inputField value="{!case.Incident_Occurrence_Time__c}" label="Incident Occurrence Time"/>  
             </apex:pageBlockSection>   
            
            <apex:pageBlockButtons > 
                <apex:commandButton value="Save & Close Quick Case" action="{!save}"/> 
                <apex:commandButton value="Cancel" action="{!cancel}"/> 
            </apex:pageBlockButtons> 
                       
          
        </apex:pageBlock> 
    </apex:form>
</apex:page>

APEX Class

public class setQuickCaseExtensionController {
   private Case QC; 
   public ApexPages.StandardSetController stdController; 
   public setQuickCaseExtensionController(ApexPages.StandardSetController controller){
        controller.setPageSize(10);
        this.QC = (Case)controller.getRecord(); 
        RecordType RecId = new RecordType();
        RecId=[SELECT Id FROM RecordType where Name='Customer First' LIMIT 1];
        QC.RecordTypeId=RecId.Id;
        QC.Quick_Case__c = True;
        QC.Origin = 'Phone';
        QC.Source_Type__c = 'Consumer';
        QC.Description='Quick Case';
        QC.Quick_Case_Closed__c = True;
        QC.Subject='New Quick Case';
        stdcontroller=controller;        
    }

}
Hi,
I am trying to display the records in coloumns using <apex:selectRadio> in <apex:repeat>, but the alignment is differing based on the number of characters field having. Here is the output User-added image
Please help me on this
Trying to have a method that counts and then updates fields on the Lead object with the notes have been created by ouur API service. We have two fields on the lead for Tour Count and Web Submission count but no matter what I try I keep getting this error. Am I calling the SOQL wrong here? 

Error: Didn't understand relationship 'Note__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.

as well as Variable does not exist: Note__r
 
public class Notefunctions {     
    
    public static void countofNotesInLead(List<Note> Nte){
        
        Set<Id> parentIds = new Set<Id>();

		for(Note n :Nte) {
			parentIds.add(n.ParentId);
		}
        
        if(!parentIds.isEmpty()){
            List<Lead> leadList = [Select Id,Count_of_Tour_Requests__c,Count_of_Web_Submissions__c, 
                                   (Select Body,Id,ParentId,Title from Note__r 
                                    WHERE Title LIKE '%Web Submission%' 
                                    AND CreatedBy.Username LIKE '%web.integrations@%') 
                                   	from Lead where Id IN:parentIds FOR UPDATE];
            
            Map<Id, Integer> tourNoteMap = new Map<Id, Integer>();
            for(Lead lead: leadList){
                Integer count = 0;
                for(Note note: lead.Note__r){
                    if(note.Body.containsIgnoreCase('In Person Tour') || note.Body.containsIgnoreCase('Virtual Tour')){
                        count++;
                    }
                }
                if(count != 0){
                    tourNoteMap.put(lead.Id, count);
                }
            }
            
            List<Lead> leadUpdateList = new List<Lead>();
            for(Lead l : leadList){
                Boolean isHaveRecs = l.Note__r.size() > 0 ? True : False;
                if(isHaveRecs){
                    l.Count_of_Web_Submissions__c = l.Note__r.size();
                    
                    if(tourNoteMap.containsKey(l.Id)){
                        l.Count_of_Tour_Requests__c = tourNoteMap.get(l.Id);
                    }
                    
                    leadUpdateList.add(l);
                }
            }
            
            if(!leadUpdateList.isEmpty())    update leadUpdateList;
            
        }
    }
}

 
APEX code:

public with sharing class InnerSOQLQuery {
    
    
    public List<Invoice__c> invList {get;set;}
    
   public List<Item_Detail__c> itemDetail {get;set;}
    
    public  void getRelatedRecords(){
   
     itemDetail = new List<Item_Detail__c>();
            
 invList = [SELECT Invoice_Number_c, Product_Detailsc, (SELECT Name, Quantityc, Ratec FROM Item_Detailsr LIMIT 7) FROM Invoice_c WHERE Id = 'a015w00001FG4gz'];
      
        for(Invoice__c Invs:invList){
            
            for( Item_Detail_c itm:Invs.Item_Details_r){
                itemDetail.add(itm);
                system.debug('Item Name-->'+ itm.Name+ '-->Rate-->'+itm.Rate_c + '-->Quantity-->'+itm.Quantity_c);
            }
        }  
        system.debug('Item Name-->'+ itemDetail);
       
    }
}

VF Code>

<apex:page controller="InnerSOQLQuery"   docType="html-5.0" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="true">

  <apex:pageBlock title="My Content">
    <apex:repeat value="{!invList}" var="acct">
        <apex:outputText value="{!acct.Product_Details__c}"/>
        
        <apex:repeat value="{!acct.Item_Details__r}" var="obj2">
            <apex:outputText value="{!obj2.Name}"/>
        </apex:repeat>
    </apex:repeat>
</apex:pageBlock>
</apex:page>

Result:

User-added image

But my Controller shows proper Output while executing via Anonymous window:

It fetches Child records
I have a VF Page wherein I have a form that the user inputs. The issue is when I click on Save1 only the "Cleaning_Activity__c" should get saved but VF page executes the whole page and because of that the required fields are throwing error in other sections. See the below image.
User-added image

How to separate the two sections such that when I click Save1 the Cleaning activity gets inserted and record gets saved?

VF Code:
<apex:page controller="i2"  sidebar="false" lightningStylesheets="true" >
    
    <script >
    function mysave1(Clicked_Id){
        var id = Clicked_Id.id;
        if(id='1')
        {
            save1();
        }
        else{
            save2();
        }
    }
    </script>

    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en">
        <head>
            <meta charset="utf-8" />
            <meta http-equiv="x-ua-compatible" content="ie=edge" />
            <title>SLDS ResponsiveDesign Visualforce Page in Salesforce Mobile</title>
            <meta name="viewport" content="width=device-width, initial-scale=1" />
            
            <!-- Import the Design System style sheet -->
            <apex:slds />
        </head>
        <body>
            
            <!-- REQUIRED SLDS WRAPPER -->
            <div class="slds-scope">
                
                <!-- PRIMARY CONTENT WRAPPER -->
                
                <!-- RESPONSIVE GRID EXAMPLE -->
                
                
                
                <style>
                    .mystyle {
                    
                    color: black;
                    font-size: 18px;
                    font-weight: bold;
                    }
                </style>
                
                <style>
                    body .bPageBlock .pbBody .grey .pbSubheader{
                    background-color:#585858;
                    
                    color:white;
                    font-size:100}
                    }
                    
                    }
                </style>
                
                <apex:form id="theform" >
                    
                    
                    <apex:pageBlock id="thePageBlock" >
                        <div class = "mystyle">
                            Maintenance Activities
                        </div>

                        <apex:pageMessages id="showmsg"></apex:pageMessages>
                        
                        <apex:pageBlockSection columns="1" >
                            <apex:outputPanel styleClass="grey" layout="block">
                                <apex:pageBlockSection columns="2" title="Cleaning Activity" id="section1" collapsible="false">
                                    <apex:inputField value="{!cle.Operation__c}"/>
                                    <apex:inputField value="{!cle.Cleaning_Company__c}"/>
                                    <apex:inputField value="{!cle.Cleaning_Start_Date__c}"/>
                                    <apex:inputField value="{!cle.Cleaning_End_Date__c}"/>
                                    <apex:inputField value="{!cle.Date_of_Cleaning__c}"/>
                                    <apex:inputField value="{!cle.Full_Site_Cleaning__c}"/>
                                    <apex:inputField value="{!cle.Qualtiy_of_Cleaning__c}"/>
                                    <apex:inputField value="{!cle.Specific_Size_Cleaned_kWp__c}"/>
                                    <apex:inputField value="{!cle.Status__c}"/>
                                    <apex:inputField value="{!cle.URL_of_Photos_folder__c}"/>
                                    <apex:inputField value="{!cle.Password__c}"/>
                                </apex:pageBlockSection> 
                            </apex:outputPanel>
                            
                            
                            <apex:actionFunction name="save1" action="{!save1}"  />
                            <input type = "button" id="1" value="Save1" onclick = "mysave1(this.id)"  />   
                     
                            <apex:outputPanel styleClass="grey" layout="block">
                                <apex:pageBlockSection columns="1" title="Permit to Work Number"  collapsible="false">
                                    <apex:inputField value="{!ptw.PTW_Number__c}"/>
                                    <apex:inputField value="{!ptw.Number_of_Workers__c}"/>
                                    <apex:inputField value="{!ptw.Date__c}"/>
                                    <apex:inputField value="{!ptw.Maintenance_Ticket__c}"/>
                                </apex:pageBlockSection> 
                            </apex:outputPanel>
                            
                            <apex:actionFunction name="save2" action="{!save2}"  />
                            <input type = "button"  id ="2" value="Save2" onclick = "mysave1(this.id)" />        
                           
                        </apex:pageBlockSection>
     
                        <apex:outputPanel styleClass="grey" layout="block">
                            <apex:pageBlockTable value="{!clelist}" var="a">
                                <apex:column headerValue="Cleaning Ticket Number">
                                    <apex:outputLink value="https://c.ap2.visual.force.com/apex/Record_detail_Vf_Page?id = {a.Cleaning_Activity__c}">{!a.Name}</apex:outputLink>
                                </apex:column>
                                <apex:column value="{!a.Password__c}"/>
                                
                                
                            </apex:pageBlockTable> 
                        </apex:outputPanel>
                    </apex:pageBlock>
                    
                </apex:form>
                <!-- / RESPONSIVE GRID EXAMPLE -->
            </div>
        </body>
    </html>
</apex:page>

Class:
public class i2{
    public Cleaning_Activity__c cle{get;set;}
    public Permit_to_Work_Number__c ptw{get;set;}
    public List<Cleaning_Activity__c> clelist{get;set;}
    
    //constructor to create a new record
    public i2(){
        cle = new Cleaning_Activity__c();
        ptw = new Permit_to_Work_Number__c();  
    }
    
    public void save1(){  
        if(cle.Password__c == 'pv' || cle.Password__c == 'sunsure')
        {
            
            insert cle;
            clelist = [SELECT Name, Password__c FROM Cleaning_Activity__c where Password__c =: cle.Password__c];
            
            /*if(cle.Id != null)
            {
                ptw.Cleaning_Activity__c = cle.Id;
            }
            if(ptw.PTW_Number__c!=null)
            {
                insert ptw;
            }*/
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Record Inserted Successfully'));
            cle = new Cleaning_Activity__c();
            
        }
        else
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Password is incorrect'));    
    }
    
    
    public void save2(){  
        if(cle.Password__c == 'pv' || cle.Password__c == 'sunsure')
     {
            
            if(ptw.PTW_Number__c!=null)
            {
                insert ptw;
            }
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Record Inserted Successfully'));
            ptw = new Permit_to_Work_Number__c(); 
       }
        else
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Password is incorrect'));
        
        
        
        
    }
}

​​​​​​​
Hi guys,
i want to share with you a solution I come up with, to wrap long url when rendering a VF page.
Basically the problem was this:
A customer pasted a very long URL (more than 400 chars) in a Rich Text Area. When rendering the page as PDF, to print it, the URL overflow the page margin, so it wasn't visible at all.

This is the code i come up with
private String addWhiteSpaceInUrlTooLong(String text) {
        // Step 1 - Search anchor links
        Pattern ptn = Pattern.compile('<a[^>]*(>.*?)</a>'); // WATCH OUT! This regex doesn't match nested anchor
        Matcher mch = ptn.matcher(text);
        Integer charPerLine = 50; // A whitespace is inserted each charPerLine chars
        while (mch.find()) {
            String toReplace = mch.group(1);
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine) //No need to replace
                continue;

            Integer elems; // White space to insert

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);            
        }

        // Step 2 - Search pasted links
        ptn = Pattern.compile('\\b\\s(https?://\\S.*?)(\\s|$)');
        mch = ptn.matcher(text);
        charPerLine = 60;

        while(mch.find()) {
            String toReplace = mch.group();
            String substitute = '';
            Integer len = toReplace.length();

            if (len < charPerLine)
                continue;

            Integer elems;

            if (len / charPerLine == 0)
                elems = len / charPerLine;
            else
                elems = len / charPerLine + 1;

            // Insert white spaces
            for (Integer i = 1; i <= elems; i++) {
                if ((charPerLine * i) < len)
                    substitute += toReplace.substring(charPerLine * (i - 1), charPerLine * i) + ' ';
                else
                    substitute += toReplace.substring(charPerLine * (i - 1), len) + ' ';
            }

            text = text.replace(toReplace, substitute);
        }

        return text;
    }

You could use like this:
MyCustomObject.richText = addWhiteSpaceInUrlTooLOng(MyCustomObject.richText);
Hope it will be useful ;)
 
Hi.

In the VF I used the date format as YYYY-MM-dd in the 
<apex:outputText value="{0,date,YYYY/MM/dd}">
Before the last week of the year it was OK. When the new year falls in the  last week of Decemeber comes the issue.
For example
2014:
S   M  T  W Th F Sat
28 29 30 31 1   2 3

In the above calendar 1st Jan of 2015 falls in the Thurusday.So when I viewd the records of 28,29,30 of December 2014 It showed as
2015-12-28
2015-12-29
2015-12-30
2015-12-31

After that I came to know that
@"YYYY" is week-based calendar year.
@"yyyy" is ordinary calendar year.
http://realmacsoftware.com/blog/working-with-date-and-time

cheers
suresh