• Shashikant Sharma
  • ALL STAR
  • 11033 Points
  • Member since 2011
  • ForceSchool ( forceschool.blogspot.in )


  • Chatter
    Feed
  • 405
    Best Answers
  • 0
    Likes Received
  • 7
    Likes Given
  • 1
    Questions
  • 2506
    Replies
I want to  get the id for a record in an object called patient__C and render the patient detail page in a VF page without having to specify each detail field.  I have created the standard controller Patient to get the record id and get the error This gives error: Illegal Assignment List to List:

public with sharing class Patient {
    
        public String patientId{get;set;}
         

         public Patient(){
             String pat = apexpages.currentPage().getParameters().get('Id');
            List<patient> patID  = [Select id from Patient__c where id = :pat Limit 10];
 }
}

Here is the visualforce page code:
<apex:page standardController="Patient">
    
    <apex:detail />
    
</apex:page>

Can anyone tell me what I am doing wrong?
 

Hi, I have the following schedulable class below and i wanted to be able to schedule it to run at 12am through the UI by navigating to schedule apex and then setting it to run every day at 12am. However, after this job has ran, i want it to schedule a subsequent job (same class) to run in the next hour. Is this possible?

The goal is to only schedule it through the UI to run at 12 Am and then it will automatically schedule the remaining jobs 1 hour later.
 

global class SampleClass implements Schedulable{
    global void execute(SchedulableContext alistContext) {
        Database.executeBatch('myBatchClass', 100);

       //when database executebatch is done, I want to schedule the same job 1 hour later
       String cron_exp = '0 0 1 * * ?';
       String jobName = 'somename';
       System.Schedule(jobName, cron_exp, new SampleClass())
    }
}
Hi i used below code but its not working fine
1. Only one account record is displaying in first page
2.Popup window is not closing after record update or cancel.

Below is my code:
Page1:
<apex:page standardController="Account" recordSetVar="accs">
<script>
  function OpenVfpage(pid){
      var newwindow = window.open('/apex/Accsmallpopup?id='+pid, 'name=_blank','height=500,width=500,left=250,top=100'); 
  newwindow.focus();
 }
</script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!accs}" var="a" >
                <apex:column value="{!a.Id}"/>
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.Phone}"/>
                <apex:column value="{!a.Industry}"/>
                <apex:column id="two">
                    <apex:commandButton value="Click" onclick="OpenVfpage('{!a.id}')" reRender="two"/>
               </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Page2:
<apex:page controller="Accpopup2" showHeader="false" sidebar="false" id="the">
   <apex:form id="page">
    <apex:pageblock id="close">
    <apex:pageBlockSection >
        <apex:inputfield value="{!a.Name}"/>
         <apex:inputfield value="{!a.Phone}"/>
     </apex:pageBlockSection>
        <apex:pageblockbuttons >
        <apex:commandButton value="save" action="{!save}"/>
        <apex:commandButton value="cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
            <apex:inputHidden id="pass" value="{!status}"/>
             </apex:pageblock>
        
            <script language="JavaScript" type="text/javascript">
            if(document.getElementById('the:page:close:pass').getAttribute('value') == 'true')
                {
                    window.top.close();
                }
            </script>   
             </apex:form>
</apex:page>

Controller: 
public class Accpopup2 
{
    public Account a {get;set;}
    public string status {get;set;}
    public Accpopup2()
    {
      a = new account();  
    }
    public pagereference save()
    {
    ID caseID = apexpages.currentPage().getParameters().get('id');
    if(caseid!=null)
    {
        account acc = [select Name,Phone from account where ID =: caseID];
        acc.Name = a.Name;
        acc.Phone = a.Phone;
        update acc;
    }
       
        return null;
    }
    
    public pagereference cancel()
    {
        status = 'true';
          return null;    
    }
}
Hi,I am new to salesforce. Wanted to know that, is there any functionality in SOQL that can work similar to "NVL" functionality in SQl? 
This is not a how to question, but a best practice/opinion question. I have a request to update a calculation on specific child records when a field on a parent record is updated. I am hesitant to do this since then the children records will go through the entire save procedure (including a good amount of Apex code), so it would add a bit more processing to the Apex transaction. My question is, when would you go ahead with this request vs pushing back and trying to find another solution (i.e. batch update of the child records every hour/night, new business process-- after updating the parent, go and check this checkbox on the children, . . . )? In general there shouldn't be more than 5 child records per parent that need to be updated.
I have a record that currently has Status__c='Draft'
When I click the Start button, i want status to change to 'In Progress'
I have used following JS code to achieve this
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var p = new sforce.SObject('Product_Order__c'); 
p.id = "{!Product_Order__c.Id}"; 
p.Status__c = "In Progress"; 
result = sforce.connection.update([p]); 
location.reload(true);

