• Joe Hayes
  • NEWBIE
  • 260 Points
  • Member since 2015
  • Certsure

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 39
    Questions
  • 48
    Replies
I want to display the send with DocuSign button only for specific users. 
I cant create multiple layouts for each profile 
I saw that you can not override the visualforce button to be displayed only for specific profiles.

It exist some sort of workaround to this ? 

Thx in advance
  • February 01, 2019
  • Like
  • 0
This might be simple but I don't know why it doesnt work.
 
Decimal pricePerPerson = 100.00;
Decimal sellPerPerson = 1.1764705882352 * pricePerPerson;
sellPerPerson = sellPerPerson.setScale(2);
This returns 117.65 as expectd.

However this...
Integer discountPercent = 15;
Decimal pricePerPerson = 100.00;
Decimal sellPerPerson = (100/(100-discountPercent)) * pricePerPerson;
sellPerPerson = sellPerPerson.setScale(2);
returns 100.00 and I'm not sure why. It should also return 117.65
 
I have a site that I want to use to upload files to users accounts.

I already have the site up and running and it can push data into salesforce and create records.

I am now trying to use an <apex:inputFile> in the page so users can upload files to the account.

When I add this and then call my upload method I get an unauthorized message. I have checked permissions and cannot find anything relating to attachments. I have ticked the "Allow site guest users to upload files" box.

Code is as follows:

Page (I have removed other fields, images etc but nothing that affects this issue)
<apex:page sidebar="false" showHeader="false" applyBodyTag="false" applyHtmlTag="false" standardStyleSheets="false" controller="CustomPortalController">
<html>
<body>
<apex:form>
  <table>
    <tr>            
      <td>Please attach PO here: </td>
      <td><apex:inputfile value="{!poBlob}" filename="PO.pdf"/></td>
    </tr>
    <tr>
      <td><apex:commandbutton action="{!insertAttachment}" value="Confirm Booking" oncomplete="trainingConf();"></apex:commandbutton>
       </td>
    </tr>
  </table>
</apex:form>
</body>
</html>
</apex:page>

Controller (Other things happen in this controller that I have removed but don't affect this issue)
public class CustomPortalController {

    public Attachment attach {get;set;}
    public transient Blob poBlob {get; set;}

public PageReference insertAttachment(){
    String oppId = ApexPages.currentPage().getParameters().get('id'); 
               
    attach.parentId = oppId;
    attach.name = 'POName.pdf';
    attach.body = poBlob;
    insert attach;
        
    return null;
    }

}


 
This should be easy but I can't find a good answer for it.

I have a string e.g.
String text = 'Send Email (3 Days Prior); Laptops (5 Days Prior); Make Phone call (2 Days Prior)';

What I need to end up with is a list or map or something that has String and Integers

The above text will then be in a table like this so I can query and fetch values.

String                    Integer
Send Email              3
Laptops                    5
Make Phone Call     2

At the moment I am doing the following:
List<String> initialList = new List<String>();
        initialList.addAll(venueTasks.split(';'));

        String initialListString = initialList.toString();
initialListString = initialListString.replaceAll(' (',';');
initialListString = initialListString.replaceAll(' Days Prior)','');

This then gives me SendEmail;3;Laptops;5;etc

I'm just not sure how to do this properly and get it into a table.

The end goal is to for loop over the list/map and create tasks where subject is the string and activity date is system.today() + integer

Thanks

 
I have ran the below code through a couple of JS validators and everything seems to be ok. Not sure where I am going wrong with this one. I get an unexpected or invalid token error. It is script for a javascript button on the opportunity page.
 
{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/42.0/apex.js")}

var location = "{!Opportunity.Location_for_Training__c}";

if(location.length > 0) {

var opp = new sforce.SObject("Opportunity");
opp.Id = "{!Opportunity.Id}";
opp.InHouseDateRequestChkBox__c = true;

var result = sforce.connection.update([opp]); 
if(result[0].success == 'true') 
{ 
alert("Dates requested!");

var t = new sforce.SObject("Task");
var today = new Date();
t.Subject = "In-house Dates Requested";
t.Status = "Completed";
t.OwnerId = "{!User.Id}";
t.ActivityDate = today;
t.WhatId = opp.Id;
t.recordTypeId = "012D0000000YTTW";

opp.InHouseDateRequestChkBox__c = false;

result = sforce.connection.create([t]);
result = sforce.connection.update([opp]);

window.location.reload();
} else 
  { 
   alert("Sending failed");
  }

} else 
  {
   alert("Please add a location for training before requesting dates");
  }

 
I have a JS button to update a text field with todays date and then redirect to a different page. I'm not sure why it always errors.
 
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")}

    var opp = new sforce.SObject("Opportunity");
        opp.Id = "{!Opportunity.Id}";

    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth();
    var yyyy = today.getFullYear();

    if (dd < 10) { 
            dd = '0' + dd;
        } 
        if (mm < 10) { 
            mm = '0' + mm;
        }
    
    opp.Docusign_Send_Date__c = dd + '/' + mm + '/' + yyyy;

    var result = sforce.connection.update(opp);

    if(result[0].success === "true"){
        window.location = 'PAGE-REDIRECT-URL-HERE';
    }
    else{
     
   alert(
            "An Error has Occurred. Error: " +
            result[0].errors.message
        );
    }

Thanks
I have a vf page that creates multiple records on an object.

The page has rows with text and date fields in for each record to be created.

I want to update a hidden inpuit field on each row but cannot figure out how to do this for multiple rows.

The page works well at the moment for inserting multiple records but only the first record gets the hidden field updated.

I'm using JS with [data-html-fields] to set the value of the hidden field.

Can anyone suggest the correct way to do this?
 
<script type="text/javascript">
    
    function updateHidden() {
        var sellist = document.querySelectorAll("[data-sellist]"),
            inpfield = document.querySelectorAll("[data-inpfield]"),
            inpnew = document.querySelectorAll("[data-inpnew]");
			
        for (var i = 0; i < {!rowNum}; i++)
          {
          inpnew[i].value = sellist[i].value + ' - ' + inpfield[i].value;
          }
      }

</script>
    
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Event Delegates"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!DelegateList}" var="del" style="width:100%">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertDelRow}"/>
                </apex:facet>
                <apex:column headerValue="Name" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Name__c}" id="inpfield" required="true" html-data-inpfield="1" onKeyUp="updatehidden()"/>
                </apex:column>
                <apex:column headerValue="Phone" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Phone__c}" id="phone"/>
                </apex:column>  
                <apex:column headerValue="Email" style="width:12%">
                    <apex:inputField style="width:98%" value="{!del.Email_Address__c}" id="email" required="true"/>
                </apex:column>
                <apex:column headerValue="Job Role" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Job_Role__c}" id="jobrole"/>
                </apex:column>
                <apex:column headerValue="Company Name" style="width:12%">
                    <apex:inputField style="width:85%" value="{!del.Company_Name__c}" id="companyname" required="true"/>
                </apex:column>
                <apex:column headerValue="Event Type" style="width:11%">
                <apex:actionRegion >
                <apex:selectList style="width:98%" value="{!selectedType}" multiselect="false" html-data-sellist="1" size="1" id="sellist" onchange="updateHidden()">
                <apex:selectOption itemValue="TechTalk" itemLabel="Tech-Talk"/>
                <apex:selectOption itemValue="Scotland Roadshow" itemLabel="Scotland Roadshow"/>
                <apex:selectOption itemValue="NICEIC/ELECSA Live" itemLabel="NICEIC/ELECSA Live"/>
                <apex:actionSupport event="onchange" reRender="venue"/>
                </apex:selectList>
                </apex:actionRegion>
                </apex:column>
                <apex:column headerValue="Venue" style="width:20%">
                    <apex:selectList value="{!del.Venue__c}" style="width:98%" size="1" id="venue">
                        <apex:selectOptions value="{!venues}"/>
                    </apex:selectList>
                </apex:column>
                <apex:column headerValue="Date" style="width:8%">
                    <apex:inputField value="{!del.Event_Date__c}" style="width:98%" required="true" html-data-datefield="1"/>
                </apex:column>
                <apex:column headerValue="FOC?">
                    <apex:inputcheckbox value="{!del.FOC__c}" id="foc"/>
                </apex:column>
                <apex:column headerValue="Delete" style="width:3%">
                    <apex:commandLink style="font-size:15px; font-weight:bold; padding-left:30%; color:red;" value="X" action="{!delDelRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index"/>
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                    <apex:inputHidden value="{!del.Name}" html-data-inpnew="1" id="inpnew"/>
                </apex:column>
            </apex:pageBlockTable>
            <br/>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertDelegates}"/>
                <apex:commandButton value="Back" action="{!cancelDelegates}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>

 
I am designing a vf page to book people onto different events that we run.
The page has a rows asking for name, phone etc and the event that they want to be booked on.
Once the user presses save it adds the list of new records (Event_Delegates__c).

It all works fine and does what I need it to do apart from one thing. When I add a row into the table it resets the venuex SelectList and clears the information. I am not sure where the issue is in the code.

Page:
<apex:page sideBar="false" controller="BookEventsTest">
<style>
        .homeTab .pageTitleIcon, .individualPalette .homeBlock .pageTitleIcon
        {
            background-position: initial;
            background-image: url('/img/icon/profile32.png');
        }
        .dateFormat{
            display: none;
        }
</style>
    <script>
    function updatehidden() {
        var sellist = document.querySelectorAll("[data-sellist]"),
            inpfield = document.querySelectorAll("[data-inpfield]"),
            inpnew = document.querySelectorAll("[data-inpnew]"),

            for (var i = 0; i < inpfield.length; i++)
              {
              inpnew[i].value = sellist[i].value + ' - ' + inpfield[i].value;       
              }
            }
            
    function setvenue() {
            var venue = document.querySelectorAll("[data-venue]"),
                venuenew = document.querySelectorAll("[data-venuenew]"),
                datenew = document.querySelectorAll("[data-datenew]");
                
                for (var i = 0; i < inpfield.length; i++)
              {
              venuenew[i].value = venue[i].value.substring(11,255);
              datenew[i].value = venue[i].value.substring(0,8);        
              }
    }
