• Laxman Rao
  • SMARTIE
  • 930 Points
  • Member since 2012

  • Chatter
    Feed
  • 35
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 165
    Replies

Hi folks,

 

I have a number of Triggers that, upon creation of a custom record, automatically create an associated custom record. The Triggers themselves fire fine, but I can only get about 70% code coverage in my test classes. If anyone could help me with the form one of the test classes should take, I'm sure I'll be able to write the rest for the other Triggers. Here's an example of the kind of Trigger I mean:

 

trigger AutoProject on Procurement__c (before insert) {
    map< id, Milestone1_Project__c > proj = new map< id, Milestone1_Project__c >( );
    
    for( Procurement__c proc : trigger.new ) {
       proj.put( proc.id,
            new Milestone1_Project__c(
                  Name = proc.Name,
                  Submission_Deadline__c = proc.Submission_Deadline__c)
            );
    
    insert proj.values();
    proc.Bid_Planning_Timeline__c = proj.get(proc.id).id;    
    }        
    
}

 Any help very greatly appreciated.

 

Many thanks,

Lee

Hi ,

 

How to change standarad application logo .............

 

like sales application , call center  application , marketing application..............

 

please help me ...........

  • October 18, 2012
  • Like
  • 0

Hii 

i am using this list

List<Service__c> srList= [select id, Name, Customer__c,Days_Collection__c,Status__c, 
Service_Start_Date__c,s.Customer__r.Grand_Parent_Account__c
from Service__c s where Status__c = 'Active' AND Days_Collection__c!=null AND Customer__c!=null];


map<id,Decimal> mapgrandParentsCounts = new map<id,Decimal>();
for(Service__c sr:srList)
{
if(mapgrandParentsCounts.containskey(sr.Customer__r.Grand_Parent_Account__c) && sr.Name!=null) 
{
Decimal tCount = mapgrandParentsCounts.get(sr.Customer__r.Grand_Parent_Account__c);
tCount = tCount + finalCount;
mapgrandParentsCounts.put(sr.Customer__r.Grand_Parent_Account__c,tCount);
}
else
{
mapgrandParentsCounts.put(sr.Customer__r.Grand_Parent_Account__c,finalCount);
}
}

for(id gpAcc : mapgrandParentsCounts.keyset()) {
//here i want Name, city and address of this id
any idea
}

  • October 18, 2012
  • Like
  • 0

Hii 

i am using this list

List<Service__c> srList= [select id, Name, Customer__c,Days_Collection__c,Status__c,
Service_Start_Date__c,s.Customer__r.Grand_Parent_Account__c
from Service__c s where Status__c = 'Active' AND Days_Collection__c!=null AND Customer__c!=null];


map<id,Decimal> mapgrandParentsCounts = new map<id,Decimal>();
for(Service__c sr:srList)
{
if(mapgrandParentsCounts.containskey(sr.Customer__r.Grand_Parent_Account__c) && sr.Name!=null)
{
Decimal tCount = mapgrandParentsCounts.get(sr.Customer__r.Grand_Parent_Account__c);
tCount = tCount + finalCount;
mapgrandParentsCounts.put(sr.Customer__r.Grand_Parent_Account__c,tCount);
}
else
{
mapgrandParentsCounts.put(sr.Customer__r.Grand_Parent_Account__c,finalCount);
}
}

for(id gpAcc : mapgrandParentsCounts.keyset()) {
//here i want Name, city and address of this id
any idea
}

  • October 18, 2012
  • Like
  • 0

hi folks,

 

I got one scenario. I have taken Two <apex:inputText />. When i am enter into textbox1 that value will be automatically populate in textbox2.

 

 

Can you please help me.....

 

thanks for helping....

I have a list of options that is rather large.  30 items or so.  I want it to display 5 or 6 of them and have the rest be available through a scroll bar.  I am using <apex:selectoptions> to populate the values.  It displays a large list.  Any idea how to make it scrollable? 

Hi,

I create trigger on Event Object and this will do the following: If user try to create new event on the related list on opportunity record then If user select anything on Primary focus(picklist) field in event while create new event then after user save the record then it will translate that picklist selected option to stage field in opportunity record.

For example: if user select primary focus = phone then opportuntiy stage hould be update with phone.I have different recprd type on event and opportunities and i want this trigger to be work on selected record types.

here is my trigger but it working but not updating the opportunity stage with what i select while creating event.