But, in Apex Trigger, I want to do some complex stuff when status changes from Draft to In Progress.
In my afterUpdate event, I am hooking on 

        Product_Order__c newPO = (Product_Order__c)o;
        Product_Order__c oldPO = (Product_Order__c)o;
        system.debug(newPO.Status__c);
        system.debug(oldPO.Status__c);
        if (newPO.Status__c.equals('In Progress') && newPO.Status__c != oldPO.Status__c)
            newInProgressPO.put (newPO.Id, newPO.RecordType.Name);

However, these two User Debugs show that both old and new statuses are 'In Progress' so my Map is always empty.

Does anybody have any ideas?
When adding products to an Opportunity the list is not sorted alphabetically.  How can I update this list view to display all my product alphabetically rather than randomly as the appear below?

User-added image

This is my Apex code where it brings in the product list.

<apex:outputLabel value="Product Name" for="productName"/> <apex:selectList id="productName" value="{!PricebookEntrys}" size="1" required="true"> <apex:selectOptions value="{!items}"/> </apex:selectList>

Can anyone help sort the products alphabetically?

Thanks in advance for any assistance
I have a class that does some work but at the end it needs to call the batch apex and pass a query the problem I am having is I want the query to be only where id in MyMap. For example 
Database.executeBatch(new JsonMassImportBatch('Select id, Name from Contract where id in : ' (Map in the batch class with the ids keyset should be here),'Contract',new JsonMassImportBatch.CustomObj(holdLease,new List<String>{'Current_Rental_Rate__c','Renewal_Date__c'},holdDate)));
The end is me passing in the map for the batch call to use ie holdlease

How should i format the batch side to make this work?  
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query + LeaseMap.keySet());
    }
 
I keep getting the following error when I test the code below:
System.ListException: List index out of bounds: 0

This error occurs on lines 13, 34, 64, and 93.  It looks like the list is pulling no records and I cannot figure out why.  I have confirmed that all required fields are captured.  I referenced another article that said to use @isTest (seeAllData=true) and it is still not working.

Help would be greatly appreciated - thank you in advance!!



@isTest (seeAllData=true)
private class leadsTaskHandlerTest {

    @isTest static void testLeadsWorkflow() {

        Lead newLead = new Lead(
                        Company = 'Test Account', FirstName= 'Test', LastName= 'Lead',
                        LeadSource = 'Web', Country = 'Canada',  Email = 'something@gmail.com',
                        Status = 'Open', Lead_Type__c = 'New Car Franchise');
        insert newLead;

        Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhoId = :newLead.Id AND Subject = 'Evaluate and Assign Web Lead'];
        tasks[0].Status = 'Completed';
        update tasks[0];

