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


  • Chatter
    Feed
  • 61
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 503
    Replies
I'm going to override the standard controller for my object .  Do insertion a new record  ( record in base still there is no).  Page

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


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

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

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

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

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

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

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

What am I missing here?

Thanks.
 

Hi all,

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

trigger differentValues on User (before insert) {

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

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

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

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

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

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

Test class:

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

Original method:

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

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

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

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

This is my test class:

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

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

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

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

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

 
Here is my code:
PassQuery is a string which contains the record ids
<apex:pageBlockTable value="{! retrieveRecords }" var="row">
               
                <apex:column id="checkboxcolumn" >
                    <apex:facet name="header">
                        <apex:inputCheckbox id="headerCheckbox" value="{! checked}" >
                            <apex:actionSupport event="onchange" action="{! headerCheckboxMethod}" reRender="pgblock"/>
                        </apex:inputCheckbox>
                    </apex:facet>
                    <apex:inputCheckbox value="{!If(contains(passQuery, row.Id),true,false)}" id="childCheckBox" >
                        <apex:actionSupport event="onchange" action="{! checkboxStateMethod}" reRender="headerCheckbox">
                            <apex:param name="checkboxId" value="{! row.Id}" assignTo="{! recordId}" />
                        </apex:actionSupport>
                    </apex:inputCheckbox>
                </apex:column>
                
                <apex:column headerValue="Action" title="Action">
                    <apex:outputLink title="Edit Record" value="/{! row.Id}/e?retURL=/apex/DescribeCallAssignment" >Edit</apex:outputLink>|&nbsp;
                    <apex:commandLink title="Delete Record" action="{! deleteRecord}"  reRender="pgblock">Del
                        <apex:param name="recordToBeDeleted"  value="{! row.Id}" assignTo="{! RecordToDelete}" />
                    </apex:commandLink>
                </apex:column>
                <apex:repeat value="{! retrieveColumns}" var="col">
                    <apex:column value="{! row[col]}" />
                </apex:repeat>
            </apex:pageBlockTable>
I have a visualforce page that I want to use a date field to rerender an output panel if the date is a certain month.

Currently I'm using a number field for this section but i would like to use a date field called Contract_Start_Date__c.

I'm not sure how to format the formula to check for what month it is from the Contract Start date. .  

<apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 12  ,true,false)}">

I would like to do something like this below
{!IF(MONTH (et.Contract_Start_Date__c)  == 12  ,true,false))}
  • August 12, 2019
  • Like
  • 0
Hi,

If particular product not added in quote, I don't want print the specific sentence in the quote PDF.

<p><strong>display:{!if(!QLI.weli.Product_Description__c=XXXXXXXX,'','none')},"><b>Along with the above mentioned XXXXXXX we also have complete range of XXXXXXXXX</b></strong>, Should you have any other clarifications / details please do feel free to contact us.</p>


 
Hi,

I have a an object called payment_plan__c which is parent and child payment_detail__c is child.. I want to create a vf page in another object called Bookin__c which has a lookup (Payment_Plan__c) .Need to fetch child record(i.e) Payment_Details_c  Based on the lookup value in booking object on a button click in booking object

Thanks in advance,
Shyam.
I have a requirement that for an account there should be unique email id for every related contact. But in my code it is not working as per the requirement, it is checking all the contacts irrespective of Account. 
But I need to check only Account related contacts email id's.Here is my code please help me where I am doing wrong.

trigger ContactTrigger on Contact (before insert,before update)
 {
   
  set<ID> accId = new set<ID>();
   list<string> ContactEmails=new list<string>();
    for(Contact conVar:trigger.new)
    {
        ContactEmails.add(conVar.email);
        accId.add(conVar.AccountId);
    }
    
    system.debug('ContactEmails ************' +ContactEmails);
    
    list<Contact> listOfDuplicateContacts=[select id,email,Account.ID from Contact where email in :ContactEmails AND AccountID IN : accId];
      system.debug('listOfDuplicateContacts ************' +listOfDuplicateContacts);
    
    for(Contact con:trigger.new)
    {
        if(trigger.isInsert){
        if(listOfDuplicateContacts.size()!=0)
        {
            con.addError('Contact email already exists with this name');
        }
        }
        if(trigger.isUpdate)
        {
           for(Contact oldContact :trigger.old)
           {
               if(con.Email!=oldContact.Email && listOfDuplicateContacts.size()!=0)
               {
                   con.addError('Contact email already exists with this name');
               }
           }
        }
    }
}
  • August 12, 2019
  • Like
  • 0
