• Vivek Deshmane
  • SMARTIE
  • 1281 Points
  • Member since 2014
  • Certified Salesforce Consultant, Advanced Developer(Vivek.deshmane@gmail.com)

  • Chatter
    Feed
  • 40
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 1
    Questions
  • 213
    Replies
I wrote a search functionality,i want to show a message "no records found" when there are no records on the entered letter
through a javascript,i got through pagemessage,but i want  through javascript.I tied but its not working,can u please help me regarding this.

<apex:page controller="searchwithactionstatuscontroller" id="one">
<script>
function js(value){
var inputValue = document.getElementById(search).value;
alert(inputValue );
if(inputValue==null||inputValue==''){
alert('no records found');
}
else{
actionFunName();
}
}
</script>

<apex:form id="two">
       <apex:actionFunction name="actionFunName" action="{!searchpositions}"  reRender="two" />
<apex:outputLabel for="search" value="SEARCH :" style="font-weight:bold"   />
<apex:inputText value="{!search}"  id="search" onkeyup="js(value)"   />
<!--<apex:actionSupport event="onkeyup" action="{!searchpositions}" reRender="one:two:block1"/>-->
<apex:outputText id="error" value="{!error}" />
<apex:pageBlock rendered="{!blockOnLoad}" id="block1">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!poslis}" var="pl"   >
<apex:column value="{!pl.name}"/>
</apex:pageBlockTable> 
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock rendered="{!blockOnEnter}" > 
<apex:pageBlockSection id="d">
<apex:pageBlockTable value="{!pos}" var="p"  >
<apex:column value="{!p.name}"/>
<apex:column >
<apex:inputCheckbox value="{!p.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
 </apex:pageBlock> 
</apex:form>
</apex:page>


controller
---------------

public with sharing class searchwithactionstatuscontroller {

    public String error { get; set; }
public boolean blockOnLoad{set;get;}
public boolean blockOnEnter{set;get;}


    public PageReference searchpositions() {
        string holdString ='SELECT name from Position__c  where name like  \'%'+search+'%\' ORDER BY name asc';
        pos=Database.query(holdString);
       blockOnLoad=false;
        blockOnEnter=true; 
        return null;
    }
public String search { get; set; }
public List<position__c> poslis{set;get;}
public List<position__c> pos{set;get;}

public searchwithactionstatuscontroller() {
poslis=[select Name from position__c];
blockOnLoad=true;
blockOnEnter=false;
}
}
  • May 02, 2016
  • Like
  • 0
I  am working on a vf page that I would like and have a related list that I would like to only show records with a specific shipment type.  Basically I would liek the second pageblocktable to only show records where the shimpment_Type__c ="Drop Ship". 

<apex:page standardController="SFDC_Project__c">
    <style type="text/css">
        #head {font-size:25pt;}
    </style>
    <center>
        <h1 id="head">
        Installation Shipping Information
        </h1>
    </center>
    <apex:pageBlock title="Installation Details">
    <apex:pageBlockSection>
        <apex:outputField value="{! SFDC_Project__c.Name }"/>
        <apex:outputField value="{! SFDC_Project__c.Account__c }"/>
        <apex:outputField value="{! SFDC_Project__c.SFDC_Project_Name__c }"/>
        <apex:outputField value="{! SFDC_Project__c.SFDC_Project_Manager__c}"/>
    </apex:pageBlockSection>
        <h1 id="t1head">
            Hardware Shipping Information
        </h1>
    <apex:pageBlockTable value="{!SFDC_Project__c.Hardware_Information__r}" var="hardware">
      <apex:column value="{!hardware.Shipment_Type__c}"/>
      <apex:column value="{!hardware.Ship_Date__c}"/>
      <apex:column value="{!hardware.Item_Master__c}"/>
      <apex:column value="{!hardware.Sales_Order__c}"/>
      <apex:column value="{!hardware.Sales_Order_Line_Item__c}"/>
      <apex:column value="{!hardware.Name}"/>
      <apex:column value="{!hardware.Quantity_Ordered__c}"/>
      <apex:column value="{!hardware.Quantity_Shipped__c}"/>
      <apex:column value="{!hardware.Carrier_for_Shipment__c}"/>
      <apex:column value="{!hardware.Tracking_Number__c}"/>
      <apex:column value="{!hardware.Ship_to_Address__c}"/>
   </apex:pageBlockTable>
        <h1 id="t2head" class="thead">
            Drop Shipped Serial Numbers
        </h1>
   <apex:pageBlockTable id="dropShipSN" value="{!SFDC_Project__c.Hardware_Information__r}" var="hardware">
      <apex:column value="{!hardware.Item_Master__c}"/>
      <apex:column value="{!hardware.Serial_Number_Shipped_from_Denver_Whs__c}"/>
      <apex:column value="{!hardware.Ship_Date__c}"/>
      <apex:column value="{!hardware.Ship_to_Address__c}"/>
       <apex:column value="{!hardware.Shipment_Type__c}"/>
   </apex:pageBlockTable>
</apex:pageBlock>
    

</apex:page>
 
I am successfully able to include visualforce page on Account layout. This page shows list of opportunities. Apex Code:
<apex:page standardController="Account" extensions="OpportunityController" sidebar="false" showheader="false">
<apex:pageBlock >
 <apex:pageBlockSection columns="1">
     <apex:pageBlockTable value="{!AccountOpportunity}" var="opty">
     <apex:column headerValue="Opportunity Name" > 
     <apex:outputlink title="Opportunity Name" value="/{!opty.id}">{!opty.Name}</apex:outputlink>
     </apex:column>
     <apex:column value="{!opty.Amount}"/>
     <apex:column value="{!opty.StageName}"/>
     <apex:column value="{!opty.CloseDate}"/>
     </apex:PageblockTable>
     </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

Everything seems to work fine accept the output Link. 
<apex:outputlink title="Opportunity Name" value="/{!opty.id}">{!opty.Name}</apex:outputlink>

The link is opening a new SFDC session in section of the VFpage rather than navigating to Opportunity. Opening a new salesforce session in the visualforce page section
Any suggestions?