</script>
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Event Delegates"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!DelegateList}" var="del" style="width:100%">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertDelRow}"/>
                </apex:facet>
                <apex:column headerValue="Name" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Name__c}" id="inpfield" required="true" html-data-inpfield="1" onchange="updatehidden()"/>
                </apex:column>
                <apex:column headerValue="Phone" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Phone__c}" onchange="updatehidden()" id="phone"/>
                </apex:column>  
                <apex:column headerValue="Email" style="width:12%">
                    <apex:inputField style="width:98%" value="{!del.Email_Address__c}" onchange="updatehidden()" id="email" required="true"/>
                </apex:column>
                <apex:column headerValue="Job Role" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Job_Role__c}" onchange="updatehidden()" id="jobrole"/>
                </apex:column>
                <apex:column headerValue="Company Name" style="width:12%">
                    <apex:inputField style="width:85%" value="{!del.Company_Name__c}" id="companyname" onchange="updatehidden()" required="true"/>
                </apex:column>
                <apex:column headerValue="Event Type" style="width:11%">
                <apex:actionRegion >
                <apex:selectList style="width:98%" value="{!selectedType}" multiselect="false" html-data-sellist="1" size="1" id="sellist">
                <apex:selectOption itemValue="Type1" itemLabel="Type1"/>
                <apex:selectOption itemValue="Type2" itemLabel="Type2"/>
                <apex:selectOption itemValue="Type3" itemLabel="Type3"/>
                <apex:actionSupport event="onchange" reRender="venue"/>
                </apex:selectList>
                </apex:actionRegion>
                </apex:column>
                <apex:column headerValue="Venue" style="width:20%">
                    <apex:selectList value="{!venuex}" style="width:98%" html-data-venue="1" size="1" id="venue" onchange="setvenue()">
                        <apex:selectOptions value="{!venues}"/>
                    </apex:selectList>
                </apex:column>
                <apex:column headerValue="FOC?">
                    <apex:inputcheckbox value="{!del.FOC__c}" onchange="updatehidden()" id="foc"/>
                </apex:column>
                <apex:column headerValue="Delete" style="width:3%">
                    <apex:commandLink style="font-size:15px; font-weight:bold; padding-left:30%; color:red;" value="X" action="{!delDelRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index"/>
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                    <apex:inputHidden value="{!del.Name}" html-data-inpnew="1" id="inpnew"/>
                    <apex:inputHidden value="{!del.Event_Date__c}" html-data-datenew="1" id="datenew"/>
                    <apex:inputHidden value="{!del.Venue__c}" html-data-venuenew="1" id="venuenew"/>
                </apex:column>
            </apex:pageBlockTable>
            <br/>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertDelegates}"/>
                <apex:commandButton value="Back" action="{!cancelDelegates}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class BookEventsTest {
    
    public List<Event_Delegates__c> DelegateList {get;set;}
    public Integer rowNum{get;set;}
    public String selectedType{get;set;}
    public String venuex{get;set;}
    
    //Add initial Delegate row
    {
        selectedType = 'Type1';
        venuex = '';
        DelegateList = new List<Event_Delegates__c>();
        DelegateList.add(new Event_Delegates__c());
    }
    
    //Insert DelegateList and redirect
	public PageReference insertDelegates(){
        insert DelegateList;
		PageReference reRender = new PageReference('/');
		reRender.setRedirect(true);
		return reRender;
    }
    
	//Cancel Delegate and redirect page
    public PageReference cancelDelegates(){
        PageReference reRender = new PageReference('/');
        reRender.setRedirect(true);
        return reRender;
    }
    
    //Insert Delegate Row
    public void insertdelRow(){
        if(DelegateList.Size()>0){
        Event_Delegates__c tmpdel = DelegateList.get(0);
        DelegateList.add(new Event_Delegates__c(
                                             phone__c=tmpdel.phone__c,
            								 email_address__c=tmpdel.email_address__c,
            								 company_name__c=tmpdel.Company_Name__c,
            								 venue__c=tmpdel.venue__c
                                            ));
    }
        
        else DelegateList.add(new Event_Delegates__c());
    }
    
    //Delete Delegate Row
    public void delDelRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        DelegateList.remove(rowNum);
    }
    
    //Display correct picklist depending on selectType
    public List<SelectOption> getVenues(){
       
       List<SelectOption> venueoptions = new List<SelectOption>();
       
        if(selectedType=='Type1'){
            Schema.DescribeFieldResult fieldResult = Event_Delegates__c.type1__c.getDescribe();
            List<Schema.PicklistEntry> venues = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry v : venues)
       		{
           	venueoptions.add(new SelectOption(v.getLabel(), v.getValue()));
       		}          
        }
        else if(selectedType=='Type2'){
            Schema.DescribeFieldResult fieldResult = Event_Delegates__c.type2__c.getDescribe();
            List<Schema.PicklistEntry> venues = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry v : venues)
       		{
           	venueoptions.add(new SelectOption(v.getLabel(), v.getValue()));
       		}
        }
        else if(selectedType=='Type3'){
            Schema.DescribeFieldResult fieldResult = Event_Delegates__c.type3__c.getDescribe();
            List<Schema.PicklistEntry> venues = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry v : venues)
       		{
           	venueoptions.add(new SelectOption(v.getLabel(), v.getValue()));
       		}
        }
        else{}
       
       return venueoptions;
       
       }
}

If someone could give me some pointers it would be really helpful,
Thanks​​
I have a controller that sends an email and grabs a few different attachments from different records.
Not all the records will have an attachment called 'Venue Map' so I want to stop the error if the SOQL returns null. Not sure what to do here.
 
Attachment att = [ select name, contenttype, body from Attachment where name LIKE '%Venue Map%' and ParentId = :cf.courses__r.venueid__c][0];

if(att.body.size() > 0 ){
Messaging.Emailfileattachment MyMap = new Messaging.Emailfileattachment(); MyMap.setContentType(att.contentType); MyMap.setFileName('Venue Information.pdf'); MyMap.setBody(att.Body); fileAttachments.add(MyMap);
}

mail.setFileAttachments(fileAttachments);

The code is working perfect when there is a 'Venue Map' attachment, but if there isnt it just gives me this error "List index out of bounds: 0"
I have a vf page with 2 picklists.
I need the second picklist to update when the first one changes. Rather than using selectOption for the second picklist I want to pass through the field name to rerender so that I can update the values without having to update the controller.
 
For this I though about using the following:
<apex:column headerValue="Picklist1">
                <apex:selectList value="{!Picklist1}" multiselect="false" size="1">
                <apex:selectOption itemValue="a" itemLabel="a"/>
                <apex:selectOption itemValue="b" itemLabel="b"/>
                <apex:selectOption itemValue="c" itemLabel="c"/>
                <apex:actionSupport event="onchange" reRender="b"/>
                </apex:selectList>
                </apex:column>

                <apex:column headerValue="Picklist2">
                <apex:inputField value="{!Picklist2}" id="b"></apex:inputField>
                </apex:column>
Public String Picklist1{get;set;}
Public String Picklist2 {get;set;}

  {
        if(Picklist1 == 'a'){
            Picklist2 = 'del.a__c';
        } else if (Picklist1 == 'b'){
            Picklist2 = 'del.b__c';
        }else if (Picklist1 == 'c'){
            Picklist2 = 'del.c__c';
        }else {
            Picklist2 = null;
        }
    }

I have 3 picklist fields (a,b & c) on the custom object (del) but I want picklist1 to select which picklist (a,b or c) depending.

Hope this makes sense.

 
I am looking to set a variable depending on the value of a field.

EmailTemplate template = 
    if(a__c == 'a' || a__c == 'b'){
    [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'ab_Email']}
    else {
    [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'c_Email']};

Please can someone show me the correct way to do this?

Thank you
Joe
I am using the tabbedAccount template for our accounts page. I am looking to apply additional styling with javascript when the contacts tab is clicked.
I want to change the text colour to red if the date is over 1 year ago.

I have looked at the DOM and got all the class names, i'ds etc that I need but I cannot get it working at all.
 
<apex:page standardController="Account" showHeader="true"
      tabStyle="account" >      
   <style>
      .activeTab {background-color: #F9AF31; color:black;
         background-image:none}
      .inactiveTab { background-color: #9FD8F6; color:black;
         background-image:none}
      .AcctListStyle {font-size: 10pt; font-color: #333333; background-image:none}
   </style>
   <apex:tabPanel switchType="client" selectedTab="tabdetails"
                  id="AccountTabPanel" tabClass="activeTab"
                  inactiveTabClass="inactiveTab">  
      <apex:tab label="Details" name="AccDetails" id="tabdetails" styleclass="AcctListStyle">
         <apex:detail relatedList="false" title="true"/>
      </apex:tab>
      <apex:tab label="Contacts" name="Contacts" id="tabContact" styleclass="AcctListStyle">
         <apex:relatedList subject="{!account}" list="contacts" />
      </apex:tab>
      <apex:tab label="Opportunities" name="Opportunities" id="tabOpp" styleclass="AcctListStyle">
         <apex:relatedList subject="{!account}" list="opportunities" />
      </apex:tab>
      <apex:tab label="Activities" name="OpenActivities" id="tabOpenAct" styleclass="AcctListStyle">
         <apex:relatedList subject="{!account}" list="OpenActivities" />
         <apex:relatedList subject="{!account}" list="ActivityHistories" />
      </apex:tab>
      <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt" styleclass="AcctListStyle">
         <apex:relatedList subject="{!account}" list="CombinedAttachments" />
      </apex:tab>
      <apex:tab label="Docusigns" name="Docusigns" id="Docusigns" styleclass="AcctListStyle">
         <apex:relatedList subject="{!account}" list="dsfs__R00N80000002eb1GEAQ__r" />
      </apex:tab>
      <apex:tab label="Other Applications" name="Otherapplications" id="otherApps" styleclass="AcctListStyle">
         <apex:relatedList subject="{!account}" list="Courses__r" title="Bespoke/In-house Courses"/>
      </apex:tab>
   </apex:tabPanel>

<script>
$(document).ready(function(){
  document.getElementById("j_id0:tabContact_lbl").onclick = function(){
   var date = document.getElementsByClassName("DateElement").value;
   var varDate = new Date(date);
   var today = new Date();
   var 1year = 3153600000;
   today.setHours(0,0,0,0);
     if(varDate <= today - 1year) {
         date.style.color = "red";
     };
  });
});
</script>
</apex:page>