I have a repeat in a visualforce page that displays the fieds in a fieldset. I want the fields to display in two columns (like the standard detail pages), but they would only display all in one cell when using apex:pageBlockSection. 

I tried to add a span to wrap the repeat to add style of width: 50% and display:inline.
It is displaying in two columns, but there seems to be a line break after each field.

Here is the code
<apex:pageBlockSection title="Information" columns="2">
                <apex:inputField value="{!Projects__c.Name}" label="Project Name" required="true"/>
                <apex:outputField value="{!Projects__c.OwnerId}" />
                <span style="display:inline; width:50%;">                
                    <apex:repeat value="{!$ObjectType.Projects__c.FieldSets.projectFieldSet}" var="f"> 
                        <span style="display:inline; width:50%;">
                            <apex:inputField value="{!Projects__c[f.fieldPath]}" label="{!f.Label}" required="{!OR(f.required, f.dbrequired)}"/>
                        </span>
                    </apex:repeat> 
                </span>                                             
            </apex:pageBlockSection>

and here is what I am getting
visualforce page preview

I want to get rid of all the vertical spaces in between the fields. Any ideas?
Hi i have a custom visual force page , in this i was unable to use onchange event
My VF Page has Account Lookup and salesDistrict lookup ,when user chnage the account  value i have to populate the accout's sales value in sales lookup field. Folowing is my code

<apex:pageBlockSectionItem helpText=" The End User’s physical location" >
Account Name:
<apex:inputField id="oppAccountId" value="{!thisOpp.AccountId}" required="true">
<apex:actionSupport action="{!populatesalesdistrict}" event="onchange" reRender="salesDistrict" status="pageStatus"/> </apex:inputField>
</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem helpText="Auto populated from Account; Enter if blank">
Sales District :
<apex:inputField value="{!thisOpp.Sales_District_lkup__c}" id="salesDistrict" required="true"/>
</apex:pageBlockSectionItem>
 controller: Mrthod:
  Public void populatesalesdistrict(){
       Account thisAcc = [SELECT Id, Sales_District__c,SoldTo__c from Account where ID =: thisOpp.AccountId];
       thisOpp.Sales_District_lkup__c = thisAcc.Sales_District__c;
}
What is alternate if onchange will not work for lookup fields.?
Hey all!
I have a visualforce page using an apex:tabpanel element wrapped in an outputPanel. When I rerender the outputpanel, the formatting of the tabpanel breaks down, showing the content of all tabs stacked on the page instead of only the content of the selected tab. For the tabpanel, I'm using switchtype="client" because I think it's a smoother user experience.

If I had to guess, I would say the tabpanel element is probably using jquery to handle its tab transitions, and when the element is rerendered it's scrubbing some of the script and breaking down the display a little. I've seen some comments around HTML5 elements being scrubbed unless you specify it in the doctype, but I have specified the html-5.0 doctype and it didn't help here.

The best workaround I can think of would be to re-render only all the individual elements within the tabpanel instead of the tabpanel itself, but that would be quite a laborious implementation.

Has anyone faced anything similar or know of a better workaround to rerender a tabpanel without messing up the display format?
Why does my chart has month names on wedges but the sample example doesn't ? 

In my sandbox I  copied and pasted exact code from the salesforce documentation as shown here https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_charting_overview_simple_example.htm

Created a Apex Controller, Created a Wrapper Class, Created a VFP.
 
The output as shown in this example doesn't have month names on the wedges. However the output I get has month names on the wedges. This example doesn't uses rendererFn property. I am wondering why i see month names and the example shown does'nt?

This is my output 
User-added imageHowever I was expecting to see this 

User-added image

Here the Code exactly as copied from the documentation 
 