        System.assert(taskCreatedForLead('Email Introduction of TradeRev to main contact person', newLead.Id));
        System.assert(taskCreatedForLead('Phone call to follow up from email of introduction', newLead.Id));
        System.assert(taskCreatedForLead('Schedule an appointment with lead; no voicemail if you don\'t connect', newLead.Id));
        System.assert(taskCreatedForLead('Attempt to contact lead to set appointment second time in the week', newLead.Id));
        System.assert(taskCreatedForLead('Any interest in TradeRev?; let\'s schedule a demo', newLead.Id));
        System.assert(taskCreatedForLead('Touch base to let them know about growth/updates of TradeRev', newLead.Id));
        System.assert(taskCreatedForLead('Are they ready to talk about TradeRev?', newLead.Id));

    }


  @isTest static void testContractWorkflow() {
        Lead newLead = new Lead(
                        Company = 'Test Account', FirstName= 'Test', LastName= 'Lead',
                        LeadSource = 'Web', Country = 'Canada',  
                        Status = 'Contract Given', Lead_Type__c = 'New Car Franchise');
        insert newLead;
        Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhoId = :newLead.Id AND Subject = 'Any questions on the Registration Forms?'];
        tasks[0].Status = 'Completed';
        update tasks[0];

        System.assert(taskCreatedForLead('Are the Registration Forms complete?', newLead.Id));
    }

    @isTest static void testDueDateEmail() {
        Lead newLead = new Lead(
                        Company = 'Test Account', FirstName= 'Test', LastName= 'Lead',
                        LeadSource = 'Web', Country = 'Canada', Email = 'something@gmail.com', 
                        Status = 'Contract Given', Lead_Type__c = 'New Car Franchise');
        insert newLead;
        Task newTask = new Task(    Priority = 'Normal', 
                                        Status = 'Not Started',
                                        ActivityDate = Date.today(), 
                                        WhoId = newLead.Id); 
        insert newTask;
        update newTask;
    }


    @isTest static void testFranchiseDealerWorkflow() {

        Account newAccount = new Account(
                        Name = 'Test Franchise Dealer',
                        AccountSource = 'Web',
                        Account_Type__c = 'New Car Franchise');
        insert newAccount;

        Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhatId = :newAccount.Id AND Subject = 'Set appointment for Installation and Training Franchise'];
        tasks[0].Status = 'Completed';
        update tasks[0];


        System.assert(taskCreatedForAccount('Assist with On-boarding', newAccount.Id));
        System.assert(taskCreatedForAccount('Launch Cars; Walk back lot and try identify more cars they can load', newAccount.Id));        
        System.assert(taskCreatedForAccount('Has buyer been in touch to make arrangements for payment/pickup?', newAccount.Id));
        System.assert(taskCreatedForAccount('Has buyer taken car? Mark car delivered', newAccount.Id));
        System.assert(taskCreatedForAccount('Use TradeRev for the Live Appraisals', newAccount.Id));    
        System.assert(taskCreatedForAccount('Any other cars to launch?', newAccount.Id));
        System.assert(taskCreatedForAccount('Reminder to buy cars on TradeRev', newAccount.Id));

        System.assert(taskCreatedForAccount('Feedback on TradeRev; any referrals?', newAccount.Id));
        System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Good time to sell cars on TradeRev', newAccount.Id));
        //System.assert(taskCreatedForAccount('Monthly Report; Tips For Better Listings', newAccount.Id));
        //System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Good time to sell cars on TradeRev', newAccount.Id));
        //System.assert(taskCreatedForAccount('Monthly Report; Tips For Better Listings', newAccount.Id));

    }

    @isTest static void testIndepedentDealerWorkflow() {

        Account newAccount = new Account(
                        Name = 'Test Independent Dealer',
                        AccountSource = 'Web',
                        Account_Type__c = 'Independent Dealer');
        insert newAccount;

        Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhatId = :newAccount.Id AND Subject = 'Set appointment for Installation and Training'];
        tasks[0].Status = 'Completed';
        update tasks[0];


        System.assert(taskCreatedForAccount('Assist with On-boarding', newAccount.Id));
        System.assert(taskCreatedForAccount('Any questions on bidding?', newAccount.Id));        
        System.assert(taskCreatedForAccount('Have they been bidding? Any cars in pending?', newAccount.Id));
        System.assert(taskCreatedForAccount('Won any cars? Discuss timing expectations for payment and pickup', newAccount.Id));
        System.assert(taskCreatedForAccount('If a car has been won; have they paid and picked up car yet?', newAccount.Id));    
        System.assert(taskCreatedForAccount('Feedback on TradeRev; any referrals?', newAccount.Id));
        System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Having success moving the cars bought on TradeRev?', newAccount.Id));
        System.assert(taskCreatedForAccount('Touch Point; How are you doing? Can I help with anything? Having success moving the cars bought on TradeRev?', newAccount.Id));

    }



    static boolean taskCreatedForLead(String subject, Id id) {
        Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhoId = :id AND Subject = :subject];
        if (tasks.size() > 0) {
            tasks[0].Status = 'Completed';
            update tasks[0];
            return true;
        }
        else {
            return false;
        }
    }

    static boolean taskCreatedForAccount(String subject, Id id) {
        Task[] tasks = [SELECT Id, Subject FROM Task WHERE WhatId = :id AND Subject = :subject];
        if (tasks.size() > 0) {
            tasks[0].Status = 'Completed';
            update tasks[0];
            return true;
        }
        else {
            return false;
        }
    }
    
    
}
Hi Expert,

I am using a test class for coverage 75% code, but few things are not covered. Can any one suggest what is going wrong.

this my test Class: --
@isTest
public class TestProfessorSelectCourse {
    @isTest static void ProfessorCourse(){
       
        
        Professor__c prof = new Professor__c(Name ='JP',Email__c='jp@gmail.com');
        insert prof;
        
        Class__c cls = new Class__c(name='12G', Class_Teacher__c = prof.id);
        insert cls;
        
        Course__c cors = new Course__c(Professor__c=prof.id,Class__c =cls.id, name='Ruby', Start_Date__c= Date.today() , End_date__c= Date.newInstance(2017,03,20));
       	//Professor__c prof = new Professor__c(Name ='JP');
        //cors.Professor__c = prof.Name;
        insert cors;
    }
}

