• Amitd
  • NEWBIE
  • 160 Points
  • Member since 2013
  • Team Lead
  • NTT DATA

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 32
    Replies
Hello friend 

I need to count Multi select picklist selected items and how to read those item using trigger.
for count i have create formula filed that working fine, but i dont want to use formula filed.
my objective if we selected two item in a list  then  two case created with  subject name  and subject name is  item value .


trigger onandoffboardingticket on Case (before insert) {

             List<SelectOption> objNames = new List<SelectOption>();
            List<Case>newCace=new List<Case>();
            List<String> recordType=new List<String>{'zCampusHelp_Internal'};
                
             
            
               for(case c :trigger.new)
               {
                       
                       for(Integer i=1;i<=c.Count__c;i++)
                       {
                       
                           Case cas=new case();
                           cas.AccountId=c.AccountId;
                           cas.Subject=c.Subject;
                           cas.Onboarding_Offboarding_Employee__c=c.Onboarding_Offboarding_Employee__c;
                           cas.Status=c.Status; 
                        
                           cas.ContactId=c.ContactId;
                           cas.Internal_Category__c=c.Internal_Category__c;
                           cas.Internal_Type__c=c.Internal_Type__c;
                           cas.Internal_Item__c=c.Internal_Item__c;
                           newcace.add(cas);
                       }
                       }
               
    insert newcace;
}

HI experts,

 

There is deal custom object and opporunity standard i created one button name called convert in deal object so when user click on that deal objects what ever are there it has covert in to opportunity so my requriment is now only approved deal has to convert opportuntiy so give me idea on this pls.

 

 

Hi I have a Situation here..

 

I have a billing custom object that has a relationship to customer custom object..  and then I have a product custom object and a tempbilling custom object that stores the productID, QTY, Bill ID, customerID..   I have created a visualforce page that allows a person to select a customer and then he selects the products and which is totaled. but I am facing dificulty to manage the databse.. the calulation is working fine but I am facing dificulty to manage the database..

 I want to do is that if I insert into bill the customerID then how can I get the ID of the bill after insert so that I could use it further?

Hi I have developed a visualforce page with a controller extension. That should allow the user to select a custom Object 'Territory_Account__c' for deletion (among other things) the problem is that the selected Territory Account is not returning True. The controller and visualforce page code is below. Any help would be great!

 

Page Controller:

public with Sharing class TerritoryController{
	
    ApexPages.StandardController con;
    public Territory__c Territory {get; set;}
    public List<TAWrapper> TAccounts {get;set;}
    private List<Territory_Account__c> TADeleteList = New List<Territory_Account__c>();
    private integer counter=0;  //keeps track of the offset
    public integer list_size=200; //sets the page size or number of rows
   	public integer total_size; //used to show user the total size of the list
    boolean DTA = False;
    Public Id TerritoryId;
    
    public TerritoryController(ApexPages.StandardController TController) {
    
      //  con = TController;
     //   Territory = (Territory__c)TController.getRecord();
        TerritoryId = ApexPages.CurrentPage().getParameters().get('id');
        
        total_size = [SELECT count() FROM Territory_Account__c WHERE Territory__c = :TerritoryId];
    }
    
    Public List<TAwrapper> getTAs() {	
        System.Debug('Joel: GetTAs has run');
        If(TAccounts == NULL) {
        	TAccounts = New List<TAWrapper>();
            For(Territory_Account__c TerAcc : [SELECT Id, Account__c, Account__r.name, Liberate_Cust_ID__c, Debtor_Group__c 
                                                   FROM Territory_Account__c 
                                                   WHERE Territory__c = :TerritoryId
                                                   ORDER BY Account__r.name
                                               	   LIMIT :list_size
                                                   OFFSET :counter])
                TAccounts.add(new TAWrapper(TerAcc,False));  
        } 
        return TAccounts;
    }
    

    Public class TAwrapper {

        Public TAwrapper(Territory_Account__c rTA, Boolean rSelected) {
            Selected = rSelected;
            TAccount = rTA;
        } 
        
        public Boolean Selected {get; set;}
        public Territory_Account__c TAccount {get; set;}
    }

    public PageReference DeleteTA() { 

        TADeleteList = New List<Territory_Account__c>();
        List<Id> TAIdList = New List<Id>();
        Territory_Account__c TAd;
	//	DTA = True;
        
    	For(TAWrapper TW : getTAs()) {
				System.debug('Joel: Print of TW '+TW);
                If(TW.Selected == True) {
                    System.Debug('Joel: TA is Selected');
                    TAIdList.Add(TW.TAccount.Id);
                }
            }
        
        If(TAIdList.Size()>0) { 
            For(Territory_Account__c Tac : [Select Id from Territory_Account__c where Id IN :TAIdList])
            	TADeleteList.Add(Tac);
            Delete TADeleteList;
            DTA = False;
         //   TAccounts = NULL;
            return NULL; //new PageReference(ApexPages.currentPage().getUrl());
        }
        else {
            System.Debug('Joel: TAdelete list is empty');
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'No Territory Accounts Selected'));
            DTA = False;
            Return Null;
        }       
              
      	
   	}

 The Visualforce Page:

<apex:page standardController="Territory__c" extensions="TerritoryController">
    <apex:sectionHeader title="Territory" subtitle="{!Territory__c.Name}"/>
    <apex:pageMessages />
    <apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false"/> 
    
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"/>
    <script type="text/javascript">
        jQuery.noConflict();        
        $j = jQuery;
        
        $j( function(){
            $j("input.SelectAll").click(function(event){                
                $j("table.AccountsTable input[type=checkbox]").attr("checked", event.target.checked);
            });
        
        });        
    </script>
     
    <apex:pageBlock Title="Territory Accounts">
		<apex:pageBlockButtons location="top" >
   			<apex:outputPanel id="myButtons">
                <apex:form >
                    <apex:commandButton action="{!NewTA}" title="New Territory Account" value="New Territory Account" style="font-size:x-small;"/>
                    <apex:commandButton action="{!DeleteTA}" title="Delete Territory Account" value="Delete Territory Account" style="font-size:x-small;"/><br/>
                 <!--   <apex:commandButton action="{!Beginning}" title="Beginning" value="First Page" disabled="{!disablePrevious}" reRender="myPanel,myButtons" style="font-size:xx-small;"/>
                    <apex:commandButton action="{!Previous}" title="Previous" value="Previous Page" disabled="{!disablePrevious}" reRender="myPanel,myButtons" style="font-size:xx-small;"/>        
                    <apex:commandButton action="{!Next}" title="Next" value="Next Page" disabled="{!disableNext}" reRender="myPanel,myButtons" style="font-size:xx-small;"/>
                    <apex:commandButton action="{!End}" title="End" value="Last Page" disabled="{!disableNext}" reRender="myPanel,myButtons" style="font-size:xx-small;"/>   -->
               </apex:form>
       		</apex:outputPanel>
   		</apex:pageBlockButtons>
        
        <apex:outputPanel id="myPanel">
            <apex:form >
                <apex:outputPanel rendered="{!total_size > list_size}" style="color:red;">
                    <apex:outputText value="{0,number,###0}"><apex:param value="{!total_size}" /></apex:outputText>
                    results found,&nbsp;  
                    <apex:outputText value="{0,number,###0}"><apex:param value="{!list_size}" /></apex:outputText>
                    displayed per page<br/> 
                </apex:outputPanel>
                <apex:outputPanel rendered="{!total_size>list_size}">
                    Go to page: &nbsp;&nbsp;
                    <apex:commandLink action="{!page1}" value="1" rendered="{!AND(counter!=0,total_size>list_size)}" rerender="myPanel,myButtons"/>
                    <apex:outputText value="1" rendered="{!AND(counter==0,total_size>list_size)}" style="color:#666666;"/>
                    &nbsp;&nbsp;
                    <apex:commandLink action="{!page2}" value="2" rendered="{!AND(OR(counter<list_size,counter>=(list_size*2)),total_size>(list_size))}" rerender="myPanel,myButtons"/>
                    <apex:outputText value="2" rendered="{!AND(counter>=list_size,counter<(list_size*2),total_size>(list_size))}" style="color:#666666;"/>
                    &nbsp;&nbsp;
                    <apex:commandLink action="{!page3}" value="3" rendered="{!AND(counter<(list_size*2),total_size>(list_size*2))}" rerender="myPanel,myButtons"/>
                    <apex:outputText value="3" rendered="{!AND(counter>=(list_size*2),counter<(list_size*3),total_size>(list_size*2))}" style="color:#666666;"/>
                    &nbsp;&nbsp;
                    <apex:commandLink action="{!page4}" value="4" rendered="{!AND(counter<(list_size*3),total_size>(list_size*3))}" rerender="myPanel,myButtons"/>
                    <apex:outputText value="4" rendered="{!AND(counter>=(list_size*3),counter<(list_size*4),total_size>(list_size*3))}" style="color:#666666;"/>
                    &nbsp;&nbsp;
                    <apex:commandLink action="{!page5}" value="5" rendered="{!AND(counter<(list_size*4),total_size>(list_size*4))}" rerender="myPanel,myButtons"/>
                    <apex:outputText value="5" rendered="{!AND(counter>=(list_size*4),counter<(list_size*5),total_size>(list_size*4))}" style="color:#666666;"/>
                </apex:outputPanel>
    	
            	<apex:pageblockTable styleClass="AccountsTable" id="accounts-table" value="{!TAs}" var="TA" >
            		<apex:column style="width:60px;">
                  		<apex:facet name="header">
                    		<input type="checkbox" class="SelectAll"/>Action                  
                  		</apex:facet>            
                        <apex:inputCheckbox value="{!TA.Selected}"/>   
            		</apex:column>
                    <apex:column value="{!TA.TAccount.Account__c}" />
                    <apex:column value="{!TA.TAccount.Liberate_Cust_ID__c}"/>
                    <apex:column value="{!TA.TAccount.Debtor_Group__c}"/>
    			</apex:pageblockTable>
            </apex:form>
        </apex:outputPanel>
    </apex:pageBlock>