Does anybody have any suggestions?

Thanks
Joe​
Hi,

I have a vf page that renders as a pdf. It is a certificate for a list of assessments that people have completed.
There are different types of certificate depending on what assessments they have taken.
I capture the different assessments in their own lists in my controller depending on which certificate needs to be displayed.

I have created the vf page and used rendered="{!NOT(List.Empty)}" to choose whether or not to display the page.
If there is more than 1 certificate in the pdf I need to show both.
At the moment they are rendering ontop of each other so I added a div with page-break-after:always; after my first apex:variable.

It is giving me a PDF Generation Error. Invalid Markup.
I'm not sure why?

Here is my vf page:
<apex:page standardController="Certification_Candidate__c" extensions="AssessmentTableController" showHeader="false" applyHtmlTag="false" applyBodyTag="false" renderAs="pdf" action="{!savePdf}">
<html>
<head>
<style type="text/css" media="print">
@page {
size: A4;
}
</style>
</head>
<body style="font-family: Arial Unicode MS; font-size:12px">
<apex:variable var="acs" value="" rendered="{!NOT(AsstList.Empty)}">
<div id="header" style="position:fixed;top:5%">
   <p style="font-weight:bold; text-align:center; font-size:16px">
   Page Title
   </p>
   <br/><br/>
   <apex:panelGrid columns="2" style="width:567px; font-size:16px; margin: auto,auto;">
   <apex:outputText value="Forename(s): {!Certification_Candidate__c.Forename__c}"/>
   <apex:outputText value="Surname: {!Certification_Candidate__c.Surname__c}"/>
   <apex:outputText value="Date of Birth: {!Certification_Candidate__c.Date_of_Birth__c}"/>
   <apex:outputText value="NI Number: {!Certification_Candidate__c.NI_Number__c}"/>
   </apex:panelGrid>
   </div>
   
<div id="content" style="position:fixed;top:23%">
<apex:dataTable value="{!AsstList}" var="item" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!item.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!item.Description__c}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!item.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>
<div id="footer" style="position:fixed;top:72%">                      
	...content here...
</div>
<div style="page-break-after:always"></div>
</apex:variable>



<apex:variable var="wat" value="" rendered="{!NOT(waterList.Empty)}">
<div id="header" style="position:fixed;top:5%">
   <p style="font-weight:bold; text-align:center; font-size:16px">
   Page Title
   </p>
   <br/><br/>
   <apex:panelGrid columns="2" style="width:567px; font-size:16px; margin: auto,auto;">
   <apex:outputText value="Forename(s): {!Certification_Candidate__c.Forename__c}"/>
   <apex:outputText value="Surname: {!Certification_Candidate__c.Surname__c}"/>
   <apex:outputText value="Date of Birth: {!Certification_Candidate__c.Date_of_Birth__c}"/>
   <apex:outputText value="NI Number: {!Certification_Candidate__c.NI_Number__c}"/>
   </apex:panelGrid>
   </div>
   
<div id="content" style="position:fixed;top:23%">
<apex:dataTable value="{!waterList}" var="witem" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!witem.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!witem.Description__c}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!witem.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>
<div id="footer" style="position:fixed;top:72%">                      
	...content here...
</div>
<div style="page-break-after:always"></div>
</apex:variable>
</body>
</html>
</apex:page>

I hope this makes sense.

Thanks
Joe​

 
Hi,

I am struggling with a button on a custom object called Certification_Candidate__c that collates various information and displays a vf page, rendered as pdf and then saves it as an attachment on the record.

At the moment I am getting an error in the controller Variable does not exist: Centre_Number__c at line 17 column 140
Centre_Number__c is a custom field within the accredited centre object and has a master relationship with Certification_Candidate__c so I am unsure why it cannot be seen with the SOQL.

I am also having a problem with recursion, when the vf page is loaded and the SavePDF() method is actioned it saves 5 copies to the record.
I guess what is happening is that the pdf.getContent() is calling another instance of SavePDF() and therefore it recurs.

Please can someone have a look down the code and give me some pointers where I am going wrong?

I don't write apex often enough so everytime I come to a project I have to re-learn a lot of stuff to jog my memory. It is very frustrating, I would love to out source some of the more advanced pieces but I dont think that will be the case unfortunately.

VF Page
<apex:page standardController="Certification_Candidate__c" extensions="AssessmentTableController" showHeader="false" applyHtmlTag="false" applyBodyTag="false" renderAs="pdf" action="{!SavePDF}">
<html>
<head>
<style type="text/css" media="print">
     ...various css...
</style>
</head>

<body style="font-size:12px">
<div class="header">
   <p style="font-weight:bold; text-align:center; font-size:16px">
   title
   </p>
   <apex:panelGrid columns="2" style="width:567px; font-size:16px; margin: auto,auto;">
   <apex:outputText value="Forename(s): {!Certification_Candidate__c.Forename__c}"/>
   <apex:outputText value="Surname: {!Certification_Candidate__c.Surname__c}"/>
   <apex:outputText value="Date of Birth: {!Certification_Candidate__c.Date_of_Birth__c}"/>
   <apex:outputText value="NI Number: {!Certification_Candidate__c.NI_Number__c}"/>
   </apex:panelGrid>
   </div>
                       
   <div class="footer">                      
<apex:panelGrid columns="2" width="568px" style="margin: 0px auto; font-weight:normal">
  <apex:outputText value="Date of Issue: {0, date, dd/MM/yyyy}"><apex:param value="{!NOW()}"/></apex:outputText>
    <apex:outputText value="Certificate Number: {0, date, YY}/{!Certification_Candidate__c.Accredited_Centre__r.Centre_Number__c}/{!certnum}"><apex:param value="{!NOW()}"/></apex:outputText>
</apex:panelGrid>
<apex:panelGrid columns="1" width="567px" style="margin: auto auto">
<apex:outputText value="text"/>
</apex:panelGrid>
<apex:panelGrid columns="2" width="567px" style="margin: auto auto; font-weight:normal">
  <apex:image value="https://c.eu1.content.force.com/servlet/servlet.FileDownload?file=015D00000048ZMN" alt="alt text" width="100px"/>
      <apex:outputText value=""/>
  <apex:outputtext value="text"/>
  <apex:outputtext value="text"/>
</apex:panelGrid>
<br/><br/>
<table style="font-size:8px;">
<tr>
<td width="60%"><apex:outputText value="text"/><br/><apex:outputText value="text"/><br/><apex:outputText value="tel:"/><br/><br/><br/><apex:outputtext value="address:"/><br/><apex:outputtext value="trading name"/>
</td>
<td width="30%"><apex:outputText value="text"/>
</td>
<td width="10%"><apex:image value="https://c.eu1.content.force.com/servlet/servlet.FileDownload?file=015D00000048ZMO" alt="text" width="50px"/>
</td>
</tr>
</table>
</div>

<div class="content">
<apex:dataTable value="{!AsstList}" var="item" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!item.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!item.Description__c}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!item.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>

</body>
</html>
</apex:page>

Controller
public class AssessmentTableController {
    public List <Assessment__c> asstList {get;set;}
    public String certnum;
    public String candid {get;set;}
    public String centnum;
    
    public AssessmentTableController(ApexPages.StandardController controller){
        Id candid = ApexPages.currentPage().getParameters().get('Id');
        asstList = new List<Assessment__c>();
        asstList = [select Candidate__c,codeTEXT__c,Expiry_Date__c, Description__c from Assessment__c where Expiry_Date__c > today and Candidate__r.id=:candid order by codeTEXT__c desc];

        certnum = [SELECT Description__c from Asstcodes__c WHERE name =: 'CertificateNumber' limit 1].Description__c;
    }
    
    public PageReference savePdf() {
    
    centnum = [SELECT Certification_Candidate__c.Accredited_Centre__r.Centre_Number__c from Certification_Candidate__c WHERE Id =: candid].Centre_Number__c;
    
    Attachment attachment = new Attachment();
    PageReference pdf = ApexPages.currentPage();
    Blob body;

    try {
        body = pdf.getContent(); 
    } catch (VisualforceException e) {
        body = Blob.valueOf('Some Text');
    }
    
    attachment.Body = body;
    attachment.Name = centnum + '-' + certnum + '-' + String.ValueOf(Date.Today().Year()).Right(2);
    attachment.IsPrivate = false;
    attachment.ParentId = candid;
    attachment.ContentType = 'application/pdf';
    insert attachment;
    
    String centnumNew = String.ValueOf(Integer.ValueOf(certnum)+1);
    certnum.description__c = centnumNew;
    update centnum;
    
    return null;
  }
}

Thanks for your help,

Joe​​
Hi,

This should be pretty basic,
I have a vf page to display the value of the name field of a record in a custom object called 'Certification_Accredited_Centres__c'
I also have a controller that the vf page uses.

The URL passes a paramater 'centreId' which is the id of the record I am trying to get the name value of.

At the moment all I am getting on the vf page is "Assesments taken at      " <-- the string is blank

VF Page (not complete)
<apex:page controller="AddingAssessmentsController>
<h3>
<apex:outputText value="Assesments taken at {!asscen}"/>
</h3>
</apex:page>
Controller (not complete)
public class AddingAssessmentsController {

    public Id centreId;
    
    public String asscen{get;set;}
    
    public AddingAssessmentsController(){
        centreId = ApexPages.currentPage().getParameters().get('centreId');
        String asscen = [SELECT name from Certification_Accredited_Centres__c WHERE id =: centreId].name;
    }
}

Please can someone tell me why the {!asscen} is blank in the vf page?

Thanks
Joe 
 
Hi,