Regards, 
Gaurav
I'm trying to add another recipient to an email button and can not seem to get it to work. Below is the Apex code for the current button, please let me know what I need to change to add a second recipient.

global class SendPurchaseOrderEmail {
    WebService static void sendEmail(String poId) {
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        
        String theTemplate = [SELECT Id FROM EmailTemplate WHERE DeveloperName = 'Purchase_Order_With_Items'].Id;
        User theUser = [SELECT Id FROM User WHERE Name = 'user name goes here'];

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        
        mail.setSaveAsActivity(false);
        mail.setTemplateId(theTemplate);
        mail.setWhatId(poId);
        mail.setTargetObjectId(theUser.Id);

        emails.add(mail);
        
        Messaging.sendEmail(emails);      
     
      }    
}
I am trying to write a trigger that fires when my custom object ‘Vehicles' is either updated or new recored is inserted.
If any of its 2 particular fields (In_service__c, Vehicle_designation__c) have been updated ,i want those records to be saved in a list.
And  i want to assign the value of  field (Group__c ) equal to the field (Vehicle_designation__c)
 My Code:  
Trigger TUpdate on Vehicle__c (before insert, before update) {
   set<String>  vehicleID = new Set<String>() ;
  for(Vehicle__c v: trigger.new){
    // if the fields are updated:
     Vehicle__c oldv = trigger.oldMap.get(v.Vehicle_ID__c);
      if ((v.In_service__c != oldv.In_service__c) || (v.Vehicle_designation__c != oldv.Vehicle_designation__c) )
      {  
       // field was updated,do something!
           v.Group__c = v.Channel_designation__c;
        }    
     // if new records are inserted:
      vehicleID.add(v.Vehicle_ID__c);
      v.Group__c = v.Channel_designation__c;
  }
There seems to be some problem with Line 6
if ((v.In_service__c != oldv.In_service__c) || (v.Vehicle_designation__c != oldv.Vehicle_designation__c) )
 when i run my test case it fails and if i insert a new record I get the error message
(Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger TruUpdate caused an unexpected exception, contact your administrator: TUpdate: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.TUpdate: line 6, column 1.)

My Unit test:
@IsTest
public with sharing class TFieldUpdate {
static testMethod void testupdates(){

// Create our records from scratch!
 Vehicle__c vc = newVehicle__v()
 vc.Serial_Number__c='1233333';
 vc.In_service__c ='yes';
 insert vc;
//update Vehicle Record:
 vc.In_service__c ='no';
 update vc;  
 }
}


 
Hi, 

I found this page

https://help.salesforce.com/apex/HTViewHelpDoc?id=siteforce_clickjacking_enable.htm&language=en_US

to disable the clickjack protection. But I don't know where can I find this settings in salesforce.

Can anybody help.

Thanks,
Sascha
I need to help on how to execute the schedule class from Developer console and also please review the code for any mistakes.

//Scheduler Class
global class Scheduler_DeleteoldCases implements Schedulable{
  global void execute(SchedulableContext SC) {
     DeleteoldCases gm = new  DeleteoldCases() ; 
  }}


global class DeleteoldCases{
    Public void DeleteoldCases(){
        List<Case> QueryCases = [SELECT Id FROM Case WHERE Case.CreatedDate < LAST_N_MONTHS:18 ORDER BY CreatedDate ASC  LIMIT 9000];
        If (QueryCases == null){return; }
        system.debug('********List of Cases********'+QueryCases);
        try{
            delete QueryCases;
        }catch(DmlException e) {
            System.debug('An unexpected error has occurred: ' + e.getMessage());
        }  }}




I found a code for sending email from apex. The problem is it have a part i do not want. If i remove below part it wont work. Any idea how to remove below part (div Id= "Remove Part"). Thanks 

VF Page 
<div Id= "Remove Part">
<apex:pageBlock title="Send an Email to Your {!account.name} Representatives">
    <p>Fill out the fields below to test how you might send an email to a user.</p><br />
        <apex:dataTable value="{!account.AccountTeamMembers}" var="contact" border="1">
            <apex:column ><apex:facet name="header">Name</apex:facet>{!contact.user.Name}</apex:column>
            <apex:column ><apex:facet name="header">Email</apex:facet>{!contact.user.Email}</apex:column>
        </apex:dataTable>
</div>
        <apex:commandButton value="Send Email" action="{!send}" /> 
</apex:pageBlock>

Extension 
public class gibco {
    
    public Product_Brief__c pb {get;set;}
    public User u {get;set;}
    
    private ApexPages.StandardController controller {get;set;}
    public boolean bUpdate {get;set;}
    public string loggedinUserId = UserInfo.getUserId();
    public User u2 = [Select ContactId From User where Id =: '005R0000001Y6h4'];
    
    public String ctId{
        get {
             ctId = u2.ContactId;
             return ctId;
            }
        set;
    }
         
    Contact ct = [SELECT AccountId, Name FROM Contact WHERE id=:ctId];
    Account acname = [SELECT Name FROM Account WHERE id=:ct.AccountId];
    public string getacct(){
        Account acct = [SELECT Name FROM Account WHERE id=:ct.AccountId];  
        return acct.Name;
        return null;
        }
         
    Opportunity opp = [SELECT Id FROM Opportunity WHERE AccountId=:ct.AccountId LIMIT 1];
    
 /* ********************* Email ************************* */
    public String subject { get; set; }
    public String body { get; set; }
    private Account account;

    public Account getAccount() {
    account = [select Name, (SELECT user.Name, user.email from AccountTeamMembers) 
                from Account where id = :ct.AccountId];
        return account;
    }

    public PageReference send() {
        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
         
        
    String addresses;
    if (account.AccountTeamMembers[0].user.Email != null)
    {
        addresses = account.AccountTeamMembers[0].user.Email;
        // Loop through the whole list of contacts and their emails
        for (Integer i = 1; i < account.AccountTeamMembers.size(); i++) 
        {
            if (account.AccountTeamMembers[i].user.Email != null)
            {
                addresses += ':' + account.AccountTeamMembers[i].user.Email;
            }
        }
    }

        String[] toAddresses = addresses.split(':', 0);

        // Sets the paramaters of the email
        email.setSubject( 'New Media/Buffer Product Brief from '  + ct.Name + ' at ' + acname.Name);
        email.setToAddresses( toAddresses );
        String htmlBody= 'Dear ' + ct.Name + ':<br/><br/>';
                htmlBody += 'This is a reminder that your review of ' + ct.Name + ' for the position of ' + 
                    ct.Name + ' has not been completed yet. Please complete this review as soon as possible.' +
                    '<br/><br/>Review Link: <a href=https://cs2.salesforce.com/' + ApexPages.currentPage().getParameters().get('id') + '>click here</a><br/><br/>Thank You,<br/>Recruiting Dept.';
                email.setHtmlBody(htmlBody);
    
        // Sends the email
        Messaging.SendEmailResult [] r = 
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Confirm,'The Product Breif has been submitted successfully. Thank you'));
        return null;
    }

 