</apex:page>

 

Hi,

This is veeraiah.i have one question

 

in my application i have some visual force pages ,i have a custom object and also i have main controller .now my questio is i want to insert th visualforce pages which i create or i have ino the custom object  as a link from the controller.i should insert that page through the main controller and if we click the page inserted in the custom object then  need to see the no of queries(queries count ) in the object .

  

pls anybody help me on this

 

 

Thanks,

veeraiah

Hi,

 

I am trying to create a record with user inputs from different visual force page. I got struck in between.

 

like page 1 gets 2 user inputs and then navigate to page 2 and get 2 more inputs and then inserting the records. the problem is all the 4 fields in the record are mandatory. so if i save the fields after first page, it throws DML exception and if i save in page 2 also ith throws because the values of first page are missing.

 

There is no session object in salesforce i guess..what can i do to handle this situation.

 

 

I'm not a developer, i'm trying to schedule the below job but I recevie "First error: You have uncommitted work pending. Please commit or rollback before calling out". Not sure how to fix this, can some one help, below is the code of the apex calss I'm trying to schedule.

Backgroupd : Brightlocal is a SEO tool and this class is trying to bring ranking infomration into salesforce.

global class BrightLocal_DownloadSeoReports implements Database.Batchable<sObject>, Database.AllowsCallouts {

  private static LogEmail email = new LogEmail('Download of SEO Reports from Bright Local');

  global Database.QueryLocator start(Database.BatchableContext BC) {

    try {
      email.Log('Starting Bright Local SEO download');

      Date today = Date.today();
      Integer day = today.day();

      email.Log('Using Today:', '' + today);
      email.Log('Using Day:', day);

      // TODO: Assess if this should run more than once a night
      // to account for failures and more than 100 records per day @ EOM
      Database.QueryLocator locator = Database.getQueryLocator([
        SELECT Ranking_Report_Link__c
        FROM Asset__c
        WHERE Ranking_Report_Link__c != null
        AND (BrightLocal_Last_Run_Date__c = NULL OR BrightLocal_Last_Run_Date__c < :today)
        AND Day_of_Month__c <= :day
        LIMIT 100  // Limit to 100 for external HTTP requests
      ]);

      email.Log('Query used to find assets:', locator.getQuery());
      email.Send();

      return locator;
    } catch(Exception ex) {
      email.Log(ex);
      email.Send();
      throw ex;
    }
  }


  global void execute(Database.BatchableContext BC, List<sObject> scope) {
    try {
      List<Asset__c> assets = (List<Asset__c>)scope;

      email.Log('Asset Count:', assets.size());
      if (assets.size() >= 100) {
        email.Log(LogEmail.MsgType.WARNING, '100 Assets selected.  It is likely that the job will need to run again.');
      }

      for (Asset__c asset : assets) {
        DownloadReport(asset.Id, asset.Ranking_Report_Link__c);
      }
      email.Send();
    } catch(Exception ex) {
      email.Log(ex);
      email.Send();
      throw ex;
    }
  }


  global void finish(Database.BatchableContext BC) {
    System.debug('Finished Download of SEO Reports');
    email.Send();
  }


  private static void DownloadReport(ID assetId, String reportUrl) {
    email.Log('Downloading Report for Asset:', assetId + ' - ' + reportUrl);

    // Download the Report from Bright Local
    HttpRequest req = new HttpRequest();
    req.setEndpoint(reportUrl + '.csv');
    req.setMethod('GET');

    Http http = new Http();
    HTTPResponse res = http.send(req);


    // Create a Summary and Summary Line items based on the Bright Local report
    SEO_Result_Summary__c summary = new SEO_Result_Summary__c();
    summary.Asset__c  = assetId;

    List<SEO_Summary_Line_Item__c> lineItems = new List<SEO_Summary_Line_Item__c>();

    //List<String> lines = res.getBody().split('\n');
    List<List<String>> lines = parseCSV(res.getBody(), true);

    for(List<String> line : lines) {
      // if (line.indexOf('"Search Term"') == 0) continue;
      // List<String> values = line.split(',', -1);

      List<String> values = line;
      // // If the size is not 10, skip as the row has incomplete data.
      if (values.size() < 10) continue;

      for(Integer i=0; i<values.size(); i++) {
        if (values[i] != 'n/a') continue;
        values[i] = null;
      }

      // Calculate current and previous ranks
      Integer currentRank = Rankings.containsKey(values[Rank]) ? Rankings.get(values[Rank]) : 0;
      Integer previousRank = Rankings.containsKey(values[Last_Rank]) ? Rankings.get(values[Last_Rank]) : 0;

      lineItems.add(new SEO_Summary_Line_Item__c(
        Last_Rank__c = TryParse(values[Last_Rank]),
        Page__c = TryParse(values[Page]),
        Rank__c = TryParse(values[Rank]),
        Result_URL__c = values[Result_URL],
        Search_Engine__c = values[Search_Engine],
        Search_Term__c = values[Search_Term],
        Search_URL__c = values[Search_URL],
        Type__c = values[Type],
        Score__c = currentRank - previousRank
      ));
    }

    email.Log('# of Line Items :', lineItems.size());
    // Don't insert a Summary or Line items if none exist
    if (lineItems.size() == 0) return;

    insert summary;
    for(SEO_Summary_Line_Item__c lineItem : lineItems) {
      lineItem.SEO_Result_Summary__c = summary.id;
    }
    insert lineItems;

  }


  // See: https://developer.salesforce.com/page/Code_Samples
  public static List<List<String>> parseCSV(String contents, Boolean skipHeaders) {
    List<List<String>> allFields = new List<List<String>>();

    // replace instances where a double quote begins a field containing a comma
    // in this case you get a double quote followed by a doubled double quote
    // do this for beginning and end of a field
    contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
    // now replace all remaining double quotes - we do this so that we can reconstruct
    // fields with commas inside assuming they begin and end with a double quote
    contents = contents.replaceAll('""','DBLQT');
    // we are not attempting to handle fields with a newline inside of them
    // so, split on newline to get the spreadsheet rows
    List<String> lines = new List<String>();
    try {
      lines = contents.split('\n');
    } catch (System.ListException e) {
      System.debug('Limits exceeded?' + e.getMessage());
    }
    Integer num = 0;
    for(String line : lines) {
      // check for blank CSV lines (only commas)
      if (line.replaceAll(',','').trim().length() == 0) break;

      List<String> fields = line.split(',');
      List<String> cleanFields = new List<String>();
      String compositeField;
      Boolean makeCompositeField = false;
      for(String field : fields) {
        if (field.startsWith('"') && field.endsWith('"')) {
          cleanFields.add(field.replaceAll('DBLQT','"'));
        } else if (field.startsWith('"')) {
          makeCompositeField = true;
          compositeField = field;
        } else if (field.endsWith('"')) {
          compositeField += ',' + field;
          cleanFields.add(compositeField.replaceAll('DBLQT','"'));
          makeCompositeField = false;
        } else if (makeCompositeField) {
          compositeField +=  ',' + field;
        } else {
          cleanFields.add(field.replaceAll('DBLQT','"'));
        }
      }

      allFields.add(cleanFields);
    }
    if (skipHeaders) allFields.remove(0);
    return allFields;
  }


  // Parse a Decimal and return a zero if un-parsable
  private static Decimal TryParse(String value) {
    try {
      return Decimal.valueOf(value);
    } catch(Exception ex) {
      return 0;
    }
  }


  // Bright Local report headers by index
  private static final Integer Search_Term    = 0;
  private static final Integer Search_Engine  = 1;
  private static final Integer Search_URL     = 2;
  private static final Integer Result_URL     = 3;
  private static final Integer Rank           = 4;
  private static final Integer Page           = 5;
  private static final Integer Type           = 6;
  private static final Integer Match          = 7;
  private static final Integer Directory      = 8;
  private static final Integer Last_Rank      = 9;


  // These rankings are used to calculate a final score.
  // They can be changed as needed, but should be ranged so that moving from
  // 1 -> 2 is much better than moving from 2 -> 3
  private static final Map<String, Integer> Rankings = new Map<String, Integer>
    { '1'  => 360
    , '2'  => 72
    , '3'  => 18
    , '4'  => 6
    , '5'  => 3
    , '6'  => 2
    , '7'  => 2
    , '8'  => 2
    , '9'  => 2
    , '10' => 2
    };
}
I am using the following code to update the states and see the error mentioned in the subject. As you can see there is no line 22; so why am I getting this error message? 
 