and below is my main class


User-added image

Thanks 
Mukesh
I am trying to build a simple page to display the Opportunity and associated Line Items. I am getting this error which doesn't make sense because I am including OpportunityId in the OLI query. 

My extension:
public class PrintContract {
    
    private final Opportunity opp;

    public PrintContract(ApexPages.StandardController stdController) {
            stdController.addFields(new String[]{
            'Id',
            'LinkContacttoOpportunity__c',
            'Name',
            'CloseDate',
            'Contract__c',
            'Type',
            'Age__c',
            'Amount',
            'EXW_Expiration_Date__c',
            'EXW_Effective_Date__c'
        });    
        
        //    get current opportunity record
        this.opp = (Opportunity)stdController.getRecord();
    }
        public List<OpportunityLineItem> oli {get;set;}

        public void olis(){
        oli = new List<OpportunityLineItem>([SELECT Id, TotalPrice, Class__c, ServiceDate, OpportunityId, Quantity, Contract__c, Is_Accessory__c, Serial_Number__c
                    FROM OpportunityLineItem 
                       WHERE OpportunityId = :opp.ID]);
           }
}

My Page:
<apex:page standardController="Opportunity" extensions="PrintContract" action="{!olis}">
    <apex:pageBlock rendered="{!Opportunity.HasOpportunityLineItem = TRUE}">
        <apex:pageBlockTable value="{!oli}" var="ol">
            <apex:column headerValue="Plan Number" value="{!ol.Contract__c}" />
            <apex:column headerValue="Serial Number" value="{!ol.Serial_Number__c}" />
            <apex:column headerValue="Purchase Date" value="{!ol.ServiceDate}" />
            <apex:column headerValue="Plan Type" value="{!ol.Opportunity.Type}" />
            <apex:column headerValue="Plan Effective Date" value="{!ol.Opportunity.EXW_Effective_Date__c}" />
            <apex:column headerValue="Plan Expiration Date" value="{!ol.Opportunity.EXW_Expiration_Date__c}" />
            <apex:column headerValue="Plan Cost" value="{!ol.TotalPrice}" />

        </apex:pageBlockTable>
    
    </apex:pageBlock>
</apex:page>
We use a custom Sales Order object where sales orders can be created directly from Accounts or from Opportunities on the Accounts. I need to place a validation rule on our Opportunity object based on whether or not a sales order has been created. When I try to create a roll-up summary custom field, the Sales Order (related list object) is not an option to select in the Summarized Object picklist. How can I make the sales order display in the picklist? Or, is there another way to determine if a sales order has been created from the opportunity?
Hello there,

I'm still pretty new to code development and I am using the following trigger and class.

Trigger:
trigger AccountTerritoryTag on Account (before insert, before update)
{
    Set<String> setName =  new Set<String>();
    for (Account account : Trigger.new)
    {       
        if (account.RunAssignment__c == TRUE)
        {
            setName.add(account.RoutingKey__c);
        }   
    }   
    
    if(setName.size() > 0 )
    {
        List<RoutingKey__c> routingkey = [select Name,Territory__c from RoutingKey__c  where Name in :setName ];
        Map<String, RoutingKey__c> mapNameWiseR = new  Map<String, RoutingKey__c> ();
        for(RoutingKey__c  RK : routingkey )
        {
            mapNameWiseR.put(RK.Name , RK);
        }

        for (Account account : Trigger.new)
        {    
          if (account.RunAssignment__c == TRUE)
          {
              if (mapNameWiseR.containsKey(account.RoutingKey__c) )
              {   
                    RoutingKey__c rk = mapNameWiseR.get(account.RoutingKey__c);
                  //assign the territory 
                    account.Territory__c = rk.Territory__c;
                    account.RunAssignment__c = FALSE;
             
              }
           }
        }
        
    }
        
}


Test Class:
@isTest

private class AccountTerritoryTest
{
    static testMethod void AccountTerritoryTest()
    { 
       Territory__c t = new Territory__c();
       t.Name = 'TerritoryTest';
       insert t;
       
       RoutingKey__c k = new RoutingKey__c();
       k.Name = 'NAM|SMB|FL';
       k.Territory__c = t.id;
       insert k;
       
       Account a = new Account();
       a.Name  = 'Test';
       a.OverrideCountry__c = 'US';
       a.OverrideEmployees__c = 'A) 1-100';
       a.OverrideState__c = 'FL';
       a.RunAssignment__c = TRUE;
       insert a;
       
       a.RunAssignment__c  =  FALSE;
       a.Territory__c = t.id;
       update a;
       
    }
    
}