How to escape the exception if there are no results from Soql Query and do I hit any Governer Limits by looking at the code??

global class DeleteoldCases{
    Public void DeleteoldCases(){
        List<Case> QueryCases = [SELECT Id FROM Case WHERE Case.CreatedDate < LAST_N_MONTHS:18 ORDER BY CreatedDate ASC  LIMIT 9000];
        If (QueryCases == null){return;}
        system.debug('********List of Cases********'+QueryCases);
        try{
            delete QueryCases;
        }catch(DmlException e) {
            System.debug('An unexpected error has occurred: ' + e.getMessage());
        }  
    }
}
In the challenge for the "Using Formula Fields" Trailhead module, I'm using the formula, TODAY()  -  LastModifiedDate, with the type set as Number (as specified in the challenge instructions, but I receive the following syntax  error: Error: Incorrect parameter type for operator '-'. Expected Number, Date, received DateTime.

I am a total admin n00b and would appreciate any feedback on the (probably obvious) element I'm missing here. Thanks!
I have a visual force page to display a list of locations. I used pagination and wrote class for it and working finely. but the test class is giving me an error : Constructor not defined: [listView].()
Can you please help. Below is my code:
This is my Constructor class.

public class listView{
    ApexPages.StandardSetController con; 
    
  //controller
  public listView(ApexPages.StandardSetController con)
    {        
     this.con = con;
      con.setPageSize(20);   
     }   

    //Instantiate the StandardSetController   
    //public ApexPages.StandardSetController con{get; set;}   
       
    //Boolean to check if there are more records after the present displaying records   
    public Boolean hasNext   
    {   
        get   
        {   
            return con.getHasNext();   
        }   
        set;   
    }   
    
    //Boolean to check if there are more records before the present displaying records   
    public Boolean hasPrevious   
    {   
        get   
        {   
            return con.getHasPrevious();   
        }   
        set;   
    }   
    
    //Page number of the current displaying records   
    public Integer pageNumber   
    {   
        get   
        {   
            return con.getPageNumber();   
        }   
        set;   
    }   
  
    //Returns the previous page of records   
    public void previous()   
    {   
        con.previous();   
    }   
    
    //Returns the next page of records   
    public void next()   
    {   
        con.next();   
    }   
}


This is my Test class:

@isTest(SeeAllData=true)  
public class listViewTest {  

        public static testMethod void testlistView() {  
        PageReference pageRef = Page.DataCenterLocation;  
        Test.setCurrentPage(pageRef);

        // Instantiate a new controller with all parameters in the page

        
        listView lv =new listView();
               
        lv.Next();
       
       
        lv.Previous();
       
        lv.con.getHasPrevious();
        lv.con.getHasNext();
        lv.con.getPageNumber();


     }

}

This is my VF page


<apex:page standardController="Data_Center_Location__c" recordsetVar="dclocation" extensions="listView">
<apex:form > <apex:pageBlock title="Data Center Locations">
<apex:pageBlockSection columns="4">
<apex:pageBlockTable style="width:200%" value="{!dclocation}" var="dclitem">
<apex:column style="width:250px" headerValue="Yardi Location Code">
<apex:outputField value="{!dclitem.Yardi_Location_Code__c}"/> </apex:column>
<apex:column headerValue="Opportunity Location Code">
<apex:outputField style="width:250px" value="{!dclitem.Opportunity_Location_Code__c}"/>
</apex:column>
<apex:column headerValue="Address">
<apex:outputField style="width:250px" value="{!dclitem.Address__c}"/>
</apex:column>
<apex:column headerValue="City">
<apex:outputField style="width:250px" value="{!dclitem.City__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:commandLink action="{!Previous}" value="Previous" rendered="{!HasPrevious}"/>&nbsp;&nbsp; <apex:commandLink action="{!Next}" value="Next" rendered="{!HasNext}"/> </apex:pageBlock> </apex:form> </apex:page>

 
  • July 23, 2015
  • Like
  • 0
Hi,
  i am working on force.com Developer addition ,my issuse is when i am trying to access reports and dashbords objects it showing error like

  You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, seeInsufficient Privileges Errors. 

Please any one give reslove issuse for this thanks you.
Hi, I have an app that needs to have a button next to Edit and Delete and Save that changes a field value of the record viewed to '11'. 

So far I have this: 
 
<apex:commandbutton value="----- Mark Complete-----" action="{!RPP_Tracker__c.Present_Dept_Number__c = 11}"  />
I know this won't work because it's not actual referencing any specific record, simply the custom object field, but how do I change this to get the custom button to grab the existing record that is displayed on the page on which is presently being viewed?

Seems like it should be easy.
 
I created a VF page with javascript to set a date field as disabled when a checkbox is unchecked.  I then wanted to function to also execute onload so the date field would be disabled if the checkbox was unchecked or enabled when the checkbox was checked.  

I noticed in the window.onload event accessing $component.xxx returned null.  If I move a field outside the apex:form tags, I can get the $component.xxx ID as expected.

I am able to pass the VF $component.id to the javascript routine but how do I get the form field ID during the onload event?  I must be missing something basic at this point.  Any assistance is appreciated.

*** Here is the VF code. ***