<apex:page controller="PieChartController" title="Pie Chart">
    <apex:chart height="350" width="450" data="{!pieData}">
        <apex:pieSeries dataField="data" labelField="name"/>
        <apex:legend position="right"/>
    </apex:chart>
</apex:page>



public class PieChartController {
    public List<PieWedgeData> getPieData() {
        List<PieWedgeData> data = new List<PieWedgeData>();
        data.add(new PieWedgeData('Jan', 30));
        data.add(new PieWedgeData('Feb', 15));
        data.add(new PieWedgeData('Mar', 10));
        data.add(new PieWedgeData('Apr', 20));
        data.add(new PieWedgeData('May', 20));
        data.add(new PieWedgeData('Jun', 5));
        return data;
    }

    // Wrapper class
    public class PieWedgeData {

        public String name { get; set; }
        public Integer data { get; set; }

        public PieWedgeData(String name, Integer data) {
            this.name = name;
            this.data = data;
        }
    }
}

 

Hi all,

There are probably steps I can look into to further optimize my visualforce page, but before I start into that, I'm wondering if it's not some sort of browser issue.

 

When I look at my view state size in the developer window it says 79KB. When my field tech tries to open it, it says that the view state has exceeded the limit of 170KB, and is 194KB instead. Why would it be more than 100KB larger when another viewer tries to access it? 

 

I am working on a trail for future method, my method finds the number of contacts on account and updates the "Number of Contacts" field on the Account.

Everyhting is working as expected but in the test class while asserting the output, the SOQL is not pulling this field.

Future Method:
public class AccountProcessor {
    
	@future
    public static void countContacts(List<Id> AccIds){
        
    List<Account> acctsContacts = new List<Account>();
        
    //List<Contact> noOfContacts = new List<Contact>();
        
        //integer noOfContacts;
        
    for(ID accn: AccIds){
            
     //contactsID = [Select ID from Contact where Account.ID = :accn];
            
     //noOfContacts = [Select COUNT() from Contact where Account.ID = :accn];
          
     	acctsContacts =  [Select Name, (Select Firstname, Lastname FROM Contacts)
                          FROM Account
                          WHERE ID =:accn]; 
         
            for(Account accns: acctsContacts){
                
            	integer noOfContacts = accns.Contacts.size();
                System.debug('Number of Contacts' +noOfContacts);
                    
                accns.Number_of_Contacts__c = noOfContacts;                 
                
            	}                        
       
       }        
        
    }

}

Test Method:
 
@isTest
public class AccountProcessorTest {
    
    @isTest
    public static void testcountContacts(){
        
        //Test Data Preparation - Create new accounts
        ID testAccID;
        List<ID> testAccIdsList = new List<ID>();
        List<Account> testAccount = new List<Account>{
            
            new Account(Name ='TestAccount 1'),
            new Account(Name = 'TestAccount 2'),
            new Account(Name = 'TestAccount 3'),
            new Account(Name = 'TestAccount 4')
        };
            
            insert testAccount;  
        
        //Create 2 contact for each Account
        List<Contact>consList = new List<Contact>();
        for (Account eachAccount:testAccount){
            
            for(integer i=0; i<2; i++){
                
               // List<Contact>consList = new List<Contact>{
                    
                  Contact cons = new Contact(Firstname ='Contact'+i, Lastname = 'Test'+i, AccountId = eachAccount.Id);
                  consList.add(cons);
            }
            
        }
        
        insert conslist;
        
        System.debug('Number of Contacts'+conslist.size());
        
        System.debug('Contacts'+conslist);
        
            //Getting the IDs of the Accounts
            for(Account testaccn:testAccount){
                
                //testAccId = [Select ID from Account 
                             //WHERE Account.ID =:testaccn.Id];
                    
                testAccIdsList.add(testaccn.ID);
                
            }
        
        //Test Starts 
        Test.startTest();
         
        AccountProcessor.countContacts(testAccIdsList);
            
        Test.stopTest();
        
           List<Account>accContactPresent = new list<Account>();
        
           System.debug('List of IDs'+testAccIdsList);
           
           for(Id eachaccID :testAccIdsList){
           
                // This SOQL is not pulling the Number_of_Contacts field
                
                Account contactCount = [Select Match_Billing_Address__c, Number_of_Contacts__c from Account 
                                   		WHERE ID= :eachaccID];
               
           		accContactPresent.add(contactCount);
           
           }  
           for(Account foreachContact :accContactPresent){
               
            	System.debug('Contacts Present'+accContactPresent);
            
            	System.assertEquals(2, foreachContact.Number_of_Contacts__c);
               
         }
        
           
    }

}