List<Contact> cts = new List<Contact>();

List<Contact> contacts=[SELECT Id, MailingState from Contact WHERE MailingState='---' LIMIT 1000];
for(Contact a: contacts){
    
    a.MailingState='';
    cts.add(a);
}

update cts;



 
Hello friend 

I need to count Multi select picklist selected items and how to read those item using trigger.
for count i have create formula filed that working fine, but i dont want to use formula filed.
my objective if we selected two item in a list  then  two case created with  subject name  and subject name is  item value .


trigger onandoffboardingticket on Case (before insert) {

             List<SelectOption> objNames = new List<SelectOption>();
            List<Case>newCace=new List<Case>();
            List<String> recordType=new List<String>{'zCampusHelp_Internal'};
                
             
            
               for(case c :trigger.new)
               {
                       
                       for(Integer i=1;i<=c.Count__c;i++)
                       {
                       
                           Case cas=new case();
                           cas.AccountId=c.AccountId;
                           cas.Subject=c.Subject;
                           cas.Onboarding_Offboarding_Employee__c=c.Onboarding_Offboarding_Employee__c;
                           cas.Status=c.Status; 
                        
                           cas.ContactId=c.ContactId;
                           cas.Internal_Category__c=c.Internal_Category__c;
                           cas.Internal_Type__c=c.Internal_Type__c;
                           cas.Internal_Item__c=c.Internal_Item__c;
                           newcace.add(cas);
                       }
                       }
               
    insert newcace;
}
I've made a trigger to automatically create a custom object "Qualification" record attached to the Opp. I recently update this to select the relevant Qualification Record Type based on Opp Record Type.