please help me figuring this out.

thanks

trigger eventafter on Event (after update) {
List<Opportunity> opps = new List<Opportunity>{};
 
for (Event  t : trigger.new)
{
 
// if the event is related to an Opportunity and the Stage has changed
if (t.Primary_Focus__c != null) {
      List<opportunity> o = [Select Id, StageName From Opportunity Where Id = :t.WhatId];
      if (o.size() >0 ) {
        o[0].StageName = t.Primary_Focus__c;
      }
      opps.add(o[0]);
   }
 
if(opps != null && !opps.isEmpty()){
Database.update(opps);
}
}
}

After the method call, I am setting the flag value to true, but on the page it is always false. Can someone please look into this and let me know if i am m issing something.

 

<apex:page standardController="Opportunity" extensions="testcontroller">
<script type="text/javascript">
function testclick(Value){
testcheck(Value);
alert({!flag});
}
</script>
<apex:form >
<apex:actionFunction action="{!phaseCheck}" name="testcheck" reRender="">
<apex:param assignTo="{!pValue}" value="" name="someName"/>
</apex:actionFunction>
<apex:pageBlock >

<apex:inputCheckbox title="Test" id="chkbox" onclick="testclick('Test')"/>
<apex:outputLabel id="olabel" for="chkbox">Test</apex:outputLabel>
</apex:pageBlock>

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

 

public class testcontroller{

public testcontroller(ApexPages.StandardController controller) {

}

public Static String pValue{get;set;}
public Static boolean flag{get;set;}

public static void phaseCheck(){
system.debug('Test --->' + pValue);
flag = true;
system.debug('flag --->' + flag);

}
}

I am trying to call the method and pass the parameter, I can see that the method is getting invoked but  the value is not getting passed to the controller. Can someone please look at this and let me know if I am missing something.

 

VF Page:

<apex:page standardController="Opportunity" extensions="testcontroller">
<script type="text/javascript">
function testclick(Value){
testcheck(Value);
}
</script>
<apex:form >
<apex:actionFunction action="{!testmeth}" name="testcheck">
<apex:param assignTo="{!pValue}" value=""/>
</apex:actionFunction>
<apex:pageBlock >

<apex:inputCheckbox title="Test" id="chkbox" onclick="testclick('Test')"/>
<apex:outputLabel id="olabel" for="chkbox">Test</apex:outputLabel>
</apex:pageBlock>

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

 

Controller:

public class testcontroller{

public testcontroller(ApexPages.StandardController controller) {

}

public Static String pValue{get;set;}

public static void testmeth(){
system.debug('Test --->' + pValue);
}
}

Hi folks,

 

I'm trying to create a portal user as part of a test class. I was building the test class piece-by-piece, smoothing out the errors as I went along, but I'm stuck with this one, even though my Test Class, below, contains a ContactId.

 

Error: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Cannot create a portal user without contact: [ContactId]

 

Test Class:

 

@isTest
public class TestClassPasswordReset {
	static testMethod void passwordresettest(){
        list<User> me = new list<User>([Select languagelocalekey, localesidkey, TimezoneSidKey from User where id = '005E0000001Z5kJ']);
        Contact c = new Contact();
        User u = new User();
        u.ContactId = c.id;
        u.ProfileId = '00eE0000000ZkiK';
        u.username = 'test@test.com';
        u.FirstName = 'First';
        c.LastName = 'Last';
        u.LastName = c.LastName;
        u.email = 'test@test.com';
        String alias = u.username;
        if(alias.length() > 5){
            alias = alias.substring(0,5);
        }
        u.alias = alias;
        u.languagelocalekey = me[0].languagelocalekey;
        u.localesidkey = me[0].localesidkey;
        u.emailencodingkey = 'UTF-8';
        u.TimezoneSidKey = me[0].TimezoneSidKey;
        insert c;
        insert u;
        }
}

 Any help greatly appreciated.

 

Many thanks,

Lee

 

 

Hello all,

 

   My requirement is Suppose there are 3 fields a,b,c in a object......When I enter value in field a,then b,c fields should be required....Can I do it....If yes how can I do it.....Help please

Hi,

 

I want Lead Title should be mapped to Opportunity Name on conversion of lead. Please help me with some piece of code.

 

Eg:

Lead title is "XYZ", when I convert that lead, new opp should be created with the Opp Name: XYZ

 