I am having a bit of trouble and cannot find an answer that fits what I need.

I have 2 custom objects totally unrelated. Assessment__c, and AsstCodes__c.

AsstCodes__c has 2 fields Name and Description. Both are text fields.

What I want to achieve is this:
When I save a new Assessment__c record I want a trigger to update the Assessment__c.Description with the AsstCodes__c.Description.
The common factor is that Assessment__c.Code__c (picklist) will be the same value as a record in AsstCodes__c.Name (text value)

So far I have minimal code for this.

I know I need to do the following:
AsstCodeDescription = [SELECT description__c FROM AsstCodes__c WHERE Assessment__c.Name = AsstCode.Name LIMIT 1];
trigger AsstDesc on Assessment__c (after insert, after update)
{
    map<string, Assessment__c> TheMap = new map<string, Assessment__c>();
        
    for (Assessment__c Desc:trigger.new)
    {
        if (Desc.Name !='')
        Desc.Description__c = AsstCodeDescription;
        update desc;
    }
    
}

I am just not sure how to put it all together.​ Hope this all makes sense.

Thanks for your help
Joe
 
Hi Everyone,

I have a vf page that adds multiple child records to an object.

I have a controller for this that can add/delete rows etc.

What I want to do is update a text field with some predetermined text based on the picklist value from the vf page.
for example

PICKLIST COLUMN                  DATE COLUMN                  TEXT COLUMN
PICKLIST VALUE 1                            ---                                       ---
PICKLIST VALUE 2                            ---                                       ---

On insert I want to add "Description related to picklist value 1" into the text column for the picklist value 1 row and "Description related to picklist value 2" into the other.

There is no maximum number of rows.

There are 94 different picklist values with descriptions.

I'm guessing I would hold all the description values in the controller some how and then use the picklist value to reference them.

Just not sure how.

This is my vf page and controller so far:
<apex:page controller="AddingAssessmentsController">
    <style>
        .homeTab .pageTitleIcon, .individualPalette .homeBlock .pageTitleIcon
        {
            background-position: initial;
            background-image: url('/img/icon/wrench32.png');
        }
    </style>
    
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Assessments"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!AssessmentList}" var="asst">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertAsstRow}"/>
                </apex:facet>
                <apex:column headerValue="Code">
                    <apex:inputField value="{!asst.Code__c}" required="true"/>
                </apex:column>
                <apex:column headerValue="Last Centre Date">
                    <apex:inputField value="{!asst.LastCentreDate__c}" id="LastCentreDate"/>
                </apex:column>  
                <apex:column headerValue="Date of Tech Review">
                    <apex:inputField value="{!asst.DateofTechReview__c}" id="DateOfTechReview"/>
                </apex:column>
                <apex:column headerValue="Date Received By Cert Office">
                    <apex:inputField value="{!asst.Date_Received_By_Cert_Office__c}" id="Date_Received_By_Cert_Office"/>
                </apex:column>
                <apex:column headerValue="Assessor">
                    <apex:inputField value="{!asst.Assessor__c}" id="Assessor"/>
                </apex:column>
                <apex:column headerValue="Verifier">
                    <apex:inputField value="{!asst.Verifier__c}" id="Verifier"/>
                </apex:column>
                <apex:column headerValue="Photo Scanned">
                    <apex:inputcheckbox value="{!asst.Photo_Scanned__c}" id="photoscanned" selected="true"/>
                </apex:column>
                <apex:column headerValue="Photo Scan date">
                    <apex:inputfield value="{!asst.Photo_Scan_Date__c}" id="photo_scan_date"/>
                </apex:column>
                <apex:column headerValue="Fastrack">
                    <apex:inputcheckbox value="{!asst.Fastrack__c}" id="Fastrack"/>
                </apex:column>
                <apex:column headerValue="MOT Cert">
                    <apex:inputcheckbox value="{!asst.MOT_Cert__c}" id="Mot_cert"/>
                </apex:column>
                <apex:column headerValue="Pass?">
                    <apex:inputcheckbox value="{!asst.Pass__c}" id="pass" selected="true"/>
                </apex:column>
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delAsstRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertAssessments}"/>
                <apex:commandButton value="Back" action="{!cancelAssessments}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class AddingAssessmentsController {
    Id candId;
    Id centreId;
    
    public List<Assessment__c> AssessmentList {get;set;}
    public Integer rowNum{get;set;}
    
    //Add initial Assessment row
    public AddingAssessmentsController(){
        candId = ApexPages.currentPage().getParameters().get('candId');
        centreId = ApexPages.currentPage().getParameters().get('centreId');
        AssessmentList = new List<Assessment__c>();
        AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true, Accredited_Centre__c=centreId));
    }
    
    
        //Insert AssessmentList and redirect
        public PageReference insertAssessments(){
            insert AssessmentList;
			PageReference reRender = new PageReference('/'+candId);
			reRender.setRedirect(true);
			return reRender;
    }
    
	//Cancel Assessment and redirect page
    public PageReference cancelAssessments(){
        PageReference reRender = new PageReference('/'+candId);
        reRender.setRedirect(true);
        return reRender;
    }
    
    //Insert Assessment Row
    public void insertAsstRow(){
        if(AssessmentList.Size()>0){
        Assessment__c tmpAssessment = AssessmentList.get(0);
        AssessmentList.add(new Assessment__c(Candidate__c=candId,
                                             Verifier__c=tmpAssessment.Verifier__c,
                                             Assessor__c=tmpAssessment.Assessor__c,
                                             LastCentreDate__c=tmpAssessment.LastCentreDate__c,
                                             DateofTechReview__c=tmpAssessment.DateofTechReview__c,
                                             Date_Received_By_Cert_Office__c=tmpAssessment.Date_Received_By_Cert_Office__c,
                                             Photo_Scanned__c=tmpAssessment.Photo_Scanned__c,
                                             Photo_Scan_Date__c=tmpAssessment.Photo_Scan_Date__c,
                                             Fastrack__c=tmpAssessment.Fastrack__c,
                                             MOT_Cert__c=tmpAssessment.MOT_Cert__c,
                                             Pass__c=tmpAssessment.Pass__c,
                                             Accredited_Centre__c=centreId
                                            ));
    }
        else AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true, Accredited_Centre__c=centreId));
    }
    
    //Delete Assessment Row
    public void delAsstRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        AssessmentList.remove(rowNum);
    }
}

Thanks for your help.
Hi,

I have a vf page that renders as a pdf and displays a dataTable of results from a related list on an object, it is working well apart from the following.

I need to add a column in my data table that displays a description of the item in the 'Code' Column.
I have done this using if statements and it is working nicely, however, I am worried that I will hit the maximum formula compile size as I will be adding a lot more to this in the future.

What is the best way to get around this to generate the correct descriptions without huge multiple if statements?

section of current vf page
<div class="content">
<apex:dataTable value="{!AsstList}" var="item" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!item.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!IF(item.CodeTEXT__c = 'Code1','Code1 Description Here',
                        IF(item.CodeTEXT__c = 'Code2','Code2 Description Here',
                        IF(item.CodeTEXT__c = 'Code3','Code3 Description Here',
                        IF(item.CodeTEXT__c = 'Code4','Code4 Description Here',
                        IF(item.CodeTEXT__c = 'Code5','Code5 Description Here',
                        IF(item.CodeTEXT__c = 'Code6','Code6 Description Here','NULL'))))))}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!item.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>

Thanks
Hi,

I am writing a controller to check the Name field in a list of child records against a field called Approved_scope__c on a custom object. If the Name fields in the List are all contained in the Approved_scope__c field then it needs to insert the list, else it needs to display which of the name fields are not in the Approved_scope__c.

I have put the Approved_scope__c field into a set and then I am trying to use set.contains(List.Name)

It is giving an error at the moment on line 17 'Initial term of field expression must be a concrete SObject: List'
I'm not sure where I am going wrong.

Also how would I then get a new list of records that weren't contained in the set?

Any help would be appreciated thank you.

Controller:
public class AddingAssessmentsController {
    Id candId;
    Id centreId;
    
    public List<Assessment__c> AssessmentList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddingAssessmentsController(){
        candId = ApexPages.currentPage().getParameters().get('candId');
        AssessmentList = new List<Assessment__c>();
        AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true));
    }
        
	public PageReference insertAssessments(){
		centreId = ApexPages.currentPage().getParameters().get('centreId');
		set <Certification_Accredited_Centres__c> centreSet = new set <Certification_Accredited_Centres__c>([Select Approved_Scope__c from Certification_Accredited_Centres__c where Id = :centreId]);
          if(centreSet.contains(';' + AssessmentList.Name + ';')){
        	insert AssessmentList;
			PageReference reRender = new PageReference('/'+candId);
			reRender.setRedirect(true);
			return reRender;
        } else {
            return null; 
        }
    }

    public PageReference cancelAssessments(){
        PageReference reRender = new PageReference('/'+candId);
        reRender.setRedirect(true);
        return reRender;
    }
    
    public void insertAsstRow(){
        if(AssessmentList.Size()>0){
        Assessment__c tmpAssessment = AssessmentList.get(0);
        AssessmentList.add(new Assessment__c(Candidate__c=candId,
                                             Verifier__c=tmpAssessment.Verifier__c,
                                             Assessor__c=tmpAssessment.Assessor__c,
                                             LastCentreDate__c=tmpAssessment.LastCentreDate__c,
                                             DateofTechReview__c=tmpAssessment.DateofTechReview__c,
                                             Date_Received_By_Cert_Office__c=tmpAssessment.Date_Received_By_Cert_Office__c,
                                             Photo_Scanned__c=tmpAssessment.Photo_Scanned__c,
                                             Photo_Scan_Date__c=tmpAssessment.Photo_Scan_Date__c,
                                             Fastrack__c=tmpAssessment.Fastrack__c,
                                             MOT_Cert__c=tmpAssessment.MOT_Cert__c,
                                             Pass__c=tmpAssessment.Pass__c                                             
                                            ));
    }
        else AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true));
    }
    
    public void delAsstRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        AssessmentList.remove(rowNum);
    }
}