I'm trying to push the trigger to our production environment but i haven't ever created test classes before, i'm in the process of trying to learn but this has become a rush job to push the change set live now. Anyone able to help me out? Trigger code below:

trigger CreateQualification on Opportunity (after insert, before update) {

    List<Qualification__c> qualtoinsert = new List<Qualification__c>();

    for (Opportunity opp : Trigger.new) {

        // Create qualification record only when the Stage is Updated to "Attendance"
        if (opp.StageName == 'Attendance' && !opp.Qual_trigger__c ) {
            
            if (opp.RecordTypeId == '01220000000Mebg' || opp.RecordTypeId == '0120J000000B69P' || opp.RecordTypeId == '0122000000034yA'){
                
                Qualification__c qual = new Qualification__c();
                
                qual.RecordTypeId = '0127E00000070be';
                
                qual.Opportunity__c   = opp.id;           
                opp.Qual_Trigger__c = True;
                qualtoinsert.add(qual); // For Bulk processing of the Records.
                
            } //End if
            
            else {
                
                Qualification__c qual = new Qualification__c();
                
                qual.RecordTypeId = '0127E00000070bj';
                
                qual.Opportunity__c   = opp.id;           
                opp.Qual_Trigger__c = True;
                qualtoinsert.add(qual); // For Bulk processing of the Records.
                
            } //End else          
        } //End if
    } // End of For

    // Inserting the New Qualification Record.
    if ( !qualtoinsert.isEmpty()) {
        insert qualtoinsert;
    }
}