<apex:page standardController="OpportunityLineItem" showHeader="true" sidebar="true">
    <apex:form id="myForm" >

        <script type="text/javascript">
            function ToggleInput(theId,overrideId)
            {
                var e = document.getElementById(theId);
                var a = document.getElementById(overrideId).checked;
               
                if(e != null)
                {
                    if(a === true)
                    {
                    e.disabled = false;
                    } else
                    {
                    //e.disabled = (e.disabled ? false : "disabled");
                    e.disabled = true;
                    }
                }
            }
           
            //window.onload = function () {document.getElementById('{!$Component.liItemShipDate}').disabled= "disabled"; }
            window.onload = function()
            {
                alert(document.getElementById('{!$Component.liItemShipDate}'));
            }
 
        </script>

        <apex:sectionHeader id="pgSection" title="Opportunity Product Edit" subtitle="{!OpportunityLineItem.Name}" />
        <apex:pageBlock id="pgBlock" mode="edit" title="Opportunity Product Edit">

            <apex:pageBlockButtons location="both">
                <apex:commandButton value="Save" action="{!Save}"/>
                <apex:commandButton value="Cancel" action="{!Cancel}"/>
            </apex:pageBlockButtons>
        <apex:pageBlockSection id="pgBlockSectionAcctInfo" title="" collapsible="false" columns="2" >
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Opportunity</apex:outputLabel>
                <apex:outputField id="actOwner" value="{!OpportunityLineItem.OpportunityId}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Machine #</apex:outputLabel>
                <apex:inputField id="actRating" value="{!OpportunityLineItem.Machine__c}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Product</apex:outputLabel>
                <apex:outputField id="actOwner" value="{!OpportunityLineItem.Product2Id}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Quantity</apex:outputLabel>
                <apex:inputField id="actRating" value="{!OpportunityLineItem.Quantity}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Product Family</apex:outputLabel>
                <apex:inputField id="actOwner" value="{!OpportunityLineItem.Product_Family__c}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Sales Price</apex:outputLabel>
                <apex:inputField id="actRating" value="{!OpportunityLineItem.UnitPrice}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Product Type</apex:outputLabel>
                <apex:outputField id="actOwner" value="{!OpportunityLineItem.Product_TypeTEXT__c}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Discount Percentage</apex:outputLabel>
                <apex:inputField id="actRating" value="{!OpportunityLineItem.Discount}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >List Price</apex:outputLabel>
                <apex:outputField id="actOwner" value="{!OpportunityLineItem.ListPrice}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Total Price</apex:outputLabel>
                <apex:outputField id="actRating" value="{!OpportunityLineItem.TotalPrice}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Serial Number</apex:outputLabel>
                <apex:inputField id="actOwner" value="{!OpportunityLineItem.Serial_Number__c}" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Asset</apex:outputLabel>
                <apex:inputField id="actOwner" value="{!OpportunityLineItem.Asset__c}" />
            </apex:pageBlockSectionItem>

        <!--
        <apex:inputCheckbox onclick="ToggleInput('{!$Component.textInput}');" value="{!OpportunityLineItem.Override_Opp_Ship_Date__c}"/>
        <apex:inputField id="textInput" value="{!OpportunityLineItem.Ship_Date__c}"/>
        -->
       
                <apex:inputCheckbox id="liItemOverride" onclick="ToggleInput('{!$Component.liItemShipDate}','{!$Component.liItemOverride}');" value="{!OpportunityLineItem.Override_Opp_Ship_Date__c}" />
                <apex:inputField id="liItemShipDate" value="{!OpportunityLineItem.Ship_Date__c}" />
       
          
        </apex:pageBlockSection>
          
        <apex:pageBlockSection id="pgBlockSectionAdditionalInformation" title="Description" collapsible="false" columns="2">
            <!--ANY CUSTOM FIELDS / ADDITIONAL INFORMATION CAN GO HERE-->
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Line Description</apex:outputLabel>
                <apex:inputField id="actRating" value="{!OpportunityLineItem.Description}" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form> 
</apex:page>
 
@RemoteAction
    public static List<Lawson_Division__c> getData(String sObjVal,String labelField,String valueField,String param){
        param = String.escapeSingleQuotes(param);
        Id usrId = UserInfo.getUserid();
        String buvalues = [select Muni_Business_Unit_ID__c from user where id=:usrId].Muni_Business_Unit_ID__c;
        if(buValues == null){
           return null; 
        }
        if(buValues != null &&  buValues.EqualsignoreCase('All')){
           return Database.query('SELECT '+valueField+','+labelField+',Business_Unit_Number__c,Area__c,Region__c,BU_Description__c FROM '+sObjVal+' WHERE '+labelField+' LIKE \''+param+'%\''); 
        }
        List<String> buIds = buValues.split(',');
        return Database.query('SELECT '+valueField+','+labelField+',Business_Unit_Number__c,Area__c,Region__c,BU_Description__c FROM '+sObjVal+' WHERE '+labelField+' LIKE \''+param+'%\' and business_unit_number__c in :buIds');
    }
   
Hello !
I'm trying to create a dropdown based on a soql query : 
public without sharing class ExtranetV2_TransfertsCommController2 {
//some code

public List<Commande__c> creneauHoraire = new List<Commande__c>();
    public List<SelectOption> horaire {
    	get{
    		creneauHoraire = [select Cr_neau_horaire_enl_vement__c from Commande__c];
    		horaire = new List<SelectOption>();
    		for(Commande__c ch : creneauHoraire){
    			horaire.add(new SelectOption(ch.Cr_neau_horaire_enl_vement__c));
    		}
    		return horaire;
    	}
    	set;
    }

public ExtranetV2_TransfertsCommController2(){
//some code

}

}
here i call it in my visualforce page :
 
<apex:pageBlock>
                                    <apex:form>
                                        <apex:selectList size="1">
                                            <label>Créneau horaire </label><apex:selectOptions value="{!horaire}"></apex:selectOptions>
                                        </apex:selectList>
                                    </apex:form>
                                    </apex:pageBlock>

my problem is that i get an error in my apex class : Constructor not defined: [System.SelectOption].<Constructor>(String)
and i don't understand how fix that error and make my dropdown working...

Thank you for your help ;)
  • July 21, 2015
  • Like
  • 0