I'm stuck at 72% coverage and would like to increase as much as possible. I looked at my dev console and lines 17, 18, and 27-30 are uncovered by my class. I'm not certain how to write the class to cover these lines and the account update doesn't cover it. Can someone help/explain what I can do to fix this? Thank you in advance for the help!
 
I want to deploy a package that has an apex class, test class and a process builder that calls the apex class. On the sandbox where I developed the class, the code coverage is 100%. When I tried to deploy it to another sandbox/production, it failed because it showed the code coverage to be 65%.

I believe the issue is because the process builder is inactive when it is deployed and the entire code is not covered as a result. How should I proceed with this?

I have already tried to do the following :
  • Deploy the process builder first to activate it before deploying the classes. Deploying the process builder failed.
  • Deploy the classes without the process builder; code coverage was 65%.
  • Change the test class to accommodate more cases. This was not possible as I changed the code to work with process builder and I cannot find a way to test it.
  • I ran the test code when the process builder was activated and deactivated. It showed 65% coverage when it was deactivated, and 100% coverage when it was activated, as the process builder is called when a record is inserted in the test class.
My code takes the customer email and converts it to a hash using CryptoUtil.generateHashDigest method and then saves it in the hashed email field.
 
Public static void newRecord(List<Account> listAccounts) {
    for(Account a : listAccounts) {
        Account updacc=[select id from account where id = :a.id];
        String message = String.valueof(a.get('Customer_Email__pc'));
        String hashDigest = CryptoUtil.generateHashDigest(message);
        updacc.Hashed_email__pc = HashDigest;
        update updacc;
    }
}

I had to create a clone of the account record inserted/updated in order to use process builder. Using this method, the changes are only made in the clone. If process builder is not used, the test class gets a Null value instead of the actual hash value in the Hashed_email__pc field which leads to the test failing. When process builder is used, the changes made in the clone are reflected in the actual record, and the test passes. Even if I do not have a test method calling this section of code, the test passes as the process builder covers it.

I cannot figure out a way of creating a test class where the correct values are returned when the process builder is deactivated. I have to use DML to insert the record, so that it can be cloned.

How should I test the apex class in this case?
 
Hello,

What is the difference between Created by and Owner ?
 
  • April 13, 2016
  • Like
  • 0
User-added image

Hi guyz,

In account object Master detail field is not available. Could you guyz tell me why is that? Thanks in advance
I am getting date from related object Opportunities - need to keep it in a table format (this is a large table), snipit
<td bgcolor="#BDD7E7"><strong>Close Date</strong></td>
<td bgcolor="#C9D2E2">{!CO__c.Opportunity__r.CloseDate}</td>
And it displays Tue Mar 02 00:00:00 GMT 2021
Can I make it display Mar 02 2021 ?

Similarly
<td bgcolor="#BDD7E7"><strong> Value</strong></td>
      <td colspan="3" bgcolor="#C9D2E2">${!(ROUND(CO__c.Opportunity__r.Amount,0))}</td>
displays $4502
Can I make it display $4,502 ?
(Add "," every 3 digits, no decimal)

Thanks!

 
  • April 11, 2016
  • Like
  • 0
Hi, I have created a VF page for my custom object with a search field included. The search field works fine but when I enters a null character or 1 character, I expects it to show me an error message in the VF page, ideally in .INFO style but it is showing me an expression error on another page.

User-added image

I am very new to VisualForce and Apex and would appreciate some help. I know I am miissing something out but can't seem to figure it out.

Apex Class:
public class QFSearchController {

    String searchText;
    List<Quality_Feedback__c> results;
    

    public String getSearchText() {
        return searchText;
    }

    public void setSearchText(String s) {
        searchText = s;
    }
    
    public List<Quality_Feedback__c> getResults() {
        return results;
    }

    public PageReference doSearch() {
    

if(searchText==null || searchText=='')
 { 
 Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Search term must be longer than one character:')); 
 }
 
 else if (searchText.length()<2)
 {
 Apexpages.addMessage(new Apexpages.Message(ApexPages.severity.INFO, 'Input box must contain at least two characters')); 
 }
 results = (List<Quality_Feedback__c>)[FIND :searchText RETURNING Quality_Feedback__c(Name, Type_of_Feedback__c,    
Feedback_For__c,   Reviewed_By__c, Review_Status__c, Incident__c)][0];
        return null;
    }
}