Regards,

Taani

hi

 

 How to provide security for reports in salesforce?

i dont know why we are creating static method under apex class using the developer console.what is the purpose of creating static method undre the apex class...please help..

trigger Behr_AmountOfMonths_US on THD_Sales__c (after insert,after update) {
    
    Set<Id> accset = new Set<Id>();
    Set<Id> thdset = new Set<Id>();
    List<THD_Sales__c> thdlst = new List<THD_Sales__c>();
    list<account> acclist = new list<account>();
    Map<Id,THD_Sales__c> thdmap = new Map<Id,THD_Sales__c>();
   map<Id,Double> AccountMap = new map <Id,Double>();

    for(THD_Sales__c thd : Trigger.new) {
        if(thd.POS_Order_Type__c == 'Special Order' && MONTH(thd.Month_Year__c)=1) {
            accset.add(thd.SFDC_Account_ID__c);            
        }
    }
    
    for(AggregateResult q:[SELECT SFDC_Account_ID__c sfdcAccId,sum(Amount__c)tot FROM THD_Sales__c 
    where SFDC_Account_ID__c in :accset group by SFDC_Account_ID__c]) {
        //AccountMap.put((Id)q.get('SFDC_Account_ID__c'),(Double)q.get('expr0'));
        Id sfdcId = (Id) q.get('sfdcAccId');
        Double dTotal = (decimal) q.get('tot'); 
        AccountMap.put(sfdcId, dTotal);
    } 
}

 Error: Compile Error: Method does not exist or incorrect signature: MONTH(Date) at line 11 column 56

if(thd.POS_Order_Type__c == 'Special Order' && MONTH(thd.Month_Year__c)=1)

trigger Behr_AmountOfMonths_US on THD_Sales__c (after insert,after update) {
    
    Set<Id> accset = new Set<Id>();
    Set<Id> thdset = new Set<Id>();
    List<THD_Sales__c> thdlst = new List<THD_Sales__c>();
    Map<Id,THD_Sales__c> thdmap = new Map<Id,THD_Sales__c>();
   map<Id,Double> AccountMap = new map <Id,Double>();

    for(THD_Sales__c thd : Trigger.new) {
        if(thd.POS_Order_Type__c == 'Special Order') {
            accset.add(thd.SFDC_Account_ID__c);            
        }
    }
    for(AggregateResult q:[SELECT SFDC_Account_ID__c,sum(Amount__c)tot FROM THD_Sales__c where SFDC_Account_ID__c in :accset group by SFDC_Account_ID__c]) {
        AccountMap.put((Id)q.get('SFDC_Account_ID__c'),(Double)q.get('expr0'));
    }    
}

  Error: Compile Error: line 15:69 no viable alternative at character '' at line 15 column 69

 

AccountMap.put((Id)q.get('SFDC_Account_ID__c'),(Double)q.get('expr0'));

Does anyone know of an equivalent to URLFOR in Apex. We now have dynamic components that can be initialized in apex. For example if you wanted to initialize the stylesheet component you could do this:

 

Apex.Component.Stylesheet customstyle = new Apex.Component.Stylesheet();

customstyle.value = '/mystyle.css';

 

This is great but I want to initalize the component to use a static resource stored in a zip file. In visualforce that's easy using the URLFOR() function. Is there anyway to acheive the same functionality in Apex?

 

Thanks!

Scott

hi, 

 

 

 
How can I write a SOQL query to find duplicate Account names.................
 
 
  • October 12, 2012
  • Like
  • 0

How to select multiple files with one go (one browser button)

 

its very urgent .....

  • October 12, 2012
  • Like
  • 0

Hi,

how to display list of records by using below soql query ,.....

 

it is write code in apex class and the results in system .debug....

 

please help me frnds..........

 

 

using this soql query...

 

Select Id, Name, (Select Id, Name From Contacts) From Account

  • October 12, 2012
  • Like
  • 0

Hi All,

 

How to display the Account Name in different font in detail page.

Salesforce always shows the fields in Black font, so how can we display in some other font?

 

I do not want to use visual force and rich text area?

Hi ,

 

When i try to update the sobject dynamically it throws me a error saying "System.SObjectException: Field Id is not editable". Can you please help on this:

 

I have used the below code to update :