Hi, I am trying to upload tasks in Salesforce and have the following fields:
Contact ID - mapped with WhoId - format ID (003D000001sEIrH)
Assigned to - mapped with AssignedtoID - format ID (005D0000005QjgV)
Subject - mapped with Subject - free field so text
Type - mapped with Type - picklist so put the exact picklist word
Related to Campaign - mapped with RelatedtoCampaign - format ID (not sure that's the right way)
Due Date - mapped with Duedate - format dd/mm/yyyy

What did I do wrong? Should the related to campaign be text instead of ID? Should I add the account ID (please no)?

Thanks for you help,

Bénédicte

 
Hi there,

I have a custom object, and created a Visualforce page to make it easy for people to add new records for this object.  After submitting the form, the user is taken to the page for that new object.  What I'd like to do is take them to a new, empty form so they can quickly and easily enter an additional record.  

I tried to use the "oncomplete" attribute on my command button, but it's not working.  What am I missing?

Thanks in advance! 

Here's the code:
 
<!-- Typeahead form plus saving / updating -->
<apex:page standardController="Book__c" showHeader="false" sidebar="False" title="Receive a Book">

   <script type="text/javascript">
   function reloadme(){
       window.location.href="https://c.na17.visual.force.com/apex/EBCBP_Receive_Books?sfdc.tabName=01ro0000000Wc30";
   }
   </script>
   
   <div class="messages"> 
    <apex:messages />
   </div>
   
    <apex:form target="_self">
    
    <div class="entry-form">
        <img src="http://eastbaychildrensbookproject.org/new/wp-content/uploads/2012/07/ebcbp_headergraphic.png"/>
        <h1>Welcome to the East Bay Children's Book Project</h1>
        <p>If you've received books from us before, please proceed below.  Otherwise, go <a href="http://www.eastbaychildrensbookproject.org/kiosk/new-client/">Here</a></p>
        <h3>Your Name:</h3>
        <c:Typeahead secondaryField="Email" placeholder="Enter name or email" minSearchLength="3"
            destinationForSelectedId="contactId"/> 

        <h3>Organization:</h3>
        <c:Typeahead searchBoxId="acctSearchBox" object="Account" primaryField="Name" secondaryField="BillingCity" 
                searchScope="NAME" placeholder="Enter organization name..." minSearchLength="3" 
                destinationForSelectedId="accountId" destinationForSelectedValue="accountName" stealFocus="false" />  

        <h3>Books Received</h3>
        <apex:inputField value="{!Book__c.Number_Received__c}"/>

        <h3>Date Received</h3>
        <apex:inputField value="{!Book__c.DateReceived__c}" />

        <apex:inputHidden value="{!Book__c.Organization__c}" id="accountId"/>
        <apex:inputHidden value="{!Book__c.Person__c}" id="contactId"/>

        
        <input type="hidden" name="accountName" id="accountName" />     

        <apex:commandButton action="{!save}" value="Save" oncomplete="reloadme()"/>


    </div>
    </apex:form>

</apex:page>

 
Hi,

I'm writing a test class for a trigger and getting 'Non-void method might not return a value or might have statement after a return statement.'.

Should be a simple thing to fix but I can't see it I'm afraid.  Any advice?

The error is on the line
update taskToUpdate;

Here is the full class:
 
@isTest
                                
public class TestTaskBeyondContractEndDate {

    public static Task createTestTask() { 

        Account a = createAccount();

        Contract con = createContract(a);

        Vist_Detail__c conwk = createContractWork(a, con);

        Task t = createTask(conwk, '2015-07-31');  // Create task with date before Contract end date  

        Task taskToUpdate = [SELECT Id, ActivityDate FROM Task WHERE Id=:t.Id];
        taskToUpdate.ActivityDate = Date.valueOf('2015-12-08');
        update taskToUpdate;
        
   }            
    
// Helper methods

    private static Account createAccount() {
		RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='Office' Limit 1];
        Account a = new Account(
            Name='Mike',
            RecordTypeId=rt.Id,
            Region__c='National',
            Status__c='Active',
        	Type='Prospect',
        	CurrencyIsoCode='GBP',
        	Phone='1',
        	Division__c='Water');
        insert a;
        return a;
    }
    
   private static Contract createContract(Account a) {        
		RecordType rt = [select id,Name from RecordType where SobjectType='Contract' and Name='Maintenance Contract' Limit 1];
        Contract con = new Contract(                
            RecordTypeId=rt.Id,
        	AccountId=a.Id,
        	Status='Active',
        	Current_State__c='New',
        	CurrencyIsoCode='GBP',
        	G_Division__c='Water',
            endDate=Date.valueOf('2015-12-31'), // yyyy-mm-dd
        	Contract_Type__c='Maintenance Contract');      
        insert con;
        return con;
    } 

    private static Vist_Detail__c createContractWork(Account a, Contract con) {        
        Vist_Detail__c conwk = new Vist_Detail__c(                
            RecordTypeId='01220000000UVOh',
        	Account__c=a.Id,
            Contract__c=con.ID,
            Service_Owner__c='005w0000003Y7Nl',
        	CurrencyIsoCode='GBP',
        	Division__c='Water',
            Start_Date__c=Date.valueOf('2015-05-08'),
        	Service_Summary__c='Chemistry',
        	Technician_Comments__c='abcd');      
        insert conwk;
        return conwk;
    } 

        private static Task createTask(Vist_Detail__c conwk, string Tdate) {
        Task t = new Task(
            RecordTypeId='01220000000UUkC',
            WhatId=conwk.Id,
            Subject='abcd',
            ActivityDate=Date.valueOf('2015-05-08'),
        	CurrencyIsoCode='GBP',
            Status='Open',
            Activity_Type__c='Service Visit',
            Description='abcd',
            Priority='Normal',
        	Division__c='Water');
        insert t;
        return t;
    }
    
//    private static void updateTask(Task theTask, string theDate){
//        Task taskToUpdate = [SELECT Id, ActivityDate FROM Task WHERE Id=:theTask.Id];
//        taskToUpdate.ActivityDate = Date.valueOf(theDate);
//        update taskToUpdate;
//    }

}