VisualForce Page:
<apex:page controller="QFSearchController"> 
 <apex:ListViews type="Quality_Feedback__c" />
   <apex:form >   
      <apex:pageBlock mode="edit" id="block">
         <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
               <apex:outputLabel for="searchText">Search Text</apex:outputLabel>
               <apex:panelGroup >
                  <apex:inputText id="searchText" value="{!searchText}"/>
                  <apex:commandButton value="Go!" action="{!doSearch}" 
                                      rerender="block" status="status"/>
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="requesting..."/>
        <apex:pageBlockSection title="Results" id="results" columns="1">
           <apex:pageBlockTable value="{!results}" var="l" 
                               rendered="{!NOT(ISNULL(results))}">
              <apex:column value="{!l.name}"/>
              <apex:column value="{!l.Type_of_Feedback__c}"/>
              <apex:column value="{!l.Feedback_For__c}"/>
              <apex:column value="{!l.Reviewed_By__c}"/>
              <apex:column value="{!l.Review_Status__c}"/>
              <apex:column value="{!l.Incident__c}"/>
           </apex:pageBlockTable>
        </apex:pageBlockSection>
      </apex:pageBlock>
       <apex:pageMessages />
   </apex:form>
 
</apex:page>

Thanks in advance.
The fromula seems to be working, but its displaying
"<img src="/servlet/servlet.FileDownload?file=0151600000QNE8V" alt=" " border="0"/>"
Instead of the image. Seems like a need URL reference?

This is the code on VF page to display picklist
<apex:outputField value="{!customo__c.Flag__c}" >    
    <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
    hideOnEdit="editButton" event="ondblclick" 
    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
and field Flag__c is picklist "Green" , "Red"

This is the code on VF page to display image
{!customo__c.Flag_formula__c}
This is the fromula (text) for field "Flag_formula__c"
IMAGE(
CASE(Flag__c,
"Green","/servlet/servlet.FileDownload?file=0151600000QNE8V",
"Red","/servlet/servlet.FileDownload?file=0151600000QNE8f",
""),"")
The images URL work
https://c.na23.content.force.com/servlet/servlet.FileDownload?file=0151600000QNE8V
https://c.na23.content.force.com/servlet/servlet.FileDownload?file=0151600000QNE8f


 
  • April 09, 2016
  • Like
  • 0
Hey Guys,

Can anyone help me how to hide the stage filed in the opportunites object which is a required standard field.

Thanks in advance.
Virinchi.

 I need to fetch history of user record in Apex Class. Is there any way to enable history tracking on User Obejct. I do not see "Set History Tracking" button above User Fields like we see in Account object.

I'm trying to read Unit of Measure on Product2. But getting compile time error as below.
 
No such column 'QuantityUnitOfMeasure' on entity 'Product2'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

But in Product entity field seems there.

Product standard fields

Not sure if I am using a wrong field name. In docs I couldn't find this field though. Can someone help me with reading unit of measure in product using SOQL?

Appreciate any help. Thanks.

 
I want to  get the id for a record in an object called patient__C and render the patient detail page in a VF page without having to specify each detail field.  I have created the standard controller Patient to get the record id and get the error This gives error: Illegal Assignment List to List:

public with sharing class Patient {
    
        public String patientId{get;set;}
         

         public Patient(){
             String pat = apexpages.currentPage().getParameters().get('Id');
            List<patient> patID  = [Select id from Patient__c where id = :pat Limit 10];
 }
}

Here is the visualforce page code:
<apex:page standardController="Patient">
    
    <apex:detail />
    
</apex:page>

Can anyone tell me what I am doing wrong?
 
Hi everyone, is it possible through Apex or visualforce for the following scenario?

User attaches an excel doc to a case record.  The values in the excel doc will populate specific case fields.  (The column headers will match the case fields).  Salesforce Classic, not lightning.

Thanks for any advice on best way to handle!
I have my UI on salesforce. I want a piece of code to execute on some server. How this can be  achieved?
Hello, good morning everyone.

Could you help? I created a field related to the account object and I want to fill in autometico when creating a record by Dataloader, the CSV file only contains the customer number, but not the account name (Account)

I have tried to populate that field by Process Builder, but I do not start as, the other option is to do a trigger, which as soon as the CSV is loaded, it will be triggered and compare "Customer Number" of my custom object against "Client Number" (Accounts) and if it is the same, fill in the field Master-detail, in my custom object. Do you have any idea how to do this trigger?