Many Thanks,
Steve.
Hi All How can i improve my code coverage .Now it is 65%
public class AddCostCenterController 
{
	Id targetid;
    public List<Cost_Center__c> cst {set;get;}
    public integer rno {set;get;}
    
    public AddCostCenterController(ApexPages.StandardController controller)
    {
        targetid =Apexpages.currentPage().getparameters().get('targetid');
        cst = new List<Cost_Center__c>();
        Cost_Center__c ct= new Cost_Center__c();
        ct.Target__c = targetid;
        cst.add(ct);
    }
    public pageReference save(){
        insert cst;
        pageReference ct = new PageReference('/'+targetid);
        return ct;
    
    }
    public void addRow()
    {
        cst.add(new Cost_Center__c(Target__c = targetid ));
        
    }
    public void delRow(){
        rno = integer.valueOf(Apexpages.currentPage().getParameters().get('index'));
        cst.remove(rno);
    }
}
 
@isTest
private class Ctr_AddCostCenters_Test
{
  static testMethod void Ctr_AddCostCenters(){
    test.startTest();
    
    
    
     Goal__c goal_Obj = new Goal__c(Name='Test',Flag__c = false,Financial_Year__c='2018-2019');
    Insert goal_Obj; 
      
    Cost_Center__c cost_center_Obj = new Cost_Center__c(Target__c = goal_Obj.id);
    Insert cost_center_Obj; 
    
    PageReference pageRef = Page.AddcostCenters;
    pageRef.getParameters().put('cost_center_Obj','test');
    pageRef.getParameters().put('index','test');
    Test.setCurrentPage(pageRef);
   ApexPages.StandardController sc = new ApexPages.StandardController(cost_center_Obj);
   AddCostCenterController obj01 = new AddCostCenterController(sc);  
   obj01.addRow();
   obj01.save();
   obj01.delRow();
    
    
              
      
  }
 
}

 
If I only know instance URL and the record id, may I combinate a like address to open the record editing page?

record editting page

When I open a editting page, the like looks like: https://na3.salesforce.com/0015000000szXbM/e?retURL=%2F0015000000szXbM. Besides the instance URL and record id, it still has a query param: retURL=%2F0015000000szXbM. What this query param?How can I get it?

Thanks
Charley
How to remove None option from drop down pick list
  • August 21, 2014
  • Like
  • 0

hi can any one tell me how can i bulky fy this trugger

 

when am inserting the opportunity through dat aloader am geeting error list has more than one row for assigne ment

 

this is my code

 


trigger Populating_CCY_Pair  on Opportunity (after insert,after update) {
List<opportunity> op=new List<opportunity>();
List<opportunity> opp=new List<opportunity>();
Set<id> accIds = new Set<Id>();
set<string> uniquerecords=new Set<string>();
string ccy_pair;
set<string> uniuqvalues=new set<String>();
op=[select id,name,Bought_CCY__c,CCY_Pair__c,Sold_CCY__c,accountid from opportunity where id=:trigger.new];

for(opportunity o:op)
{
if(o.accountid != null)
        {
            accIds.add(o.accountid);
        }
}
Account ac=[select id,name,CCY_Pairs_Traded__c from account where id=:accIds];
opp=[select id,name,Bought_CCY__c,CCY_Pair__c,Sold_CCY__c,accountid  from opportunity where accountid=:accIds];
ccy_pair='';
try{
for(Opportunity o1:opp)
{
if(!uniuqvalues.contains(o1.CCY_Pair__c.toUpperCase().trim()))
{
uniuqvalues.add(o1.CCY_Pair__c.toUpperCase().trim());
ccy_pair=ccy_pair+o1.CCY_Pair__c+';';
system.debug('uniuqvalues of valuews'+ccy_pair);
}

}
}catch(Exception e){system.debug('@@@'+e);}
//ac.CCY_Pairs_Traded__c=uniquerecords;
ac.CCY_Pairs_Traded__c=ccy_pair.toUpperCase().trim();

system.debug('account updated fields'+ac.CCY_Pairs_Traded__c);
update ac;
system.debug('account updated records'+ac);

}

 

 