Many Thanks,
Mike.
I created a custom button for the "leads" page so that our sales team can have a one-click follow-up created for various lengths of time.  The below button is for a 1 week follow-up and works just fine on the leads page:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var myTask = new sforce.SObject("Task"); 
myTask.WhoId = "{!Lead.Id}"; 
myTask.Subject = "{!Lead.LastName} 1 Month Follow-up"; 
myTask.status = "Not Started"
myTask.ActivityDate = "{!SUBSTITUTE(TEXT(TODAY()+30), "/", "-")}"
sforce.connection.create([myTask]); 
window.location.reload();

I would like to do something similar on our Opportunity and Case pages. I would expect that I could just swap out Lead.ID for Opportunity.ID and Lead.Lastname for the Opportunity.Subject and it should work.  Unfortunatly, I'm just getting a page refresh and no task.  Please help!
Through apex call out i am getting following response from .Net Webservice  . How I will render/create as attachment  in salesforce as well formed PDF file based on below response.

JVBERi0xLjQNCiVET0MxIFJlc291cmNlR1VJRD01ODU4REFCNUQzQUY0RjY2QjU2Mzc5Mzg5NjI0NDYxMg0KJeLj5A0KMSAwIG9iag0KPDwgL1R5cGUgL1BhZ2UNCi9QYXJlbnQgMyAwIFINCi9SZXNvdXJjZXMgNCAw........

Please help . 
Hi,

How can i deploy the profiles alone from sandbox to the production?  

Thanks,
Ramshah
I wrote a search functionality,i want to show a message "no records found" when there are no records on the entered letter
through a javascript,i got through pagemessage,but i want  through javascript.I tied but its not working,can u please help me regarding this.

<apex:page controller="searchwithactionstatuscontroller" id="one">
<script>
function js(value){
var inputValue = document.getElementById(search).value;
alert(inputValue );
if(inputValue==null||inputValue==''){
alert('no records found');
}
else{
actionFunName();
}
}
</script>

<apex:form id="two">
       <apex:actionFunction name="actionFunName" action="{!searchpositions}"  reRender="two" />
<apex:outputLabel for="search" value="SEARCH :" style="font-weight:bold"   />
<apex:inputText value="{!search}"  id="search" onkeyup="js(value)"   />
<!--<apex:actionSupport event="onkeyup" action="{!searchpositions}" reRender="one:two:block1"/>-->
<apex:outputText id="error" value="{!error}" />
<apex:pageBlock rendered="{!blockOnLoad}" id="block1">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!poslis}" var="pl"   >
<apex:column value="{!pl.name}"/>
</apex:pageBlockTable> 
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock rendered="{!blockOnEnter}" > 
<apex:pageBlockSection id="d">
<apex:pageBlockTable value="{!pos}" var="p"  >
<apex:column value="{!p.name}"/>
<apex:column >
<apex:inputCheckbox value="{!p.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
 </apex:pageBlock> 
</apex:form>
</apex:page>


controller
---------------

public with sharing class searchwithactionstatuscontroller {

    public String error { get; set; }
public boolean blockOnLoad{set;get;}
public boolean blockOnEnter{set;get;}


    public PageReference searchpositions() {
        string holdString ='SELECT name from Position__c  where name like  \'%'+search+'%\' ORDER BY name asc';
        pos=Database.query(holdString);
       blockOnLoad=false;
        blockOnEnter=true; 
        return null;
    }
public String search { get; set; }
public List<position__c> poslis{set;get;}
public List<position__c> pos{set;get;}

public searchwithactionstatuscontroller() {
poslis=[select Name from position__c];
blockOnLoad=true;
blockOnEnter=false;
}
}
  • May 02, 2016
  • Like
  • 0
I've detail page button (content source: Javascript), on Account detail page. Upon click of this button, data on Account will be sent to an inhouse application. Requirement is to show a progress bar upon the button click showing the progress of the data sent.

To summarize-

I'd like to know how can I show progress bar (animated image) with the statuses of integration completed.

For example:

Integration1 in progress..
Integration1 completed..

Integration2 in progress
Integration2 completed.

Any pointers on how to implement this is much appreciated..
Want my soql query to find records with specific record types. OR stement returning error: expecting right square bracket, found 'OR'

Do I need to create additional soql queries to first obtain record types, then reference in existig soql?

Thanks!

Existing soql
List<AggregateResult> results = [SELECT Account__c, 
                                         SUM(X2_1_a_Total_of_jobs_Year_0__c) mysum0,
                                         FROM Form__c 
                                         WHERE Account__c IN:accountIds
                                         AND (RecordType.DeveloperName ='Baseline Report')
                                         OR  (RecordType.DeveloperName ='Annual Report')
                                         GROUP BY Account__c]  ;

 
Error: Could not resolve the entity from <apex:inputField> value binding '{!a.Account.Id}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.
code-<apex:page controller="wizard_class">
  <apex:form >
  <apex:pageblock title="Enter Account Details">
  <apex:pageblockButtons >
  <apex:commandButton value="Next Page" action="{!gotopage2}"/>
  </apex:pageblockButtons>
  <apex:pageblockSection >
    <apex:inputField value="{!a.Account.Id}" />
    <apex:inputfield value="{!a.Name}" />
  </apex:pageblockSection>
  </apex:pageblock>
  </apex:form>
</apex:page>
 
I  am working on a vf page that I would like and have a related list that I would like to only show records with a specific shipment type.  Basically I would liek the second pageblocktable to only show records where the shimpment_Type__c ="Drop Ship". 