Look out for comments.User-added image
I have created a validation rule on a field on a custom object that is part of a managed package. The validation rule simply prohibits the text length in the field from exceeding 30 characters. The actual text field the rule is on is a 255 character text field, but for our uses we need to limit the length to 30 characters. Since that field is part of a managed packaged I cannot change the field length. It works perfectly for standard inputs.

The issue arises when a record in the object is created from another custom object in the managed package. We are using Process Builder to populate the field that the validation rule is on with the text from a custom field in the originating object. It worked flawlessly until I created the validation rule. The text field in the originating  object is only 30 characters long so it cannot exceed the rule limits. With the validation rule activated every time the originating object inserts a record the validation rule causes an error and prevents the insertion. And the Validation Rule fires before the Process Builder does so it cannot be the text length in the originating field causing the error.

Any ideas??
I am trying to add fields in the Edit Opporunity page, however it seems like I can't override.  How do I add Address, phone number and email onto the edit page? 

User-added image
 

Hi, I have the following schedulable class below and i wanted to be able to schedule it to run at 12am through the UI by navigating to schedule apex and then setting it to run every day at 12am. However, after this job has ran, i want it to schedule a subsequent job (same class) to run in the next hour. Is this possible?

The goal is to only schedule it through the UI to run at 12 Am and then it will automatically schedule the remaining jobs 1 hour later.
 

global class SampleClass implements Schedulable{
    global void execute(SchedulableContext alistContext) {
        Database.executeBatch('myBatchClass', 100);

       //when database executebatch is done, I want to schedule the same job 1 hour later
       String cron_exp = '0 0 1 * * ?';
       String jobName = 'somename';
       System.Schedule(jobName, cron_exp, new SampleClass())
    }
}
Hi i used below code but its not working fine
1. Only one account record is displaying in first page
2.Popup window is not closing after record update or cancel.

Below is my code:
Page1:
<apex:page standardController="Account" recordSetVar="accs">
<script>
  function OpenVfpage(pid){
      var newwindow = window.open('/apex/Accsmallpopup?id='+pid, 'name=_blank','height=500,width=500,left=250,top=100'); 
  newwindow.focus();
 }
</script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!accs}" var="a" >
                <apex:column value="{!a.Id}"/>
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.Phone}"/>
                <apex:column value="{!a.Industry}"/>
                <apex:column id="two">
                    <apex:commandButton value="Click" onclick="OpenVfpage('{!a.id}')" reRender="two"/>
               </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Page2:
<apex:page controller="Accpopup2" showHeader="false" sidebar="false" id="the">
   <apex:form id="page">
    <apex:pageblock id="close">
    <apex:pageBlockSection >
        <apex:inputfield value="{!a.Name}"/>
         <apex:inputfield value="{!a.Phone}"/>
     </apex:pageBlockSection>
        <apex:pageblockbuttons >
        <apex:commandButton value="save" action="{!save}"/>
        <apex:commandButton value="cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
            <apex:inputHidden id="pass" value="{!status}"/>
             </apex:pageblock>
        
            <script language="JavaScript" type="text/javascript">
            if(document.getElementById('the:page:close:pass').getAttribute('value') == 'true')
                {
                    window.top.close();
                }
            </script>   
             </apex:form>
</apex:page>

Controller: 
public class Accpopup2 
{
    public Account a {get;set;}
    public string status {get;set;}
    public Accpopup2()
    {
      a = new account();  
    }
    public pagereference save()
    {
    ID caseID = apexpages.currentPage().getParameters().get('id');
    if(caseid!=null)
    {
        account acc = [select Name,Phone from account where ID =: caseID];
        acc.Name = a.Name;
        acc.Phone = a.Phone;
        update acc;
    }
       
        return null;
    }
    
    public pagereference cancel()
    {
        status = 'true';
          return null;    
    }
}
Does anyone know if it is possible to get the selected stage values using SOQL ... see screen shot below:

User-added image

My thoughts were that this information would be stored in a Picklist, but I have only been able to get to the various Sales Process values:

Find the FieldDefinitionId
SELECT EntityDefinitionId, QualifiedAPIName, FieldDefinitionId FROM EntityParticle WHERE EntityDefinition.QualifiedApiName LIKE '%Business%' AND DataType = 'picklist'

Get the Picklist values based on the EntityParticleId which will equal the FieldDefinitionId​
SELECT DurableId,EntityParticleId,Id,IsActive,IsDefaultValue,Label,ValidFor,Value FROM PicklistValueInfo WHERE EntityParticleId = 'BusinessProcess.TableEnumOrId' ORDER BY label