vf page if needed:
<apex:page controller="AddingAssessmentsController">
    <style>
        .homeTab .pageTitleIcon, .individualPalette .homeBlock .pageTitleIcon
        {
            background-position: initial;
            background-image: url('/img/icon/wrench32.png');
        }
    </style>
    
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Assessments"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!AssessmentList}" var="asst">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertAsstRow}"/>
                </apex:facet>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!asst.Name}" required="true"/>
                </apex:column>
                <apex:column headerValue="Last Centre Date">
                    <apex:inputField value="{!asst.LastCentreDate__c}" id="LastCentreDate"/>
                </apex:column>  
                <apex:column headerValue="Date of Tech Review">
                    <apex:inputField value="{!asst.DateofTechReview__c}" id="DateOfTechReview"/>
                </apex:column>
                <apex:column headerValue="Date Received By Cert Office">
                    <apex:inputField value="{!asst.Date_Received_By_Cert_Office__c}" id="Date_Received_By_Cert_Office"/>
                </apex:column>
                <apex:column headerValue="Assessor">
                    <apex:inputField value="{!asst.Assessor__c}" id="Assessor"/>
                </apex:column>
                <apex:column headerValue="Verifier">
                    <apex:inputField value="{!asst.Verifier__c}" id="Verifier"/>
                </apex:column>
                <apex:column headerValue="Photo Scanned">
                    <apex:inputcheckbox value="{!asst.Photo_Scanned__c}" id="photoscanned" selected="true"/>
                </apex:column>
                <apex:column headerValue="Photo Scan date">
                    <apex:inputfield value="{!asst.Photo_Scan_Date__c}" id="photo_scan_date"/>
                </apex:column>
                <apex:column headerValue="Fastrack">
                    <apex:inputcheckbox value="{!asst.Fastrack__c}" id="Fastrack"/>
                </apex:column>
                <apex:column headerValue="MOT Cert">
                    <apex:inputcheckbox value="{!asst.MOT_Cert__c}" id="Mot_cert"/>
                </apex:column>
                <apex:column headerValue="Pass?">
                    <apex:inputcheckbox value="{!asst.Pass__c}" id="pass" selected="true"/>
                </apex:column>
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delAsstRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertAssessments}"/>
                <apex:commandButton value="Back" action="{!cancelAssessments}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Thank you
I am writing a vf page and controller to add multiple child records to the parent at the same time. Sort of like a dynamic related list.
I have a table with 1 row to begin with and a method to add rows as needed.

When the Add row button is pressed I need to pass the values from row 1 into the new row.

I have tried to pass them using 
public string Assessor {get;set;}
but this gets the value when the page is loaded therefore it is empty when I recall it with insertAsstRow()

I need to get the values when the add row button is pressed and then I can populate the new fields from there.

Here is my vf page:
<apex:page controller="AddingAssessmentsController">
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Assessments"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!AssessmentList}" var="asst">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertAsstRow}"/>
                </apex:facet>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!asst.Name}"/>
                </apex:column>
                <apex:column headerValue="Last Centre Date">
                    <apex:inputField value="{!asst.LastCentreDate__c}" id="LastCentreDate"/>
                </apex:column>  
                <apex:column headerValue="Date of Tech Review">
                    <apex:inputField value="{!asst.DateofTechReview__c}" id="DateOfTechReview"/>
                </apex:column>
                <apex:column headerValue="Date of Received By Cert Office">
                    <apex:inputField value="{!asst.Date_Received_By_Cert_Office__c}" id="Date_Received_By_Cert_Office"/>
                </apex:column>
                <apex:column headerValue="Assessor">
                    <apex:inputField value="{!asst.Assessor__c}" id="Assessor"/>
                </apex:column>
                <apex:column headerValue="Verifier">
                    <apex:inputField value="{!asst.Verifier__c}" id="Verifier"/>
                </apex:column>
                <apex:column headerValue="Photo Scanned">
                    <apex:inputcheckbox value="{!asst.Photo_Scanned__c}" id="photoscanned" selected="true"/>
                </apex:column>
                <apex:column headerValue="Photo Scan date">
                    <apex:inputfield value="{!asst.Photo_Scan_Date__c}" id="photo_scan_date"/>
                </apex:column>
                <apex:column headerValue="Fastrack">
                    <apex:inputcheckbox value="{!asst.Fastrack__c}" id="Fastrack"/>
                </apex:column>
                <apex:column headerValue="MOT Cert">
                    <apex:inputcheckbox value="{!asst.MOT_Cert__c}" id="Mot_cert"/>
                </apex:column>
                <apex:column headerValue="Pass?">
                    <apex:inputcheckbox value="{!asst.Pass__c}" id="pass" selected="true"/>
                </apex:column>
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delAsstRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertAssessments}"/>
                <apex:commandButton value="Back" action="{!cancelAssessments}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class AddingAssessmentsController {
    Id candId;
        
    public List<Assessment__c> AssessmentList {get;set;}
    public Integer rowNum{get;set;}
   
    public AddingAssessmentsController(){
        candId = ApexPages.currentPage().getParameters().get('candId');      
        AssessmentList = new List<Assessment__c>();
        AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true));
    }
        
    public PageReference insertAssessments(){
        insert AssessmentList;
        PageReference reRender = new PageReference('/'+candId);
        reRender.setRedirect(true);
        return reRender;
    }
    
    public PageReference cancelAssessments(){
        PageReference reRender = new PageReference('/'+candId);
        reRender.setRedirect(true);
        return reRender;
    }
            
    public void insertAsstRow(){
        AssessmentList.add(new Assessment__c(Candidate__c=candId));
    }
    
    public void delAsstRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        AssessmentList.remove(rowNum);   
    }
}

Thanks
Joe
 
Hi Everyone,

I have a text field that I want to start with a date in the dd/mm/yy format.

I am trying to get a REGEX validation rule to force this but I am struggling.

I need the rule to allow dd/mm/yy - *

The* will allow any text afterward.

Would someone be able to tell me the correct expression please?

Thanks
Joe
 
This might be simple but I don't know why it doesnt work.
 
Decimal pricePerPerson = 100.00;
Decimal sellPerPerson = 1.1764705882352 * pricePerPerson;
sellPerPerson = sellPerPerson.setScale(2);
This returns 117.65 as expectd.

However this...
Integer discountPercent = 15;
Decimal pricePerPerson = 100.00;
Decimal sellPerPerson = (100/(100-discountPercent)) * pricePerPerson;
sellPerPerson = sellPerPerson.setScale(2);
returns 100.00 and I'm not sure why. It should also return 117.65
 
This should be easy but I can't find a good answer for it.

I have a string e.g.
String text = 'Send Email (3 Days Prior); Laptops (5 Days Prior); Make Phone call (2 Days Prior)';

What I need to end up with is a list or map or something that has String and Integers

The above text will then be in a table like this so I can query and fetch values.

String                    Integer
Send Email              3
Laptops                    5
Make Phone Call     2

At the moment I am doing the following:
List<String> initialList = new List<String>();
        initialList.addAll(venueTasks.split(';'));

        String initialListString = initialList.toString();
initialListString = initialListString.replaceAll(' (',';');
initialListString = initialListString.replaceAll(' Days Prior)','');

This then gives me SendEmail;3;Laptops;5;etc

I'm just not sure how to do this properly and get it into a table.

The end goal is to for loop over the list/map and create tasks where subject is the string and activity date is system.today() + integer

Thanks

 
I have a vf page that creates multiple records on an object.

The page has rows with text and date fields in for each record to be created.

I want to update a hidden inpuit field on each row but cannot figure out how to do this for multiple rows.

The page works well at the moment for inserting multiple records but only the first record gets the hidden field updated.

I'm using JS with [data-html-fields] to set the value of the hidden field.

Can anyone suggest the correct way to do this?
 
<script type="text/javascript">
    
    function updateHidden() {
        var sellist = document.querySelectorAll("[data-sellist]"),
            inpfield = document.querySelectorAll("[data-inpfield]"),
            inpnew = document.querySelectorAll("[data-inpnew]");
			
        for (var i = 0; i < {!rowNum}; i++)
          {
          inpnew[i].value = sellist[i].value + ' - ' + inpfield[i].value;
          }
      }

</script>
    
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Event Delegates"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!DelegateList}" var="del" style="width:100%">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertDelRow}"/>
                </apex:facet>
                <apex:column headerValue="Name" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Name__c}" id="inpfield" required="true" html-data-inpfield="1" onKeyUp="updatehidden()"/>
                </apex:column>
                <apex:column headerValue="Phone" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Phone__c}" id="phone"/>
                </apex:column>  
                <apex:column headerValue="Email" style="width:12%">
                    <apex:inputField style="width:98%" value="{!del.Email_Address__c}" id="email" required="true"/>
                </apex:column>
                <apex:column headerValue="Job Role" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Job_Role__c}" id="jobrole"/>
                </apex:column>
                <apex:column headerValue="Company Name" style="width:12%">
                    <apex:inputField style="width:85%" value="{!del.Company_Name__c}" id="companyname" required="true"/>
                </apex:column>
                <apex:column headerValue="Event Type" style="width:11%">
                <apex:actionRegion >
                <apex:selectList style="width:98%" value="{!selectedType}" multiselect="false" html-data-sellist="1" size="1" id="sellist" onchange="updateHidden()">
                <apex:selectOption itemValue="TechTalk" itemLabel="Tech-Talk"/>
                <apex:selectOption itemValue="Scotland Roadshow" itemLabel="Scotland Roadshow"/>
                <apex:selectOption itemValue="NICEIC/ELECSA Live" itemLabel="NICEIC/ELECSA Live"/>
                <apex:actionSupport event="onchange" reRender="venue"/>
                </apex:selectList>
                </apex:actionRegion>
                </apex:column>
                <apex:column headerValue="Venue" style="width:20%">
                    <apex:selectList value="{!del.Venue__c}" style="width:98%" size="1" id="venue">
                        <apex:selectOptions value="{!venues}"/>
                    </apex:selectList>
                </apex:column>
                <apex:column headerValue="Date" style="width:8%">
                    <apex:inputField value="{!del.Event_Date__c}" style="width:98%" required="true" html-data-datefield="1"/>
                </apex:column>
                <apex:column headerValue="FOC?">
                    <apex:inputcheckbox value="{!del.FOC__c}" id="foc"/>
                </apex:column>
                <apex:column headerValue="Delete" style="width:3%">
                    <apex:commandLink style="font-size:15px; font-weight:bold; padding-left:30%; color:red;" value="X" action="{!delDelRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index"/>
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                    <apex:inputHidden value="{!del.Name}" html-data-inpnew="1" id="inpnew"/>
                </apex:column>
            </apex:pageBlockTable>
            <br/>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertDelegates}"/>
                <apex:commandButton value="Back" action="{!cancelDelegates}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>

 