<apex:page standardController="SFDC_Project__c">
    <style type="text/css">
        #head {font-size:25pt;}
    </style>
    <center>
        <h1 id="head">
        Installation Shipping Information
        </h1>
    </center>
    <apex:pageBlock title="Installation Details">
    <apex:pageBlockSection>
        <apex:outputField value="{! SFDC_Project__c.Name }"/>
        <apex:outputField value="{! SFDC_Project__c.Account__c }"/>
        <apex:outputField value="{! SFDC_Project__c.SFDC_Project_Name__c }"/>
        <apex:outputField value="{! SFDC_Project__c.SFDC_Project_Manager__c}"/>
    </apex:pageBlockSection>
        <h1 id="t1head">
            Hardware Shipping Information
        </h1>
    <apex:pageBlockTable value="{!SFDC_Project__c.Hardware_Information__r}" var="hardware">
      <apex:column value="{!hardware.Shipment_Type__c}"/>
      <apex:column value="{!hardware.Ship_Date__c}"/>
      <apex:column value="{!hardware.Item_Master__c}"/>
      <apex:column value="{!hardware.Sales_Order__c}"/>
      <apex:column value="{!hardware.Sales_Order_Line_Item__c}"/>
      <apex:column value="{!hardware.Name}"/>
      <apex:column value="{!hardware.Quantity_Ordered__c}"/>
      <apex:column value="{!hardware.Quantity_Shipped__c}"/>
      <apex:column value="{!hardware.Carrier_for_Shipment__c}"/>
      <apex:column value="{!hardware.Tracking_Number__c}"/>
      <apex:column value="{!hardware.Ship_to_Address__c}"/>
   </apex:pageBlockTable>
        <h1 id="t2head" class="thead">
            Drop Shipped Serial Numbers
        </h1>
   <apex:pageBlockTable id="dropShipSN" value="{!SFDC_Project__c.Hardware_Information__r}" var="hardware">
      <apex:column value="{!hardware.Item_Master__c}"/>
      <apex:column value="{!hardware.Serial_Number_Shipped_from_Denver_Whs__c}"/>
      <apex:column value="{!hardware.Ship_Date__c}"/>
      <apex:column value="{!hardware.Ship_to_Address__c}"/>
       <apex:column value="{!hardware.Shipment_Type__c}"/>
   </apex:pageBlockTable>
</apex:pageBlock>
    

</apex:page>
 
I am successfully able to include visualforce page on Account layout. This page shows list of opportunities. Apex Code:
<apex:page standardController="Account" extensions="OpportunityController" sidebar="false" showheader="false">
<apex:pageBlock >
 <apex:pageBlockSection columns="1">
     <apex:pageBlockTable value="{!AccountOpportunity}" var="opty">
     <apex:column headerValue="Opportunity Name" > 
     <apex:outputlink title="Opportunity Name" value="/{!opty.id}">{!opty.Name}</apex:outputlink>
     </apex:column>
     <apex:column value="{!opty.Amount}"/>
     <apex:column value="{!opty.StageName}"/>
     <apex:column value="{!opty.CloseDate}"/>
     </apex:PageblockTable>
     </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

Everything seems to work fine accept the output Link. 
<apex:outputlink title="Opportunity Name" value="/{!opty.id}">{!opty.Name}</apex:outputlink>

The link is opening a new SFDC session in section of the VFpage rather than navigating to Opportunity. Opening a new salesforce session in the visualforce page section
Any suggestions?

Regards, 
Gaurav
I'm trying to add another recipient to an email button and can not seem to get it to work. Below is the Apex code for the current button, please let me know what I need to change to add a second recipient.

global class SendPurchaseOrderEmail {
    WebService static void sendEmail(String poId) {
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        
        String theTemplate = [SELECT Id FROM EmailTemplate WHERE DeveloperName = 'Purchase_Order_With_Items'].Id;
        User theUser = [SELECT Id FROM User WHERE Name = 'user name goes here'];

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        
        mail.setSaveAsActivity(false);
        mail.setTemplateId(theTemplate);
        mail.setWhatId(poId);
        mail.setTargetObjectId(theUser.Id);

        emails.add(mail);
        
        Messaging.sendEmail(emails);      
     
      }    
}
Hi Guys,
Can you please help me with a Test Class? I am not a developer and trying to write a Test class for a Trigger I have but getting error. 
Trigger:

trigger ServiceLineBillingFrequency on kugo2p__SalesOrder__c (after update) {

Set<Id> OrderID = new Set<Id>();

 for(kugo2p__SalesOrder__c so : Trigger.new){
 OrderID.add(so.id);
}

List<kugo2p__SalesOrderServiceLine__c> SLUpdate = [select id, kugo2p__SalesOrder__c from kugo2p__SalesOrderServiceLine__c where kugo2p__SalesOrder__c in :OrderID];
 for(kugo2p__SalesOrder__c so : trigger.new){
 for (kugo2p__SalesOrderServiceLine__c osl : SLUpdate) {
 If(so.Order_Billing_Frequency__c != Null){

        osl.Billing_Frequency__c = so.Order_Billing_Frequency__c;
 }
}
}
update SLUpdate;
  }

Test Class:

@isTest
 public class BillingFrequency {
 static testMethod void InsertOrder(){
 
 Account acc = new Account();
 acc.Name = 'ABC';
 insert acc;
 
 kugo2p__SalesOrder__c SO = new kugo2p__SalesOrder__c();
 Account AccID = [Select id from Account where Name = 'ABC'];
 SO.kugo2p__Account__c = AccID.id;
 SO.CurrencyIsoCode = 'USD';
 SO.Order_Form_Type__c = 'New Order';
 SO.Renewal_Term_Exceptions__c = 'None';
 SO.Purchase_Order_Required__c = 'NO';
 SO.Renewal_Term_Notification__c = '30';
 SO.Order_Billing_Frequency__c = 'Monthly';
 insert SO;
 
 kugo2p__SalesOrderServiceLine__c SL = new kugo2p__SalesOrderServiceLine__c();
 SO =[Select id from kugo2p__SalesOrder__c where id = :SO.id];
 Sl.kugo2p__SalesOrder__c = SO.id;
 SL.kugo2p__Service__c = 'a2B40000000Lk85';
 SL.kugo2p__Quantity__c = 2;
 SL.CurrencyIsoCode = 'USD';
 date mydate = date.parse('08/03/2015');
 SL.kugo2p__DateServiceStart__c = mydate;
 insert SL;
 
 SO.kugo2p__RecordStatus__c = 'approved';
 update SO;
 }
 }

Error Message:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, kugo2p.SalesOrderBeforeInsert: execution of BeforeInsert
caused by: System.NullPointerException: Attempt to de-reference a null object
(kugo2p)
Stack Trace Class.BillingFrequency.InsertOrder: line 18, column 1
  • August 03, 2015
  • Like
  • 0