Log
At line 73: is wehre, I am not able to pull the Number_Of_Contacts field from Account. It is pulling the ID and Match Billing Address field.

Any help would be appreciated.

 
I want to display around 40k markers on the map. I tried like this but maximum is 10 (i read in documentation this is some sort of a limitation).

Here is my code: 
<apex:page standardController="Account" recordSetVar="accounts" >

  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="42.23  42.23">
        <apex:repeat value="{! accounts }" var="acc">
        <apex:mapMarker title="{! acc.Name }" position="{!acc.BillingLatitude}, {!acc.BillingLongitude},{!acc.BillingCity}, {!acc.Billing_Zip_Postal_Code__c}" />
        </apex:repeat>
  </apex:map>
  </apex:page>

Is there any posibility to do that ? 
  • March 28, 2019
  • Like
  • 1
I would like to know how I reference a custom field as part of this visual force page for Opportunity Line Items. The template is from this app, on the Appexchange form Salesforce labs: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N300000016cYlEAI&modal=where_to_install_package

The error states that it is an invalid field, but it's a custom field on the product. 

Any help would be appreciated!
VF Error

Hi
I have created a Managed and Unmanaged packages and trying to access the URL provided while creating the packages and seeing the below issues

Managed Packages - When I am trying to access the URL and install the same package in a different account I am getting the below error
Package Not Found
The requested package doesn't yet exist or has been deleted. If this is a recently created package version, please try again in a few minutes or contact the package publisher. 

Unmanaged Packages
 - When I am trying to access the URL and install the same package in a different account I am getting the below error
This app can't be installed.
There are problems that prevent this package from being installed.

Package Not Found. User-added imageThe requested package doesn't yet exist or has been deleted. If this is a recently created package version, please try again in a few minutes or contact the package publisher.​​​​​​​

Your help would be really appreciated. .

I have a list button from the account record that called up this VF page. The works perfectrly in classic but the page doesn not load in lighteing. Why?
<apex:page standardController="Account"    extensions="UploadAttachmentController">

 <apex:sectionHeader title="{!Account.Name}" subtitle="Attach File"/>
 
 <apex:form id="form_Upload">
 <apex:pageBlock >

 <apex:pageBlockButtons >
   <apex:commandButton action="{!back}" value="Back to {!Account.Name}"/>
   <apex:commandButton action="{!back}" value="Cancel"/>
 </apex:pageBlockButtons>
 <apex:pageMessages />
 
  <apex:pageBlockSection columns="1">
  
    <apex:pageBlockSectionItem >
      <apex:outputLabel value="File" for="file_File"/>
      <apex:inputFile id="file_File" value="{!fileBody}" filename="{!fileName}"/>
    </apex:pageBlockSectionItem>
  
    <apex:pageBlockSectionItem >
      <apex:outputLabel value="Type" for="type"/>
      <apex:selectList value="{!selectedType}" size="1" id="type"> 
        <apex:selectOption itemValue="MSA" itemLabel="MSA"/>
        <apex:selectOption itemValue="NDA" itemLabel="NDA"/>

      </apex:selectList>
    </apex:pageBlockSectionItem>
    
   
    
    <apex:pageBlockSectionItem >
      <apex:outputLabel value="Description" for="description"/> 
      <apex:inputTextarea id="description" value="{!description}" rows="4" cols="50"/>
    </apex:pageBlockSectionItem>
    
    <apex:pageBlockSectionItem >
      <apex:outputLabel value="" for="uploadBtn"/> 
      <apex:commandButton id="uploadBtn" value="Attach File" action="{!processUpload}" />
    </apex:pageBlockSectionItem>    
    
  </apex:pageBlockSection>
 
 </apex:pageBlock>


 </apex:form>

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

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


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

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

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

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

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

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

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