I want to display the send with DocuSign button only for specific users. 
I cant create multiple layouts for each profile 
I saw that you can not override the visualforce button to be displayed only for specific profiles.

It exist some sort of workaround to this ? 

Thx in advance
  • February 01, 2019
  • Like
  • 0
I'm trying to find out if it's possible to keep a user from changing their Profile picture?  Everything I find is about their Profile, but I'm curious about the picture itself.

Any ideas?

Thanks!
Hello:
Any recommendations on free ways salespeople can map their customers easily. I have many requests to put in a zip code and provide a list of customers within a 5-15 mile radius as an example.
 
Thanks!
I am designing a vf page to book people onto different events that we run.
The page has a rows asking for name, phone etc and the event that they want to be booked on.
Once the user presses save it adds the list of new records (Event_Delegates__c).

It all works fine and does what I need it to do apart from one thing. When I add a row into the table it resets the venuex SelectList and clears the information. I am not sure where the issue is in the code.

Page:
<apex:page sideBar="false" controller="BookEventsTest">
<style>
        .homeTab .pageTitleIcon, .individualPalette .homeBlock .pageTitleIcon
        {
            background-position: initial;
            background-image: url('/img/icon/profile32.png');
        }
        .dateFormat{
            display: none;
        }
</style>
    <script>
    function updatehidden() {
        var sellist = document.querySelectorAll("[data-sellist]"),
            inpfield = document.querySelectorAll("[data-inpfield]"),
            inpnew = document.querySelectorAll("[data-inpnew]"),

            for (var i = 0; i < inpfield.length; i++)
              {
              inpnew[i].value = sellist[i].value + ' - ' + inpfield[i].value;       
              }
            }
            
    function setvenue() {
            var venue = document.querySelectorAll("[data-venue]"),
                venuenew = document.querySelectorAll("[data-venuenew]"),
                datenew = document.querySelectorAll("[data-datenew]");
                
                for (var i = 0; i < inpfield.length; i++)
              {
              venuenew[i].value = venue[i].value.substring(11,255);
              datenew[i].value = venue[i].value.substring(0,8);        
              }
    }
</script>
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Event Delegates"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!DelegateList}" var="del" style="width:100%">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertDelRow}"/>
                </apex:facet>
                <apex:column headerValue="Name" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Name__c}" id="inpfield" required="true" html-data-inpfield="1" onchange="updatehidden()"/>
                </apex:column>
                <apex:column headerValue="Phone" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Phone__c}" onchange="updatehidden()" id="phone"/>
                </apex:column>  
                <apex:column headerValue="Email" style="width:12%">
                    <apex:inputField style="width:98%" value="{!del.Email_Address__c}" onchange="updatehidden()" id="email" required="true"/>
                </apex:column>
                <apex:column headerValue="Job Role" style="width:10%">
                    <apex:inputField style="width:98%" value="{!del.Job_Role__c}" onchange="updatehidden()" id="jobrole"/>
                </apex:column>
                <apex:column headerValue="Company Name" style="width:12%">
                    <apex:inputField style="width:85%" value="{!del.Company_Name__c}" id="companyname" onchange="updatehidden()" required="true"/>
                </apex:column>
                <apex:column headerValue="Event Type" style="width:11%">
                <apex:actionRegion >
                <apex:selectList style="width:98%" value="{!selectedType}" multiselect="false" html-data-sellist="1" size="1" id="sellist">
                <apex:selectOption itemValue="Type1" itemLabel="Type1"/>
                <apex:selectOption itemValue="Type2" itemLabel="Type2"/>
                <apex:selectOption itemValue="Type3" itemLabel="Type3"/>
                <apex:actionSupport event="onchange" reRender="venue"/>
                </apex:selectList>
                </apex:actionRegion>
                </apex:column>
                <apex:column headerValue="Venue" style="width:20%">
                    <apex:selectList value="{!venuex}" style="width:98%" html-data-venue="1" size="1" id="venue" onchange="setvenue()">
                        <apex:selectOptions value="{!venues}"/>
                    </apex:selectList>
                </apex:column>
                <apex:column headerValue="FOC?">
                    <apex:inputcheckbox value="{!del.FOC__c}" onchange="updatehidden()" id="foc"/>
                </apex:column>
                <apex:column headerValue="Delete" style="width:3%">
                    <apex:commandLink style="font-size:15px; font-weight:bold; padding-left:30%; color:red;" value="X" action="{!delDelRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index"/>
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                    <apex:inputHidden value="{!del.Name}" html-data-inpnew="1" id="inpnew"/>
                    <apex:inputHidden value="{!del.Event_Date__c}" html-data-datenew="1" id="datenew"/>
                    <apex:inputHidden value="{!del.Venue__c}" html-data-venuenew="1" id="venuenew"/>
                </apex:column>
            </apex:pageBlockTable>
            <br/>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertDelegates}"/>
                <apex:commandButton value="Back" action="{!cancelDelegates}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class BookEventsTest {
    
    public List<Event_Delegates__c> DelegateList {get;set;}
    public Integer rowNum{get;set;}
    public String selectedType{get;set;}
    public String venuex{get;set;}
    
    //Add initial Delegate row
    {
        selectedType = 'Type1';
        venuex = '';
        DelegateList = new List<Event_Delegates__c>();
        DelegateList.add(new Event_Delegates__c());
    }
    
    //Insert DelegateList and redirect
	public PageReference insertDelegates(){
        insert DelegateList;
		PageReference reRender = new PageReference('/');
		reRender.setRedirect(true);
		return reRender;
    }
    
	//Cancel Delegate and redirect page
    public PageReference cancelDelegates(){
        PageReference reRender = new PageReference('/');
        reRender.setRedirect(true);
        return reRender;
    }
    
    //Insert Delegate Row
    public void insertdelRow(){
        if(DelegateList.Size()>0){
        Event_Delegates__c tmpdel = DelegateList.get(0);
        DelegateList.add(new Event_Delegates__c(
                                             phone__c=tmpdel.phone__c,
            								 email_address__c=tmpdel.email_address__c,
            								 company_name__c=tmpdel.Company_Name__c,
            								 venue__c=tmpdel.venue__c
                                            ));
    }
        
        else DelegateList.add(new Event_Delegates__c());
    }
    
    //Delete Delegate Row
    public void delDelRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        DelegateList.remove(rowNum);
    }
    
    //Display correct picklist depending on selectType
    public List<SelectOption> getVenues(){
       
       List<SelectOption> venueoptions = new List<SelectOption>();
       
        if(selectedType=='Type1'){
            Schema.DescribeFieldResult fieldResult = Event_Delegates__c.type1__c.getDescribe();
            List<Schema.PicklistEntry> venues = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry v : venues)
       		{
           	venueoptions.add(new SelectOption(v.getLabel(), v.getValue()));
       		}          
        }
        else if(selectedType=='Type2'){
            Schema.DescribeFieldResult fieldResult = Event_Delegates__c.type2__c.getDescribe();
            List<Schema.PicklistEntry> venues = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry v : venues)
       		{
           	venueoptions.add(new SelectOption(v.getLabel(), v.getValue()));
       		}
        }
        else if(selectedType=='Type3'){
            Schema.DescribeFieldResult fieldResult = Event_Delegates__c.type3__c.getDescribe();
            List<Schema.PicklistEntry> venues = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry v : venues)
       		{
           	venueoptions.add(new SelectOption(v.getLabel(), v.getValue()));
       		}
        }
        else{}
       
       return venueoptions;
       
       }
}

If someone could give me some pointers it would be really helpful,
Thanks​​
I have a controller that sends an email and grabs a few different attachments from different records.
Not all the records will have an attachment called 'Venue Map' so I want to stop the error if the SOQL returns null. Not sure what to do here.
 
Attachment att = [ select name, contenttype, body from Attachment where name LIKE '%Venue Map%' and ParentId = :cf.courses__r.venueid__c][0];

if(att.body.size() > 0 ){
Messaging.Emailfileattachment MyMap = new Messaging.Emailfileattachment(); MyMap.setContentType(att.contentType); MyMap.setFileName('Venue Information.pdf'); MyMap.setBody(att.Body); fileAttachments.add(MyMap);
}

mail.setFileAttachments(fileAttachments);

The code is working perfect when there is a 'Venue Map' attachment, but if there isnt it just gives me this error "List index out of bounds: 0"
I have a vf page with 2 picklists.
I need the second picklist to update when the first one changes. Rather than using selectOption for the second picklist I want to pass through the field name to rerender so that I can update the values without having to update the controller.
 
For this I though about using the following:
<apex:column headerValue="Picklist1">
                <apex:selectList value="{!Picklist1}" multiselect="false" size="1">
                <apex:selectOption itemValue="a" itemLabel="a"/>
                <apex:selectOption itemValue="b" itemLabel="b"/>
                <apex:selectOption itemValue="c" itemLabel="c"/>
                <apex:actionSupport event="onchange" reRender="b"/>
                </apex:selectList>
                </apex:column>

                <apex:column headerValue="Picklist2">
                <apex:inputField value="{!Picklist2}" id="b"></apex:inputField>
                </apex:column>
Public String Picklist1{get;set;}
Public String Picklist2 {get;set;}

  {
        if(Picklist1 == 'a'){
            Picklist2 = 'del.a__c';
        } else if (Picklist1 == 'b'){
            Picklist2 = 'del.b__c';
        }else if (Picklist1 == 'c'){
            Picklist2 = 'del.c__c';
        }else {
            Picklist2 = null;
        }
    }