Schema.SObjectType t = Schema.getGlobalDescribe().get('Account');
SObject sObjectAccount = t.newSObject();
sObjectAccount.put('Id', '001G000000pyDGL');
sObjectAccount.put('Name', 'Test');

Update sObjectAccount;

Hi,

Can some one help me on this by explaining the reasons:

 

Given the following Force.com page markup and assuming the controller and each extension include an action method named “go,” which class method will be invoked when the user clicks on the commandButton?
A. theController
B. ext1
C. ext2
D. ext3

 

-Kaity

  • July 18, 2013
  • Like
  • 0

Hi all,

 

I have one Custom Object Patient__c.On VF page onclick of commandlink button I am filling all the correspondant fields of Patient like firstname, middle name like that. I am getting the particular id also. Now my requirment is this to insert the new patient if we did not get the id from SQL query else update the patient if we got the id. Suppose the variable name in which I am getting the id is PatientID on Apex page


Please tell me I got stuck here ??

 

Regards
Raman

Hello Everyone,

 

How to Use @readOnly Annotation in Apex Class. Can anyone suggest me by sending one sample class with @readOnly Annotation.

 

Please let us know if we use @readOnly annotation in Apex Class that is calling from Apex Trigger.

 

Thanks,

Anil

Hi All,I have created a Apex code for my custom object button which will create a 10 opportunity. Now i need to move this to production. I didn't have any idea about writting test class, Can anyone help me how to write test class for this,also tell me any link about class. I am new to salesforce this is the first time I am going to write test class.Thanks in advance,waiting for your reply.

 

Apex Code:

 

public class Conversion_site
{
    private Site__c siteObj;
    public String Sales_pop {get; set;}
    private List<Opportunity> lstOpp = new List<Opportunity>();
    public List<opportunityRecords> lstOppRecords {get; set;}
    public Map<Integer, opportunityRecords> mapOppRecords {get; set;}
    public Integer selectedRowIndex {get; set;}
    public Integer rowCount {get; set;}
    private Integer intialCount = 10;
    private Integer maxCount {get; set;}
    public List<String> lstOppName {get; set;}
    private Map<Integer, String> mapOppName {get; set;}
    private Map<Integer, String> mappedOppName = new Map<Integer, String>();
    public String dateTimeValue { get; set; }
    public Boolean showOppRec {get; set;}

/*Opportunity records*/
public class opportunityRecords implements Comparable
{
    //Holds record Index
    public Integer recIndex {get; set;}
    public String oppType {get; set;}
    public Opportunity opp {get; set;}
    public Boolean rendered {get; set;}

    public opportunityRecords(Integer index)
    {
        recIndex = index;
        opp = new Opportunity();
        rendered = true;
    }

    // Implement the compareTo() method
    public Integer compareTo(Object compareTo) {
        opportunityRecords oppRec = (opportunityRecords)compareTo;
        if (recIndex == oppRec.recIndex) return 0;
        if (recIndex > oppRec.recIndex) return 1;
        return -1;        
    }
}

////save the records by adding the elements in the inner class list to lstAcct,return to the same page
public PageReference Convert()
{
    system.debug('>>>Inside convert');
    PageReference pr = new PageReference('/' + siteObj.Id);
    Integer totalRows = 0;
    lstOpp.clear();
    for(opportunityRecords oppRec : lstOppRecords)
    {
        if(oppRec.rendered)
        {
            totalRows++;
            oppRec.opp.Name = siteObj.Name+'-'+oppRec.oppType;
            oppRec.opp.Site_Ref_No__c = siteObj.Site_Ref_No__c;
            oppRec.opp.Site_Lead__c = siteObj.Id;
            if(oppRec.opp.StageName == 'No Contact Made')
                oppRec.opp.Probability= 0;
            else if(oppRec.opp.StageName == 'Contact Made')
                oppRec.opp.Probability= 10;
            else if(oppRec.opp.StageName == 'Taking Off')
                oppRec.opp.Probability= 25;
            else if(oppRec.opp.StageName == 'Quotation with Customer ')
                oppRec.opp.Probability= 50;
            else if(oppRec.opp.StageName == 'Negotiation/Review')
                oppRec.opp.Probability= 75;
            else if(oppRec.opp.StageName == 'Closed Won')
                oppRec.opp.Probability= 100;
            else if(oppRec.opp.StageName == 'Closed Lost')
                oppRec.opp.Probability= 0;

            if (oppRec.opp.AccountId != null && oppRec.opp.CloseDate != null && oppRec.opp.OwnerId != null)
            {    /*Default user as Opp owner*/
                /*if (oppRec.opp.OwnerId == null)
                    oppRec.opp.OwnerId = UserInfo.getUserId();*/
                system.debug('>>>Check already available:');
                system.debug(oppRec.opp);
                lstOpp.add(oppRec.opp);
                //mapOppRecords.remove(oppRec.recIndex);
                oppRec.rendered = false;
                mapOppRecords.put(oppRec.recIndex,oppRec);
                rowCount = rowCount - 1;
            }
        }
    }
    insert lstOpp;
    if (lstOpp.size() != totalRows)
    {
        clearAndPopulateList();
        String successMsg = '';
        if(lstOpp.size() > 0)
        {
            if(lstOpp.size() == 1)
                successMsg = 'Successfully Created ' + lstOpp.size() + ' Opportunity';
            else if(lstOpp.size() > 1)
                successMsg = 'Successfully Created ' + lstOpp.size() + ' Opportunities';
            ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,successMsg));   
        }
        String errorMsg = 'Please enter Account,Sales Person and Close Date for below Opportunities. Otherwise click cancel to go back to Site Leads page.';

        ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.INFO,errorMsg));

        pr = null;
    }
    else
    {
        showOppRec = false;
        ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'All Opportunities created successfully. Please click cancel to go back to Site Leads page.')); 
        //pr.setRedirect(True);
        pr = null;
    }
    return pr;
}