am getting error an this line

 

Account ac=[select id,name,CCY_Pairs_Traded__c from account where id=:accIds];

 

My organization hired a consultant to do some customizations. One of the things they did was to write a trigger that runs after a gift is created or updated and to update fields on the associated contact's record. But, it is failing when I try to update more than 10ish records at a time, either via the data loader or via bulk update from lists. 

 

Can someone either: 

1 - Look at this code and tell me how I can update it so it can handle bulk updates, or 

2 - Tell me how to temporarily disable this trigger so I can update the records? 

 

Any help would be grately appreciated!!!!!

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 trigger updateGiftInformation on Opportunity (after update, after insert) {
  
  for(Opportunity o : Trigger.new){
         
         Decimal accountLargestAmount = 0.0;
         Decimal contactLargestAmount = 0.0;
         Integer accountCount = 0;
         Integer contactCount = 0;
         
         Account accountToUpdate = [select Id, Largest_Gift_Date__c, Last_Gift_Given__c, Largest_Gift_Given__c 
                         from Account
                         where Id = :o.AccountId];
      
      Contact contactToUpdate = [select Id, Largest_Gift_Date__c, Largest_Gift_Given__c, Last_Gift_Date__c,
                         Last_Gift_Given__c
                     from Contact
                     where Id = :o.Contact__c];    
      
      Opportunity[] contactOpps = [select CloseDate, Amount 
                           from Opportunity
                            where Contact__c = :o.Contact__c and
                            StageName = 'Posted'
                            order by CloseDate desc];
      
        
      if(o.AccountId != '0018000000U9G5W' || o.AccountId !=null){
         
                  
           Opportunity[] opps = [select CloseDate, Amount 
                        from Opportunity
                         where AccountId = :o.AccountId and
                         StageName = 'Posted'
                         order by CloseDate desc];
           
           for(Opportunity currOpp : opps){
             
             Decimal tempCurrency = currOpp.Amount;
             
             if(tempCurrency > accountLargestAmount){
               accountToUpdate.Largest_Gift_Date__c = currOpp.CloseDate;
               accountLargestAmount = tempCurrency;
             }
             
             if(accountCount == 0){
               accountToUpdate.Last_Gift_Given__c = currOpp.Amount;
               accountCount++;
             }             
               
           }
      }
         
         update accountToUpdate;
         
         for(Opportunity currOpp : contactOpps){
           
           Decimal tempCurrency = currOpp.Amount;
           
           if(tempCurrency > contactLargestAmount){
             contactToUpdate.Largest_Gift_Date__c = currOpp.CloseDate;
             contactToUpdate.Largest_Gift_Given__c = tempCurrency;
             contactLargestAmount = tempCurrency;
           }
           
           if(contactCount == 0){
             contactToUpdate.Last_Gift_Given__c = currOpp.Amount;
             contactToUpdate.Last_Gift_Date__c = currOpp.CloseDate;
             contactCount++;
           }
             
           
         }
         
         update contactToUpdate;
  }
}

HI experts,

 

There is deal custom object and opporunity standard i created one button name called convert in deal object so when user click on that deal objects what ever are there it has covert in to opportunity so my requriment is now only approved deal has to convert opportuntiy so give me idea on this pls.

 

 

I want to regularly send all account information from salesforce to another external system that will accept it as xml. I have the end point url for the external system and the fields that needs to be sent. 

How do I go about creating this? I assume I will have to schedule this to run daily at a particular time.

Please help.

 

Thanks.

Hello, well i have a request i have Contact that participate in one Event or More, now if the contact is already participatin i'm able to retreive his details in this participation and show them then modify if he wants to, but if he doesn't have a participation in any event  i can click on New button and Create new participation and my problem is when i click on Save it gives me an Error which is " Id not specified in an update call"

 

 

this is the methode for the New : 