I have 3 picklist fields (a,b & c) on the custom object (del) but I want picklist1 to select which picklist (a,b or c) depending.

Hope this makes sense.

 
Hi,

I am struggling with a button on a custom object called Certification_Candidate__c that collates various information and displays a vf page, rendered as pdf and then saves it as an attachment on the record.

At the moment I am getting an error in the controller Variable does not exist: Centre_Number__c at line 17 column 140
Centre_Number__c is a custom field within the accredited centre object and has a master relationship with Certification_Candidate__c so I am unsure why it cannot be seen with the SOQL.

I am also having a problem with recursion, when the vf page is loaded and the SavePDF() method is actioned it saves 5 copies to the record.
I guess what is happening is that the pdf.getContent() is calling another instance of SavePDF() and therefore it recurs.

Please can someone have a look down the code and give me some pointers where I am going wrong?

I don't write apex often enough so everytime I come to a project I have to re-learn a lot of stuff to jog my memory. It is very frustrating, I would love to out source some of the more advanced pieces but I dont think that will be the case unfortunately.

VF Page
<apex:page standardController="Certification_Candidate__c" extensions="AssessmentTableController" showHeader="false" applyHtmlTag="false" applyBodyTag="false" renderAs="pdf" action="{!SavePDF}">
<html>
<head>
<style type="text/css" media="print">
     ...various css...
</style>
</head>

<body style="font-size:12px">
<div class="header">
   <p style="font-weight:bold; text-align:center; font-size:16px">
   title
   </p>
   <apex:panelGrid columns="2" style="width:567px; font-size:16px; margin: auto,auto;">
   <apex:outputText value="Forename(s): {!Certification_Candidate__c.Forename__c}"/>
   <apex:outputText value="Surname: {!Certification_Candidate__c.Surname__c}"/>
   <apex:outputText value="Date of Birth: {!Certification_Candidate__c.Date_of_Birth__c}"/>
   <apex:outputText value="NI Number: {!Certification_Candidate__c.NI_Number__c}"/>
   </apex:panelGrid>
   </div>
                       
   <div class="footer">                      
<apex:panelGrid columns="2" width="568px" style="margin: 0px auto; font-weight:normal">
  <apex:outputText value="Date of Issue: {0, date, dd/MM/yyyy}"><apex:param value="{!NOW()}"/></apex:outputText>
    <apex:outputText value="Certificate Number: {0, date, YY}/{!Certification_Candidate__c.Accredited_Centre__r.Centre_Number__c}/{!certnum}"><apex:param value="{!NOW()}"/></apex:outputText>
</apex:panelGrid>
<apex:panelGrid columns="1" width="567px" style="margin: auto auto">
<apex:outputText value="text"/>
</apex:panelGrid>
<apex:panelGrid columns="2" width="567px" style="margin: auto auto; font-weight:normal">
  <apex:image value="https://c.eu1.content.force.com/servlet/servlet.FileDownload?file=015D00000048ZMN" alt="alt text" width="100px"/>
      <apex:outputText value=""/>
  <apex:outputtext value="text"/>
  <apex:outputtext value="text"/>
</apex:panelGrid>
<br/><br/>
<table style="font-size:8px;">
<tr>
<td width="60%"><apex:outputText value="text"/><br/><apex:outputText value="text"/><br/><apex:outputText value="tel:"/><br/><br/><br/><apex:outputtext value="address:"/><br/><apex:outputtext value="trading name"/>
</td>
<td width="30%"><apex:outputText value="text"/>
</td>
<td width="10%"><apex:image value="https://c.eu1.content.force.com/servlet/servlet.FileDownload?file=015D00000048ZMO" alt="text" width="50px"/>
</td>
</tr>
</table>
</div>

<div class="content">
<apex:dataTable value="{!AsstList}" var="item" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!item.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!item.Description__c}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!item.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>

</body>
</html>
</apex:page>

Controller
public class AssessmentTableController {
    public List <Assessment__c> asstList {get;set;}
    public String certnum;
    public String candid {get;set;}
    public String centnum;
    
    public AssessmentTableController(ApexPages.StandardController controller){
        Id candid = ApexPages.currentPage().getParameters().get('Id');
        asstList = new List<Assessment__c>();
        asstList = [select Candidate__c,codeTEXT__c,Expiry_Date__c, Description__c from Assessment__c where Expiry_Date__c > today and Candidate__r.id=:candid order by codeTEXT__c desc];

        certnum = [SELECT Description__c from Asstcodes__c WHERE name =: 'CertificateNumber' limit 1].Description__c;
    }
    
    public PageReference savePdf() {
    
    centnum = [SELECT Certification_Candidate__c.Accredited_Centre__r.Centre_Number__c from Certification_Candidate__c WHERE Id =: candid].Centre_Number__c;
    
    Attachment attachment = new Attachment();
    PageReference pdf = ApexPages.currentPage();
    Blob body;

    try {
        body = pdf.getContent(); 
    } catch (VisualforceException e) {
        body = Blob.valueOf('Some Text');
    }
    
    attachment.Body = body;
    attachment.Name = centnum + '-' + certnum + '-' + String.ValueOf(Date.Today().Year()).Right(2);
    attachment.IsPrivate = false;
    attachment.ParentId = candid;
    attachment.ContentType = 'application/pdf';
    insert attachment;
    
    String centnumNew = String.ValueOf(Integer.ValueOf(certnum)+1);
    certnum.description__c = centnumNew;
    update centnum;
    
    return null;
  }
}

Thanks for your help,

Joe​​
Hi,

This should be pretty basic,
I have a vf page to display the value of the name field of a record in a custom object called 'Certification_Accredited_Centres__c'
I also have a controller that the vf page uses.

The URL passes a paramater 'centreId' which is the id of the record I am trying to get the name value of.

At the moment all I am getting on the vf page is "Assesments taken at      " <-- the string is blank

VF Page (not complete)
<apex:page controller="AddingAssessmentsController>
<h3>
<apex:outputText value="Assesments taken at {!asscen}"/>
</h3>
</apex:page>
Controller (not complete)
public class AddingAssessmentsController {

    public Id centreId;
    
    public String asscen{get;set;}
    
    public AddingAssessmentsController(){
        centreId = ApexPages.currentPage().getParameters().get('centreId');
        String asscen = [SELECT name from Certification_Accredited_Centres__c WHERE id =: centreId].name;
    }
}

Please can someone tell me why the {!asscen} is blank in the vf page?

Thanks
Joe 
 
Hi,

I am having a bit of trouble and cannot find an answer that fits what I need.

I have 2 custom objects totally unrelated. Assessment__c, and AsstCodes__c.

AsstCodes__c has 2 fields Name and Description. Both are text fields.

What I want to achieve is this:
When I save a new Assessment__c record I want a trigger to update the Assessment__c.Description with the AsstCodes__c.Description.
The common factor is that Assessment__c.Code__c (picklist) will be the same value as a record in AsstCodes__c.Name (text value)

So far I have minimal code for this.

I know I need to do the following:
AsstCodeDescription = [SELECT description__c FROM AsstCodes__c WHERE Assessment__c.Name = AsstCode.Name LIMIT 1];
trigger AsstDesc on Assessment__c (after insert, after update)
{
    map<string, Assessment__c> TheMap = new map<string, Assessment__c>();
        
    for (Assessment__c Desc:trigger.new)
    {
        if (Desc.Name !='')
        Desc.Description__c = AsstCodeDescription;
        update desc;
    }
    
}

I am just not sure how to put it all together.​ Hope this all makes sense.

Thanks for your help
Joe
 
Hi Everyone,

I have a vf page that adds multiple child records to an object.

I have a controller for this that can add/delete rows etc.

What I want to do is update a text field with some predetermined text based on the picklist value from the vf page.
for example

PICKLIST COLUMN                  DATE COLUMN                  TEXT COLUMN
PICKLIST VALUE 1                            ---                                       ---
PICKLIST VALUE 2                            ---                                       ---

On insert I want to add "Description related to picklist value 1" into the text column for the picklist value 1 row and "Description related to picklist value 2" into the other.

There is no maximum number of rows.

There are 94 different picklist values with descriptions.

I'm guessing I would hold all the description values in the controller some how and then use the picklist value to reference them.

Just not sure how.