//add one more row
public void Add()
{   
    if (rowCount < maxCount)
    {
        rowCount = rowCount+1;
        addMore();
        clearAndPopulateMap();
    }
    else
    {
        ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Maximum row that can be added is ' + maxCount));
        //return null;
    }
}

/*Begin addMore*/
public void addMore()
{
//clearAndPopulateMap();
    //call to the iner class constructor
    Set<Integer> setName = mapOppName.keySet();
    List<Integer> lstName = new List<Integer>();
    lstName.addAll(setName);
    mappedOppName.put(lstName[0], mapOppName.get(lstName[0]));
    mapOppName.remove(lstName[0]);
    opportunityRecords oppRecord = new opportunityRecords(rowCount);
    oppRecord.oppType = mappedOppName.get(lstName[0]);
 /*----Default value for Account and Salesperson----*/
  /*Id accId = siteObj.Account__c;
    system.debug('accId' + accId);
    if (accId != null)
    {
        oppRecord.opp.AccountId = accId;
        Id ownerid = getSalesPerson(oppRecord.opp.AccountId);
        if (ownerid != null)
            oppRecord.opp.OwnerId = ownerid;
    }*/
   // oppRecord.opp.CloseDate = siteObj.Completion_Date__c;
    oppRecord.opp.CloseDate=date.today()+7;
    oppRecord.opp.StageName = 'No Contact Made';
    //add the record to the inner class list
    lstOppRecords.add(oppRecord);
//clearAndPopulateMap();
    system.debug('lstOppRecords---->'+lstOppRecords);            
}/* end addMore*/


private void clearAndPopulateMap()
{
    if(!lstOppRecords.isEmpty())
    {
        mapOppRecords.clear();
        for(opportunityRecords oppRec : lstOppRecords)
        {
            mapOppRecords.put(oppRec.recIndex, oppRec);
        }
        lstOppRecords.sort();
    }
}

private void clearAndPopulateList()
{
    if(!lstOppRecords.isEmpty())
    {
        lstOppRecords.clear();
        lstOppRecords = mapOppRecords.values();
        lstOppRecords.sort();
    }
}

/* begin delete */
public PageReference Del()
{
    /*if(rowCount > 1)
    {
        system.debug('selected row index---->'+selectedRowIndex);
        //lstOppRecords.remove(selectedRowIndex-1);
        opportunityRecords opRec = mapOppRecords.get(selectedRowIndex);
        for(Integer i = 0; i < mapOppRecords.size(); i++)
        {
            if (mappedOppName.containsKey(i) && mappedOppName.get(i) == opRec.oppType)
            {
                mapOppName.put(i, mappedOppName.get(i));
                mappedOppName.remove(i);
                break;
            }
        }
    mapOppRecords.remove(selectedRowIndex);
        rowCount = rowCount - 1;
    clearAndPopulateList();
        return null;
    }
    else
    {
        ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter atleast one Opportunity.'));
        return null;
    }*/
    return null;

} /*End del*/