How do you get those Selected Values ... if it can be done on the Sales Process page you would think you'd be able to use SOQL to get that information.

Thank you in advance for your time and input.
Hi,I am new to salesforce. Wanted to know that, is there any functionality in SOQL that can work similar to "NVL" functionality in SQl? 
HI,

I'm working with a visualforce page and form and I wanted to display a list if U.S. States as just text with checkboxes underneath each state for the cities in that state. 

So for example:

Nevada
 - Reno
 - Carson City
 - Las Vegas

Colorado
 - Denver
 - Boulder

I have a custom object that stores customer records.  In the address fields I store the city and state.  I want to generate the output above using this data and have a checkbox rendered for each city.

Any ideas on how to do this using visualforce?
 
  • September 16, 2015
  • Like
  • 1
Need help with my VF page.  I am trying to display only the list view with no header, no buttons, no sidebar and not actions.  Anyone know how?
 
<apex:page sidebar="false" >
  
   <apex:enhancedlist type="Location__c" height="730" customizable="false" rowsPerPage="50" Listid="00B19000000S8a3"  />
  
</apex:page>

 
Hi folks,

I have written one class in org1.I generated wsdl file and partner wsdl of that class. I login to other salesforce org2 and import those two files into this org. I created one stub class in org2 and using this class i have called those classes and methods and callout this stub class using developer console. While executing this class it throws an error [System.CalloutException: IO Exception: Unauthorized endpoint, please check Setup-&gt;Security-&gt;Remote site settings. endpoint = https://login.salesforce.com/services/Soap/u/34.0]. I have pasted login url in Remote site settings in org 2.

Apex class in Org1:
global class webservicesoap1
{
 webservice static string createcontact(string Fname,string Lname,String phone)
 {
 list<contact> conlist=[select id from contact where firstname =:fname and lastname =:lname and phone =:phone];
  if(conlist.size()!=0)
   {
    return 'contact already exists';
    }
    else{
     contact c=new contact();
     c.firstname=fname;
     c.lastname=lname;
     c.phone=phone;
     insert c;
     return c.id;
     }
     }
     }

Stub Class i implemented in org2:

public class soapcallout
{

    public soapcallout(ApexPages.StandardController controller) {

    }

 public soapcallout()
 {
    partnerSoapSforceCom.soap spc=new partnerSoapSforceCom.soap();
    string username ='sfgt@283.com';
    string password ='radhekrishna***AIyGjqKUpuRnKaBzoX6XRUnzH';
    partnerSoapSforceCom.loginresult loginresult = spc.login(username, password);
    system.debug(loginresult.sessionid);
    
    soapSforceComSchemasClassWebservice.webservicesoap1 websrvc= new soapSforceComSchemasClassWebservice.webservicesoap1();
    soapSforceComSchemasClassWebservice.SessionHeader_element sessionheader =new soapSforceComSchemasClassWebservice.SessionHeader_element();
    sessionheader.sessionid = loginresult.sessionid;
    websrvc.timeout_x = 120000;
    websrvc.sessionheader = sessionheader;
    string s = websrvc.createcontact('Mahesh','Krishna','9526389523');
    }
    }



 
hi
when i convert lead to opportunity i want to display lead name that converted in opportunity.i want to write it in triggers based on a check box i am updating that field. 
 
It has been a few years since I've worked on Salesfoce. But I'm back for more! I was pocking around looking for a new sparkly IDE that might be waiting for me and I'm left with a feeling of confusion. What is going on? I get that Salesforce has/is working hard on the tooling api but who has a solid IDE solution that has professional support and sparkly toys? I know I know, I can just use the Eclipse plugin but you know, its not sparkly.

Cloud9 looks like the perfect solution for salesforce developers. The two cloud geeks are already working together with Heroku so why don't they have a OOTB Cloud9 solution for Salesforce.com development?

Has anyone tried to hook up a salesforce org with Cloud9? If not someone should make that happen. Or maybe I should have a go at it.
I looked at BrainEngine but the sign up page gives an azure 403, for that last week. It didn’t look like BrainEngine had more than one guy supporting it, and not open source. Maybe I’m overlooking something?

Any up dates on whats going on would be helpful.
 
I want to use extjs in visualforce but i am getting error Uncaught ReferenceError: Ext is not defined i also added all library related to ext js but this time also getting same error so How to solve this error. I have a urgent requirement to solve this issue .

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.