I'm trying to find the properly way to display a lookup field on a Visualforce for a custom object/field. All of the examples I keep seeing are for standard fields (AccountID ; UserID). 

<apex:inputfield id="Vendor_Classification__c" value="{!Vendor_Classification__c.Vendor__c}" required="true"/>

What is the proper syntax to display the Vendor__c lookup field as a link ?
  • August 03, 2015
  • Like
  • 0
I have a trigger that, among other things, is creating some events on new opportunities. Here's that section of the trigger:
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime,subject='Account Management Follow-Up', EndDateTime=myDateTime, IsAllDayEvent=true, OwnerId = 'cwilli'));
                        eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(2),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(2), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
                        eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(4),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(4), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
                        eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(6),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(6), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
                        eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(8),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(8), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
                        eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
                        eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Renewal',EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));
                        eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(9),subject='Sales Contract Follow-Up',EndDateTime=myDateTime.addMonths(9), IsAllDayEvent=true/*, OwnerId = 'cwilli'*/));

As you can see, I was trying to use the OwnerId field with a specific user's alias, but that was essentially destroying my trigger. I just need to know the correct syntax for specifying the assigned to field when I create these events. Thanks.
I'm new at this thanks for any advice...
I have at account level, fields I need to be dependent and dynamic.  First field picklist choice will determine population of second field picklist.  After second picklist choice, defined fields will appear (based on choices from field 1 and 2).  Many fields are common.  Just looking for some basic guidance.  Thank you.
I am trying to write a trigger that fires when my custom object ‘Vehicles' is either updated or new recored is inserted.
If any of its 2 particular fields (In_service__c, Vehicle_designation__c) have been updated ,i want those records to be saved in a list.
And  i want to assign the value of  field (Group__c ) equal to the field (Vehicle_designation__c)
 My Code:  
Trigger TUpdate on Vehicle__c (before insert, before update) {
   set<String>  vehicleID = new Set<String>() ;
  for(Vehicle__c v: trigger.new){
    // if the fields are updated:
     Vehicle__c oldv = trigger.oldMap.get(v.Vehicle_ID__c);
      if ((v.In_service__c != oldv.In_service__c) || (v.Vehicle_designation__c != oldv.Vehicle_designation__c) )
      {  
       // field was updated,do something!
           v.Group__c = v.Channel_designation__c;
        }    
     // if new records are inserted:
      vehicleID.add(v.Vehicle_ID__c);
      v.Group__c = v.Channel_designation__c;
  }
There seems to be some problem with Line 6
if ((v.In_service__c != oldv.In_service__c) || (v.Vehicle_designation__c != oldv.Vehicle_designation__c) )
 when i run my test case it fails and if i insert a new record I get the error message
(Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger TruUpdate caused an unexpected exception, contact your administrator: TUpdate: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.TUpdate: line 6, column 1.)

My Unit test:
@IsTest
public with sharing class TFieldUpdate {
static testMethod void testupdates(){

// Create our records from scratch!
 Vehicle__c vc = newVehicle__v()
 vc.Serial_Number__c='1233333';
 vc.In_service__c ='yes';
 insert vc;
//update Vehicle Record:
 vc.In_service__c ='no';
 update vc;  
 }
}


 
I am working within a dev org and was told I cannot have this "go live" automatically with littel explanation as to the best path to move the work I have done into a production account.  Can anyone point me in the right direction?  Appreciate your help!
I make and erase the object
I did the formula again
I take all the security settings that has on the object Case
 
Our developer reported sudden mixed DML errors in code that has worked for months with no changes.  Any ideas why this happened between releases?
  • July 24, 2015
  • Like
  • 1
I have environment hub enabled for my org.
But environment hub tab is missing from the tab list.
My profile is set to system admin...
Any info on this would be helpful !!! Thank you :)
Hi 
I have requirement  i need to display  in the table with contact count based on customer status value
on contact histroy
how can i write the soql for contact histroy
In dot net where 
select count()  name  as *assigned name from contact 
'lly in salesforce how can it is  acheivable 

Advance thanks
I have a trigger that should send an email to a specific email address if the task subject is troubleshooting and it is created by a specific user. But it doesnt work. any help would be greatly appreciated as I can not figure out this issue . The code is below.

 
trigger  Trigger_SendPartsTechEmail on Task (before update) {
   List<Messaging.SingleEmailMessage> emailList=new List<Messaging.SingleEmailMessage>();
   Map<Id, User> userMap = new Map<Id,User>([SELECT id FROM User WHERE Username IN('bpoliquin@cybexintl.com.cybextest','tghetti@cybexintl.com') AND isActive=True]);
    for(Task tsk : Trigger.New){
        if(tsk.Subject=='Troubleshooting' && userMap.keySet().contains(tsk.createdById) ){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddresses = new String[] {'bpoliqui@aol.com'};
            mail.setToAddresses(toAddresses); // Set the TO addresses
            mail.setSubject('A task owned by you has been updated'); // Set the subject
                String template = 'Hello {tsk.First_Name__c}, \nYour task has been modified. Here are the details - \n\n';
                template+= 'Subject - {tsk.Subject}\n';
                template+= 'Comments - {tsk.Activity_Comment__c}\n';
             mail.setPlainTextBody (template);
             emailList.add(mail);
        }
    }
    Messaging.SendEmail(emailList);
}

 
  • July 13, 2015
  • Like
  • 1
Hi Guys,
  1. Until the Spring 15 release, Maps and Sets are Unordered Collections. So the returned order will be random.
  2. But beginning from Summer 15 release onwards, Maps and Set order is predictable. The order will be same that what you put from the beginning to end.
Example:
Map<String, String> orderedMap = new Map<String, String>();
orderedMap.put('Good', 'This is so good');
orderedMap.put('Bad', 'This is so bad');
System.debug(orderedMap);

If you run the above code snippet in Developer console you will get the returned order as below,

Until Spring 15 Release:

{Bad=This is so bad, Good=This is so good}

From Summer 15 Release:

{Good=This is so good, Bad=This is so bad}

This changes is not the API level, this is Schema level change. If anyone relying on the Map or Set order in your codes, change it as soon. 

Thanks.