private void AddOpportunity(Integer rc)
{
    for(Integer i = 0; i < rc; i++) 
    {
        rowCount += i;
        addMore();
    }
    clearAndPopulateMap();
}

//Sales Person Populate from Account
public Id getSalesPerson(Id accountid)
{
    Id salesPersonId = [select EXO_Sales_Rep__r.id, EXO_Sales_Rep__r.Name 
                    from Account 
                    where id=:accountid 
                    LIMIT 1].EXO_Sales_Rep__r.Id;
    return salesPersonId;
}

//OnChange SalesPerson Populate
public void SalesPersonPopulate()
{
    system.debug('>>>ListOpprec start ' + lstOppRecords);
    opportunityRecords opRec = mapOppRecords.get(selectedRowIndex);
    if (opRec.opp.AccountId != null)
    {
        Id ownerid = getSalesPerson(opRec.opp.AccountId);
        opRec.opp.OwnerId = ownerid;
        mapOppRecords.put(selectedRowIndex, opRec);
        clearAndPopulateList();
    }
    system.debug('>>>ListOpprec start ' + lstOppRecords);
}

private void opportunityList()
{
    lstOppName = new List<String>();
    mapOppName = new Map<Integer, String>();
    lstOppName.add('Floor Systems');
    lstOppName.add('Footings & Concrete');
    lstOppName.add('Frames');
    lstOppName.add('Roof');
    lstOppName.add('External Cladding');
    lstOppName.add('Plasterer');
    lstOppName.add('Fix out');
    lstOppName.add('Renderer');
    lstOppName.add('Retaining Walls / Landscaping');
    lstOppName.add('Hire');
    maxCount = lstOppName.size();
    for(Integer i = 0; i < maxCount; i++)
    {
        mapOppName.put(i, lstOppName[i]);
    }
}
public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    for(String name : lstOppName)
    {
        options.add(new SelectOption(name,name));
    }
    return options;
}

/*Constructor*/
public Conversion_site(ApexPages.StandardController stdController)
{  dateTimeValue = System.Now().format('dd/MM/yyyy');//GMT 
    siteObj = (Site__c)stdController.getRecord();
    lstOppRecords = new List<opportunityRecords>();
    mapOppRecords = new Map<Integer, opportunityRecords>();
    opportunityList();
    rowCount = 0;
    AddOpportunity(intialCount);
    selectedRowIndex = 0;
    showOppRec = true;
}/*End Constructor*/

I have a custom field in Opportunity is Auto_Number__c

 

i have a trigger like this

trigger updateactive on Opportunity(before insert){



for(Opportunity c : Trigger.new){

if(c.StageName == 'Closed Won')
c.Auto_Number__c=c.Auto_Number__c+1;

}

}

 I want to increment the old record Auto_Number__c and update like2,3,4 etc  like that when opportunity is closed won

 

trigger OppDescUpdate on Opportunity (before update) {
    if(trigger.new[0].stagename != trigger.old[0].stagename)
    {
        trigger.new[0].description = 'opportunity stage changes from' + trigger.old[0].stagename + ' to '+ trigger.new[0].stagename;
    }
}

Can u give a small idea to bulk this trigger. Just give steps to bulk this, no need code

trigger AccDescriptionUpdate on Account (before update) {
set<Id> setIds = new set<Id>();
for(Account objA : trigger.new){
setIds.add(objA.id);
}
system.debug('----set Ids are --->'+setIds);

List<Account> lstA = [select id,name,(select id,name from Contacts) from Account where id in : setIds];
system.debug('---lstA is --->'+lstA);
String sDesc ='';

for(Account objA : lstA){
Integer i= objA.contacts.size();
integer j=1;
for(Contact objC : objA.contacts){
if(j <= i-1){
sDesc = sDesc + objC.name + ',';
j++;
}
else{
sDesc = sDesc + objC.name;
j++;
}



}
system.debug('---sDesc is --->'+sDesc);
objA.description = sDesc; // In before insert why its not updating to my account.
system.debug('---objA.description is --->'+objA.description);
}

}

 

how can i update the description file in before update event.

what is the  difference between export and export all in apex dataloader?

what is the difference between before insert  trigger and after insert triggers? can we retrive IDs in before insert trigger?