What am I missing here?

Thanks.
 
Hey there, I got some help for this issue here (https://success.salesforce.com/answers?id=9063A000000tCRxQAM)- but still, don't fully understand how to do this. But I have the below code for a button that grabs parts of the Onboarding record to create another Onboarding record (of a specific record type).
<apex:page standardController="Onboarding__c" > <flow:interview name="Create_Billing_Onboarding" finishLocation="/{!Onboarding__c.Id}"> <apex:param name="AccountID" value="{!Onboarding__c.Account__c}" /> <apex:param name="AccountName" value="{!Onboarding__c.Account__r.Name}" /> <apex:param name="PricingTier" value="{!Onboarding__c.Opportunity__r.Pricing_Tier__c}" /> <apex:param name="OpportunityID" value="{!Onboarding__c.Opportunity__c}" /> <apex:param name="DateOfSale" value="{!Onboarding__c.Opportunity__r.CloseDate}" /> <apex:param name="ChildrenOnSubsidy" value="{!Onboarding__c.Children_on_subsidy__c}" /> <apex:param name="HowDoTheyCurrentlyBill" value="{!Onboarding__c.How_Do_They_Currently_Bill_Parents__c}" /> <apex:param name="HowAreTuitionFeesCalculated" value="{!Onboarding__c.How_are_tuition_fees_calculated__c}" /> <apex:param name="HowFrequentlyAreParentsBilled" value="{!Onboarding__c.How_frequently_are_parents_billed__c}" /> <apex:param name="HowManyChildrenOnSubsidy" value="{!Onboarding__c.How_many_children_on_subsidy__c}" /> <apex:param name="IfNoWhy" value="{!Onboarding__c.If_No_Why__c}" /> <apex:param name="InterestedInInvoicing" value="{!Onboarding__c.Interested_in_invoicing_through_Himama__c}" /> <apex:param name="WillRecordSubsidyOutsideHiMama" value="{!Onboarding__c.Will_they_record_subsidy_outside_Himama__c}" /> <apex:param name="BillingNotes" value="{!Onboarding__c.Billing_Notes__c}" /> </flow:interview> </apex:page>

And then triggers a flow. We want a validation rule that if some of the parts are bull then they get a message/pop up whatever to say it needs to be filled - like a Validation Rule.

I tried adding this piece of code to it and various tinkerings but no such luck.
<apex:pagemessages>
    if ( Onboarding__c.Interested_in_invoicing_through_Himama__c == False) {
       Onboarding__c.Interested_in_invoicing_through_Himama__c.addError( 'You must enter a value');

}
  </apex:pagemessages>

There are about 6 fields that we need to have to be required for clicking this button. Thanks!

 

Hi all,

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

trigger differentValues on User (before insert) {

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

This trigger it's not firing.. I'm confused why not?
I am working on a visualforce page that has an issue with the last two rows shifting to the left.

Below is the VF code. The code is looking at a number field to simulate months in a year. The last two <outputPanel>'s  shift to the left for some reason and I cant figure it out.

If I move those two panels somewhere in the middle of the code it aligns perfectly. 

Any help on this would be greatly appreciated.


 
<apex:page standardcontroller="Account" renderas="pdf" extensions="AccountExtensionController" standardstylesheets="false" showheader="false" applyhtmltag="false">
<form >
<html xmlns="http://www.w3.org/1999/xhtml">
    <body style="color:#000000;border-style:solid; border-width:0px; width:85%; text-align:center">
    </body>

    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif;text-align:left;"
               cellpadding="2">
            
            <tr>
                <td colspan="4" style="font-size:12px; font-weight: normal">
                </td>
            </tr>
            
            <tr>
                <td colspan="4" style="font-weight:bold ; border-style:solid; border-width:1px;
                border-color:#000000;padding:3px;text-align:center;background-color:#B4C6E7">
                    SERVICE PARTNER DETAILS
                </td>
            </tr>

    </table>
            
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif; text-align:left;"
               cellpadding="2">
            <tr>
                <td width="50%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;padding:3px;padding-top:10px">
                    <b>Company</b> {!Account.Name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

                <td width="50%" align="right" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color:#ffffff;font-style:normal; font-weight:normal;padding:3px;padding-top:10px">
                    <b>Office Phone</b> {!Account.Phone}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            </tr>
            <tr>
                <td width="25%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;padding:3px">
                    <b>Contact</b> {!Account.Primary_Field_POC__r.FirstName} {!Account.Primary_Field_POC__r.LastName} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

                <td width="25%" align="left" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color:  #ffffff;font-style:normal; font-weight:normal;padding:3px"><b>Cell Phone</b> {!Account.Secondary_Phone__c}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            <tr>
                <td width="25%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;padding:3px">
                    <b>Street Address</b><br/> {!Account.BillingStreet}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

                <td width="25%" align="left" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color:#ffffff;font-style:normal; font-weight:normal;padding:3px"><b>Fax</b> {!Account.Fax}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            
            <tr>
                <td width="25%" align="left" style="color: #000000;text-align:left; border-left-style: solid; border-left-width: thin;
                border-left-color: #ffffff;font-style:normal; font-weight:normal;padding:3px">
                    <b>City, St. Zip</b><br/> {!Account.BillingCity}, {!Account.BillingState} {!Account.BillingPostalCode}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td width="25%" align="left" style="color: #000000;text-align:left; border-right-style: solid; border-right-width: thin;
                border-right-color: #ffffff;font-style:normal; font-weight:normal;padding-bottom:10px"><b>Email</b> {!Account.Primary_Field_POC__r.Email}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="4" style="font-weight:bold ; border-style: solid; border-width:1px;
                border-color: #000000;padding:3px;padding:3px;text-align:center;background-color:#B4C6E7">PER PUSH FEE SERVICE AGREEMENT</td>
            </tr>
    </table>
            
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif;  text-align:left;"
               cellpadding="4">
          
            <tr>
               
            <td width="50%" align="left" style="color: #000000;text-align:center; border-right-style: solid; border-right-width: thin;
                border-right-color: #ffffff;font-style:normal; font-weight:normal;padding:3px">Per Push Fees: Includes all fees necessary to complete the services described in the scope of work for the event duration.  Hourly pricing applies only to extra services.
            </td>
            </tr>
    </table>
 
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif;text-align:center;" cellpadding="2">
            
            <tr>
                <td colspan="4" style="font-size:12px; font-weight: normal">
                </td>
            </tr>
            
            <tr>
                <td colspan="4" style="font-weight:bold ; border-style: solid; border-width:1px;
                border-color:#000000;padding:3px;background-color:#B4C6E7;">
                  Service Locations and Fees
                </td>
            </tr>
        <tr><td></td></tr>
    </table>
   
    <table align="center" width="85%" style="font-family: Arial, Helvetica, sans-serif; text-align:center;"
               cellpadding="0">
              
            <apex:repeat var="sd" value="{!bidsList}">
          
              <apex:outputPanel layout="none" rendered="{!IF(sd.IsAddedToPDF__c =true  ,true,false)}" style="vertical-align:central; font-family: Arial, Helvetica, sans-serif; text-align:center;width:85%">

                    <tr>
                        <th style="text-align:center;background-color:#0094DA;border-bottom-style:solid;border-bottom-width:1px;border-top-width:1px; border-top-style:solid">Site Name</th>
                        <th style="text-align:center;background-color:#0094DA;border-bottom-style:solid;border-bottom-width:1px;border-top-width:1px; border-top-style:solid">Service Period</th>
                        <th style="text-align:center;background-color:#0094DA;border-bottom-style:solid;border-bottom-width:1px;border-top-width:1px;border-top-style:solid">Address</th>
                    </tr>

                   </apex:outputPanel>
                 
                <apex:outputPanel layout="none" rendered="{!IF(sd.IsAddedToPDF__c =true  ,true,false)}" style="vertical-align:central;font-family: Arial, Helvetica, sans-serif; text-align:center;width:85%">
                   
                    <tr>
                       
                        <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2" ><apex:outputPanel rendered="{!IF(sd.IsAddedToPDF__c =true  ,true,false)}"> {!sd.Customer__r.Name }</apex:outputPanel> </td>
                       
                       <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2" ><apex:outputPanel rendered="{!IF(sd.IsAddedToPDF__c =true  ,true,false)}"> <apex:outputText value="{0, date, MMMM d','  yyyy}">
                        <apex:param value="{!sd.Customer__r.Contract_Start_Date__c}" /> </apex:outputText>Seasonal<apex:outputText value="{0, date, MMMM d','  yyyy}"><apex:param value="{!sd.Customer__r.Contract_End_Date__c}" /></apex:outputText>

                </apex:outputPanel></td>

                       <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2" ><apex:outputPanel rendered="{!IF(sd.IsAddedToPDF__c =true  ,true,false)}">{!sd.Site__r.BillingStreet}<br/>{!sd.Site__r.BillingCity}, {!sd.Site__r.BillingState} {!sd.Site__r.BillingPostalCode} </apex:outputPanel></td>

                    </tr>

                </apex:outputPanel>
               
                       <apex:repeat var="et" value="{!bidsMap[sd.Name] }" rendered="{!IF(sd.IsAddedToPDF__c =true  ,true,false)}"    >
    
                   <tr>
                       <th style="text-align:center;background-color:#28baff;border-bottom-style:solid;border-bottom-width:1px;border-top-width:0px; border-top-style:solid">Month</th>
                       <th style="text-align:center;background-color:#28baff;border-bottom-style:solid;border-bottom-width:1px;border-top-width:0px; border-top-style:solid"></th>
                       <th style="text-align:center;background-color:#28baff;border-bottom-style:solid;border-bottom-width:1px;border-top-width:0px; border-top-style:solid">Monthly Payment</th>
                      
                   </tr>

                   
        <apex:outputPanel layout="none" rendered="{!IF(et.UOM__c ='Seasonal'  ,true,false)}" style="vertical-align:central; font-family: Arial, Helvetica, sans-serif; text-align:center;width:85%">
        
            
            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 1  ,true,false)}">
         <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Jan-20</td>
                            
                            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>

            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>
            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 2  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Feb-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 3  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Mar-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 4  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Apr-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 5  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-May-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>
           

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 6  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Jun-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>
          

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 7  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Jul-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 8  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Aug-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 9  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Sep-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 10  ,true,false)}">

        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Oct-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText> </td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 11  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Nov-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>

            <apex:outputPanel layout="none" rendered="{!IF(et.Number_of_Months__c >= 12  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">10-Dec-20</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Monthly_Payment__c}" /> </apex:outputText></td>
        </tr>
             </apex:outputPanel>
             
             <apex:outputPanel layout="none" rendered="{!IF(et.UOM__c ='Seasonal'  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2">Retainer Fee</td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Retainer_Fee__c}" /> </apex:outputText></td>
        </tr>
            </apex:outputPanel>
             <apex:outputPanel layout="none" rendered="{!IF(et.UOM__c ='Seasonal'  ,true,false)}">
        <tr>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:bold ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"></td>
            <td style="font-weight:normal ; border-bottom-style:solid; border-bottom-width:1px;
                            color:#000000;padding:3px;text-align:center;background-color:#f2f2f2"><b>Total&#58; &nbsp;</b><apex:outputText value="{0, Number, Currency}"><apex:param value="{!et.Total__c}" /> </apex:outputText></td>
        </tr>
             </apex:outputPanel>
             </apex:outputPanel>
             </apex:repeat>
             </apex:repeat>
        </table>
     </html>
</form>

</apex:page>

 
  • August 12, 2019
  • Like
  • 0
Hi Experts,

I don't want show the field if there is no value in Discount filed.

<td style="border-bottom:1px solid black;border-right:1px solid black;" align="center"> {!QLI.Discount__c}{!if(QLI.Discount__c != null,'%','')} </td>

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

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

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

            Integer elems; // White space to insert

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

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

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

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

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

            if (len < charPerLine)
                continue;

            Integer elems;

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

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

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

        return text;
    }

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

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

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

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

cheers
suresh