This is my vf page and controller so far:
<apex:page controller="AddingAssessmentsController">
    <style>
        .homeTab .pageTitleIcon, .individualPalette .homeBlock .pageTitleIcon
        {
            background-position: initial;
            background-image: url('/img/icon/wrench32.png');
        }
    </style>
    
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Assessments"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!AssessmentList}" var="asst">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertAsstRow}"/>
                </apex:facet>
                <apex:column headerValue="Code">
                    <apex:inputField value="{!asst.Code__c}" required="true"/>
                </apex:column>
                <apex:column headerValue="Last Centre Date">
                    <apex:inputField value="{!asst.LastCentreDate__c}" id="LastCentreDate"/>
                </apex:column>  
                <apex:column headerValue="Date of Tech Review">
                    <apex:inputField value="{!asst.DateofTechReview__c}" id="DateOfTechReview"/>
                </apex:column>
                <apex:column headerValue="Date Received By Cert Office">
                    <apex:inputField value="{!asst.Date_Received_By_Cert_Office__c}" id="Date_Received_By_Cert_Office"/>
                </apex:column>
                <apex:column headerValue="Assessor">
                    <apex:inputField value="{!asst.Assessor__c}" id="Assessor"/>
                </apex:column>
                <apex:column headerValue="Verifier">
                    <apex:inputField value="{!asst.Verifier__c}" id="Verifier"/>
                </apex:column>
                <apex:column headerValue="Photo Scanned">
                    <apex:inputcheckbox value="{!asst.Photo_Scanned__c}" id="photoscanned" selected="true"/>
                </apex:column>
                <apex:column headerValue="Photo Scan date">
                    <apex:inputfield value="{!asst.Photo_Scan_Date__c}" id="photo_scan_date"/>
                </apex:column>
                <apex:column headerValue="Fastrack">
                    <apex:inputcheckbox value="{!asst.Fastrack__c}" id="Fastrack"/>
                </apex:column>
                <apex:column headerValue="MOT Cert">
                    <apex:inputcheckbox value="{!asst.MOT_Cert__c}" id="Mot_cert"/>
                </apex:column>
                <apex:column headerValue="Pass?">
                    <apex:inputcheckbox value="{!asst.Pass__c}" id="pass" selected="true"/>
                </apex:column>
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delAsstRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertAssessments}"/>
                <apex:commandButton value="Back" action="{!cancelAssessments}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class AddingAssessmentsController {
    Id candId;
    Id centreId;
    
    public List<Assessment__c> AssessmentList {get;set;}
    public Integer rowNum{get;set;}
    
    //Add initial Assessment row
    public AddingAssessmentsController(){
        candId = ApexPages.currentPage().getParameters().get('candId');
        centreId = ApexPages.currentPage().getParameters().get('centreId');
        AssessmentList = new List<Assessment__c>();
        AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true, Accredited_Centre__c=centreId));
    }
    
    
        //Insert AssessmentList and redirect
        public PageReference insertAssessments(){
            insert AssessmentList;
			PageReference reRender = new PageReference('/'+candId);
			reRender.setRedirect(true);
			return reRender;
    }
    
	//Cancel Assessment and redirect page
    public PageReference cancelAssessments(){
        PageReference reRender = new PageReference('/'+candId);
        reRender.setRedirect(true);
        return reRender;
    }
    
    //Insert Assessment Row
    public void insertAsstRow(){
        if(AssessmentList.Size()>0){
        Assessment__c tmpAssessment = AssessmentList.get(0);
        AssessmentList.add(new Assessment__c(Candidate__c=candId,
                                             Verifier__c=tmpAssessment.Verifier__c,
                                             Assessor__c=tmpAssessment.Assessor__c,
                                             LastCentreDate__c=tmpAssessment.LastCentreDate__c,
                                             DateofTechReview__c=tmpAssessment.DateofTechReview__c,
                                             Date_Received_By_Cert_Office__c=tmpAssessment.Date_Received_By_Cert_Office__c,
                                             Photo_Scanned__c=tmpAssessment.Photo_Scanned__c,
                                             Photo_Scan_Date__c=tmpAssessment.Photo_Scan_Date__c,
                                             Fastrack__c=tmpAssessment.Fastrack__c,
                                             MOT_Cert__c=tmpAssessment.MOT_Cert__c,
                                             Pass__c=tmpAssessment.Pass__c,
                                             Accredited_Centre__c=centreId
                                            ));
    }
        else AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true, Accredited_Centre__c=centreId));
    }
    
    //Delete Assessment Row
    public void delAsstRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        AssessmentList.remove(rowNum);
    }
}

Thanks for your help.
Hi,

I have a vf page that renders as a pdf and displays a dataTable of results from a related list on an object, it is working well apart from the following.

I need to add a column in my data table that displays a description of the item in the 'Code' Column.
I have done this using if statements and it is working nicely, however, I am worried that I will hit the maximum formula compile size as I will be adding a lot more to this in the future.

What is the best way to get around this to generate the correct descriptions without huge multiple if statements?

section of current vf page
<div class="content">
<apex:dataTable value="{!AsstList}" var="item" border="0" cellpadding="5" cellspacing="1" width="567px" style="margin: auto auto;">

<apex:column width="20%" headerValue="Code">
<apex:outputText value="{!item.CodeTEXT__c}">
</apex:outputText>
</apex:column>

<apex:column width="60%" headerValue="Description">
<apex:outputText value="{!IF(item.CodeTEXT__c = 'Code1','Code1 Description Here',
                        IF(item.CodeTEXT__c = 'Code2','Code2 Description Here',
                        IF(item.CodeTEXT__c = 'Code3','Code3 Description Here',
                        IF(item.CodeTEXT__c = 'Code4','Code4 Description Here',
                        IF(item.CodeTEXT__c = 'Code5','Code5 Description Here',
                        IF(item.CodeTEXT__c = 'Code6','Code6 Description Here','NULL'))))))}">
</apex:outputText>
</apex:column>

<apex:column width="20%" headerValue="Expiry Date">
<apex:outputText value="{0, date, dd/MM/yyyy}">
       <apex:param value="{!item.Expiry_Date__c}" />
       </apex:outputText>
</apex:column>
</apex:dataTable>
</div>

Thanks
Hi,

I am writing a controller to check the Name field in a list of child records against a field called Approved_scope__c on a custom object. If the Name fields in the List are all contained in the Approved_scope__c field then it needs to insert the list, else it needs to display which of the name fields are not in the Approved_scope__c.

I have put the Approved_scope__c field into a set and then I am trying to use set.contains(List.Name)

It is giving an error at the moment on line 17 'Initial term of field expression must be a concrete SObject: List'
I'm not sure where I am going wrong.

Also how would I then get a new list of records that weren't contained in the set?

Any help would be appreciated thank you.

Controller:
public class AddingAssessmentsController {
    Id candId;
    Id centreId;
    
    public List<Assessment__c> AssessmentList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddingAssessmentsController(){
        candId = ApexPages.currentPage().getParameters().get('candId');
        AssessmentList = new List<Assessment__c>();
        AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true));
    }
        
	public PageReference insertAssessments(){
		centreId = ApexPages.currentPage().getParameters().get('centreId');
		set <Certification_Accredited_Centres__c> centreSet = new set <Certification_Accredited_Centres__c>([Select Approved_Scope__c from Certification_Accredited_Centres__c where Id = :centreId]);
          if(centreSet.contains(';' + AssessmentList.Name + ';')){
        	insert AssessmentList;
			PageReference reRender = new PageReference('/'+candId);
			reRender.setRedirect(true);
			return reRender;
        } else {
            return null; 
        }
    }

    public PageReference cancelAssessments(){
        PageReference reRender = new PageReference('/'+candId);
        reRender.setRedirect(true);
        return reRender;
    }
    
    public void insertAsstRow(){
        if(AssessmentList.Size()>0){
        Assessment__c tmpAssessment = AssessmentList.get(0);
        AssessmentList.add(new Assessment__c(Candidate__c=candId,
                                             Verifier__c=tmpAssessment.Verifier__c,
                                             Assessor__c=tmpAssessment.Assessor__c,
                                             LastCentreDate__c=tmpAssessment.LastCentreDate__c,
                                             DateofTechReview__c=tmpAssessment.DateofTechReview__c,
                                             Date_Received_By_Cert_Office__c=tmpAssessment.Date_Received_By_Cert_Office__c,
                                             Photo_Scanned__c=tmpAssessment.Photo_Scanned__c,
                                             Photo_Scan_Date__c=tmpAssessment.Photo_Scan_Date__c,
                                             Fastrack__c=tmpAssessment.Fastrack__c,
                                             MOT_Cert__c=tmpAssessment.MOT_Cert__c,
                                             Pass__c=tmpAssessment.Pass__c                                             
                                            ));
    }
        else AssessmentList.add(new Assessment__c(Candidate__c=candId, pass__c=true, photo_scanned__c=true));
    }
    
    public void delAsstRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        AssessmentList.remove(rowNum);
    }
}

vf page if needed:
<apex:page controller="AddingAssessmentsController">
    <style>
        .homeTab .pageTitleIcon, .individualPalette .homeBlock .pageTitleIcon
        {
            background-position: initial;
            background-image: url('/img/icon/wrench32.png');
        }
    </style>
    
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlock >            
            <apex:sectionHeader subtitle="Add Assessments"/>
            <apex:variable var="rowNum" value="{!0}"/>
            <apex:pageBlockTable value="{!AssessmentList}" var="asst">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertAsstRow}"/>
                </apex:facet>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!asst.Name}" required="true"/>
                </apex:column>
                <apex:column headerValue="Last Centre Date">
                    <apex:inputField value="{!asst.LastCentreDate__c}" id="LastCentreDate"/>
                </apex:column>  
                <apex:column headerValue="Date of Tech Review">
                    <apex:inputField value="{!asst.DateofTechReview__c}" id="DateOfTechReview"/>
                </apex:column>
                <apex:column headerValue="Date Received By Cert Office">
                    <apex:inputField value="{!asst.Date_Received_By_Cert_Office__c}" id="Date_Received_By_Cert_Office"/>
                </apex:column>
                <apex:column headerValue="Assessor">
                    <apex:inputField value="{!asst.Assessor__c}" id="Assessor"/>
                </apex:column>
                <apex:column headerValue="Verifier">
                    <apex:inputField value="{!asst.Verifier__c}" id="Verifier"/>
                </apex:column>
                <apex:column headerValue="Photo Scanned">
                    <apex:inputcheckbox value="{!asst.Photo_Scanned__c}" id="photoscanned" selected="true"/>
                </apex:column>
                <apex:column headerValue="Photo Scan date">
                    <apex:inputfield value="{!asst.Photo_Scan_Date__c}" id="photo_scan_date"/>
                </apex:column>
                <apex:column headerValue="Fastrack">
                    <apex:inputcheckbox value="{!asst.Fastrack__c}" id="Fastrack"/>
                </apex:column>
                <apex:column headerValue="MOT Cert">
                    <apex:inputcheckbox value="{!asst.MOT_Cert__c}" id="Mot_cert"/>
                </apex:column>
                <apex:column headerValue="Pass?">
                    <apex:inputcheckbox value="{!asst.Pass__c}" id="pass" selected="true"/>
                </apex:column>
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delAsstRow}" immediate="true">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!insertAssessments}"/>
                <apex:commandButton value="Back" action="{!cancelAssessments}" immediate="true"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Thank you
Hi Everyone,

I have a text field that I want to start with a date in the dd/mm/yy format.

I am trying to get a REGEX validation rule to force this but I am struggling.

I need the rule to allow dd/mm/yy - *

The* will allow any text afterward.

Would someone be able to tell me the correct expression please?

Thanks
Joe