Hi All,

            It would be helpful if you could let me know on how to import salesforce custom object data into excel sheet (without using any excel connector/ApexDataLaoder) programatically (Visual Force).

 

Thanks in advance..

 

Pavan..

Hi folks,

 

I have a number of Triggers that, upon creation of a custom record, automatically create an associated custom record. The Triggers themselves fire fine, but I can only get about 70% code coverage in my test classes. If anyone could help me with the form one of the test classes should take, I'm sure I'll be able to write the rest for the other Triggers. Here's an example of the kind of Trigger I mean:

 

trigger AutoProject on Procurement__c (before insert) {
    map< id, Milestone1_Project__c > proj = new map< id, Milestone1_Project__c >( );
    
    for( Procurement__c proc : trigger.new ) {
       proj.put( proc.id,
            new Milestone1_Project__c(
                  Name = proc.Name,
                  Submission_Deadline__c = proc.Submission_Deadline__c)
            );
    
    insert proj.values();
    proc.Bid_Planning_Timeline__c = proj.get(proc.id).id;    
    }        
    
}

 Any help very greatly appreciated.

 

Many thanks,

Lee

Hi,

 

Below is my code and i am trying to using the for loop to iterarte the element but i am getting an error unexpected token projectDetail.id how can i modify the below code in for loop

 

 

public with sharing class ProjectDetailrecords {
   
    public  Project_Detail__c  projectDetailrecords {get; set;}
   
  
    public ProjectDetailrecords(ApexPages.StandardController pController) {
       projectDetail =(Project_Detail__c)pController.getRecord();
       String projectDetailId = projectDetail.Id;
       projectDetail = [SELECT Id, Name,CoreCompleted__c,Completed__c   FROM Project_Detail__c WHERE ID = :projectDetailId];
    }
   
      
    public PageReference ProjectApprovals() {
                
           for(Project_Detail__c item: [SELECT Id, Name,Record_Type__c,CoreCompleted__c,Completed__c   FROM Project_Detail__c  WHERE ID = projectDetail.Id]){
                  
         if((item.Completed__c != 100) && (item.CoreCompleted__c != 100) ){
         String msg='Must be completed ';
         ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,msg);
            ApexPages.addMessage(myMsg);
            return null;
        } }
       

I have one custom object ,i have to insert data into this object by  selecting csv file from browse button.Could u please help out how to write code?

 

Thanks in Advance...

PavanReddy

I have a master detail relationship between Opportunity(Parent) and a custom object(Child).

The child object has the same picklist field with same values as Opportunity StageName.

 

 

I want the stage value in child object to change automatically whenever the StageName in parent object changes.

 

Can anyone please tell me how to do this.

 

Thanks.

Hi Folks,

 

I have assigned 4 custom boolean fields to the Contacts and these are for users to update which email they would like to subscribe too, such as Monthly Newsletter, New Courses etc.

 

I am trying to create a page on our force.com site that displays the 4 checkboxes with a save button, so we can attach a link to the bottom of the emails we send for users to update their subscriptions to the emails we send them.

 

Visualforce Page:

 

<apex:page Controller="EmailSubscriptionController">
    <apex:form >
        <apex:messages />
        <br />

        <apex:inputCheckbox id="Brochure_email__c" value="{!contact.Brochure_email__c}"/>Brochure Email<br />
        <apex:commandButton value="Save" action="{!save}"/>


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

 

Apex Class:

 

public class EmailSubscriptionController {

    public final Contact contact;
    public ID get_id {get;set;}
    public boolean email_brochure {get;set;}

    public EmailSubscriptionController() {
        contact = [SELECT Brochure_email__c  FROM Contact
            WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Contact getContact() {
        return contact;
    }

    public PageReference save() {

        try {
            upsert(contact);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }

        return null;

    }
}

 

The code shows me the force.com page fine, and check's the relevant boxes, but when i click update it gives me the following error message:

 

system.security.NoAccessException: Update access denied for Contact

 

Any ideas on how i can get this working?

 

Many Thanks

 

Dave

 

 

Hi All,

 

I have a code which are getting all the fields name and their properties like api name, label , data type.

 

Now for deployed the code I am getting this exception :

System.SObjectException: Field Lead.LastViewedDate is inaccessible in this context.

 

It seems that there is a field "LastViewedDate" , I have checked all fields but I am not able to find this.

Please let me know if any one have any idea.

 

Regards,

Deepak