public void NewRecord(){
isEdit=true;
related = new Related_Events_and_Reports__c();
}

and this is the methode for Save :


     public void save() {
        if (related == null ) {

              //means if it's new record insert it
              insert related;
      }
      try {

        else if (related != null ) {

// if the record already exist update it
      update related;
}

isEdit=false;

}catch(DmlException e){
ApexPages.addMessages(e);
}

 

now if i change in the if(related != null) TO  if(related.id != null){ update related; } it doesn't give me the Error but it doesn't insert in the Table

 

 

Any Help Please !!

  • May 29, 2013
  • Like
  • 0

Hi All,

   In opportunity Stage field when i select "closed won". then all the fields of closed won pageblocksection will be display in VF otherwise i select closed lost the pageblockselection will be hide. this  code is correct or wrong.im using PE

 

<apex:page standardController="Opportunity">
<script type="text/javascript">
function changetextbox()
{
var ele=document.getElementById('{!$Component.form1.block1.section1.populate}');
var opt=ele.options[ele.selectedIndex].text;
if (opt=='Closed Won')
{
var newEle=document.getElementById('{!$Component.form1.block1.section2}');
newEle.disabled=true;
}
else
{
var newEle=document.getElementById('{!$Component.form1.block1.section2}');
newEle.disabled=false;
}
}
</script>
<apex:form id="form1">
<apex:pageBlock id="block1">
<apex:outputPanel >
<apex:pageBlockSection id="section1">
<apex:inputField value="{!Opportunity.StageName}" id="populate" onchange="changetextbox();"/>
</apex:pageBlockSection>
<apex:pageblockSection id="section2>
<apex:inputField value="{!Opportunity.NextStep}" id="textpop" required="true"/>
</apex:pageblockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>

I have a requirement which says Account detail page should have border and all its Section Names and Related List names should be in Orange Colour.

I went throught the following but couldnt implement :-

http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_component.htm
http://www.salesforce.com/us/developer/docs/pages/Content/pages_comp_cust_elements_attributes.htm

This is what till now i have done :-

<apex:page standardController="Account" tabStyle="Accounts__tab">
<apex:pageBlock >
<apex:pageBlockSection >
<TABLE BORDERCOLOR="RED" width="195%">
<tr>
<apex:detail relatedList="false"/>
</tr>
</TABLE>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

 

The problem in the Above is:-
1.Section Names are not Visible.
2.Related lists should be available outside account detail.
3.Names of Section and Related list needs to be Orange in colour.


Please Kindly Help and Guide...:(

Howdy Folks!  I am trying to write a trigger that will work like a roll up summary field.  I have to run this through a trigger as I cannot create a master detail relationship with a managed custom object.  This is using docusign.

 

The use case is this.  When a doc is marked as completed in the custom object Docusign status (dsfs__DocuSign_Status__c).  I need to get a count of items either completed or Denied and use that data to manage the Opportunity stage.

 

If status =complete, stage = Closed Won

if Status=Denied, Stage = Closed Lost

 

Has anyone run into this issue?!  I cannot believe I am the first one to need this automation.  Thanks folks!

Hi, I have an outputlink, and I would like to implement the function that everytime when the link is clicked, then it always opens the redirect visualforce page in the same window or tab. The problem is that the redirect link is not static one like google.dk, it should has paramete cus which defines a specific customer.

 

I have tried to use window.open(url, target) like the following, but it doesn't work.

<apex:outputLink onlick="window.open('/apex/XX?

&cus={!account.Customer_No__c}', 'sametab')" target="sametab" styleClass="viewLink">click me< /apex:outputLink>

 

I hope you can help me. Thanks in advance.

Hi,

This is veeraiah.i have one question

 

in my application i have some visual force pages ,i have a custom object and also i have main controller .now my questio is i want to insert th visualforce pages which i create or i have ino the custom object  as a link from the controller.i should insert that page through the main controller and if we click the page inserted in the custom object then  need to see the no of queries(queries count ) in the object .

  

pls anybody help me on this

 

 

Thanks,

veeraiah

I'm not seeing any clear way to handle user clicks on the elements of an apex:chart.  Is there such a way that I'm missing?  Is anyone aware of JS events that are thrown by the chart based on user interaction?

 

Otherwise I guess it's over to jqPlot or Google Charts.  *sigh*.