• Coco_Sdyney
  • NEWBIE
  • 305 Points
  • Member since 2012

  • Chatter
    Feed
  • 11
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 56
    Replies
Hi as title indicates i'm trying to make a condition that if 2 specific fields = blank or Null for a flag to appear.

Here is formula i've managed so far, but seems i have an error, as blank or not it returns green flag.

if(ISNULL(Account__r.Banking_Username__c + Account__r.Banking_Password__c  ) , IMAGE("/img/samples/flag_red.gif", "red"), IMAGE("/img/samples/flag_green.gif", "green"))

If someone could help me with Syntax I would greatly appreciate it

thx
  • March 06, 2014
  • Like
  • 0
We have a custom object that requires a record type to be selected.  Before the administrator created the different record types the custom table id was captured in the Sandbox. I was too late when they went to production and now I cannot figure out how to get the full ID of the custom table.  I do not need the ID of a specific record or the 3 digit prefix of the object.  I need the full ID of the custom object.

For instance the URL the works in the Sandbox contains the full table Id after the value or "ent=XXxXXXXXXXXXxxx'  This process then calls a visual force page that calls a class and prepopulates the custom object.

Example.
var TheURL = "setup/ui/recordtypeselect.jsp?ent=01I500000007Qqe&retURL=/{!Opportunity.Id}&save_new_url=%2Fapex%2FcreateProjectFromOpportunity%3Fid={!Opportunity.Id}";

Could someone please explain to me how to get the full id of the custom object?  I cannot use the 3 digit prefix of the object and cannot use the name of the custom object in place of ent=01I500000007Qqe like ent=CustomObject__c.

Thanks.

I've been trying to find a solution for this all over with no luck. I'm trying to create a GoToMeeting meeting from Salesforce through the GoToMeeting API. I'm not too familiar with APIs in general.

 

I get the error:

Argument cannot be null. Error is in expression '{!createMeeting}' in component <apex:page> in page gotomeetingapi

 

This is what I have on my Page:

 

<apex:page controller="GoToMeetingAPI">
    <apex:form id="newmeetings">
    	<script type="text/javascript">
	function addMeeting() {
		makeMeeting(
			document.getElementById("subject").value,
			document.getElementById("starttime").value,
			document.getElementById("endtime").value,
			document.getElementById("conferencecallinfo").value,
			document.getElementById("meetingtype").value
			);
		}
	</script> 
    	<apex:actionFunction name="makeMeeting" action="{!createMeeting}">
		<apex:param name="subject" value="t" />
		<apex:param name="starttime" value="" />
		<apex:param name="endtime" value="" />
		<apex:param name="conferencecallinfo" value="" />
		<apex:param name="meetingtype" value="" />
	</apex:actionFunction>
    	subject<input type="text" id="subject"/><br />
    	starttime<input type="text" id="starttime"/><br />
    	endtime<input type="text" id="endtime"/><br />
    	conferencecallinfo<input type="text" id="conferencecallinfo"/><br />
    	meetingtype<input type="text" id="meetingtype"/><br />
    	<button type="button" onclick="addMeeting()">Submit</button>
    </apex:form>
</apex:page

 

This what I have for my class:

 

public class GoToMeetingAPI {
	public PageReference createMeeting() {
		String subject = Apexpages.currentPage().getParameters().get('subject');
		String starttime = Apexpages.currentPage().getParameters().get('starttime');
		String endtime = Apexpages.currentPage().getParameters().get('endtime');
		String conferencecallinfo = Apexpages.currentPage().getParameters().get('conferencecallinfo');
		String meetingtype = Apexpages.currentPage().getParameters().get('meetingtype');
		Http httpProtocol = new Http();
		HttpRequest request = new HttpRequest();
		HttpResponse response = new HttpResponse();
		request.setEndpoint('https://api.citrixonline.com/G2M/rest/meetings');
		request.setMethod('POST');
		request.setBody('subject='+EncodingUtil.urlEncode(subject,'UTF-8')+
						'&starttime='+EncodingUtil.urlEncode(starttime,'UTF-8')+
						'&endtime='+EncodingUtil.urlEncode(endtime,'UTF-8')+
						'&passwordrequired=false'+
						'&conferencecallinfo='+EncodingUtil.urlEncode(conferencecallinfo,'UTF-8')+
						'&timezonekey=""'+
						'&meetingtype='+EncodingUtil.urlEncode(meetingtype,'UTF-8'));
		request.setHeader('Authorization','OAuth oauth_token=123456789');
		request.setCompressed(true);
		try {
            response = httpProtocol.send(request);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug(response.toString());
        }
        return null;
	}
}

 I apologize for the names of my function names... I've been getting frustrated and all I need to do is show that it works.

 

The GET request was so much easier!

 

If anyone knows what I'm missing I'd be very appreciative.

Hi ,

 

We have a visual force page for adding the products for an opportunity where 

<apex:page standardController="OpportunityLineItem" extensions="ProductExtensionController" id="pg" tabStyle="Opportunity" showHeader="true">
<style type="text/css">
.longText { width:100px; }
</style>

    <apex:form id="frm">
    <!--Displays Error messages.--->
        <apex:pagemessages />
        <apex:pageBlock id="pgBlock0">
            <!--Display page to add products to oppurtunity from Cloud User Pricebook.--->
            <apex:pageBlockSection id="pgBlock1">
                <apex:pageBlockTable value="{!CloudProducts}" var="pro1">
                    <apex:column >
                        <apex:facet name="header">Product Name</apex:facet>
                        <apex:outputText styleClass="longText" value="{!pro1.prodWrapper .Name}">&nbsp;&nbsp;</apex:outputText>
                    </apex:column>            
                    <apex:column >  
                        <apex:facet name="header">Quantity/Term</apex:facet>

                            <apex:inputField value="{!pro1.oli.Quantity}" required="true"/>&nbsp;&nbsp;
                        
                    </apex:column>    
                    <apex:column >  
                        <apex:facet name="header">No.of Users</apex:facet>
                           <apex:inputField value="{!pro1.oli.No_of_Users__c}" required="true"/>&nbsp;&nbsp;
                       </apex:column>
                    <apex:column >  
                        <apex:facet name="header">Price per user/month</apex:facet>
                        


<apex:inputField value="{!pro1.oli.Price_per_user_month__c}" required="true"/>&nbsp;&nbsp;
       
                    </apex:column>  
                    <apex:column >  
                        <apex:facet name="header">Revenue Type</apex:facet>
                        <apex:inputField value="{!pro1.oli.Revenue_Type__c}" required="true"/>&nbsp;&nbsp;
                    </apex:column>                    
<apex:column >
                        <apex:facet name="header">Product Type</apex:facet>
                        <apex:inputField value="{!pro1.oli.Product_Type__c}" required="true" />&nbsp;&nbsp;   
                                    
</apex:column>           
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            <!--Display navigation buttons--->
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Save&More" action="{!saveMore}"/>
                <apex:commandButton value="Cancel" action="{!Cancel}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 we want to display the helptext for the field "Product_Type__c" in the page, can someone help me how can we do this. I see some solutions saying to display as below:

<apex:pageBlockSectionItem helpText="{!$ObjectType.OpportunityLineItem.Fields.Product_Type__c.inlineHelpText}"/>

but not able to use this anywhere wherever i use i get the blank message whith no content.

 

Regards,

Krishna.

Hello,

 

In my visualforce page I have the following line for displaying the day/month/year from a datetime field

 

{!DAY(DATEVALUE(quoteItem.Quoted_Date__c))}/{!MONTH(DATEVALUE(quoteItem.Quoted_Date__c))}/{!YEAR(DATEVALUE(quoteItem.Quoted_Date__c))}

 

if my day is the 3rd  (i.e. 3), 4th etc (any single character less than 10)  I wish to display 2 characters (i.e. a "0" before the day) on my page.   SImilarly for months.

 

Does anyone know of the best way to do this?

 

Thanks in advance!

I've been trying and trying to get this code to work and it seems that no matter which way I format it I keep getting errors regarding pulling the contact ID via the contact role.  Just for background when a quote is sent I'm trying to create a course for each Contact in the associated opportunity contact roles section.  Here's what I have that gives me the least amount of errors but still tells me I can't associate the Contact ID that way.

 

If anyone could help I would appreciate it very much.

Thank you,

Amanda

 

trigger QuoteAdoptionAgreementSentCreateCourses on Quote (after update) {
   // map tracks records on OpportunityID

    Map<String, Quote> QuotetoOpportunityIDMap = new Map<String, Quote>();

    for( Quote record : Trigger.new )
    {
        if( record.Adoption_Agreement_Sent__c == date.today())

        {
              QuotetoOpportunityIDMap.put( record.OpportunityID, record );            
        }
        
    }

 //map to keep track of the opportunity contact roles
    map<Id, OpportunityContactRole> OppIDtoContactRolesMap = new map<Id, OpportunityContactRole>();

    List<Contact> AllContacts = new List<Contact>();

    //select OpportunityContactRoles for the opportunities with contact role required

    List<OpportunityContactRole> CourseContacts = [select OpportunityID, ContactID from OpportunityContactRole where OpportunityID in :QuotetoOpportunityIDMap.keySet() ];


    for (OpportunityContactRole ocr : CourseContacts) {
        //puts the contact roles in the map with the Opportunity ID as the key
        OppIDtoContactRolesMap.put(ocr.ContactId,ocr);
    }          
List<Course__c> Course = new List<Course__c>();
    for (Quote record: Trigger.New)
         if( record.Adoption_Agreement_Sent__c == date.today())
{

Course.add (new Course__c(
                     Contact__c =  [Select Id From Contact Where ID IN : OppIDtoContactRolesMap.keySet()],
                     Adoption_Agreement__c = record.Id,
                     Opportunity__c = record.OpportunityID));
         }
   insert course;
 }

I am in need of help with a Test class for my trigger. I'm getting zero test code coverage, because I am an absolute newbie at Apex. 

 

My first question is, do you recommend reading the entire documentation online, or are there any decent books out there regarding Apex code?

 

My second question is, How can I increase my code coverage on the test class below?

 

This is the trigger: 

trigger UpdateContactLeadSource on Opportunity (before update) {
    /*  delete this first part of code and in the query instead of ":oppsToFill" bind to ":trigger.new" or
        ":trigger.newMap.keyset()".
    */
    Set<Id> oppsToFill = new Set<Id>();
    
    for(Opportunity o : trigger.new){
        if(o.LeadSource <> null) {
           oppsToFill.add(o.Id);
      }
    }

    // Now we'll select all possible contacts wasting only 1 query.
    if(!oppsToFill.isEmpty()){
        List<OpportunityContactRole> roles = [SELECT OpportunityId, Contact.Name, Contact.LeadSource
            FROM OpportunityContactRole
            WHERE isPrimary = true AND Contact.LeadSource != null AND OpportunityId IN :oppsToFill];

        if(!roles.isEmpty()){
            for(OpportunityContactRole ocr : roles){
                Opportunity oppToBeFilled = trigger.newMap.get(ocr.OpportunityId);
                System.debug('Changing lead source on ' + oppToBeFilled.Name + ' from ' + oppToBeFilled.LeadSource + ' to ' + ocr.Contact.LeadSource + ' (thx to ' + ocr.Contact.Name + ' being the Primary Contact).');
                oppToBeFilled.LeadSource = ocr.Contact.LeadSource;
            }
        }
    }
   
    // NEEDS TO INCLUDE IF STATEMENT IN CASE NO PRIMARY CONTACT IS LISTED
}

 

This is the Test Class I have so far 

@isTest (SeeAllData = true) 
public with sharing class TestPrimaryContactLeadSrc {

 static testMethod void TestPrimaryContactLeadSrc() 
      {  
       		   Set<Id> oppsToFill = new Set<Id>();
       		   Contact newContact = new Contact( lastname= 'Testerson',
                                        LeadSource = 'Cold Call'
                                       // WhatId = newOpp.id 
                                        );                
                insert newContact;
       		
       		
               Opportunity o = new Opportunity (Name = 'testopp',
               										Set_up_Fee__c = 10, 
               										Term__c = 1,
               										CARR__c = 1,
               										StageName = 'Meeting',
               										ForecastCategoryName = 'Pipeline',
               										CloseDate = date.today(),
               										Type = 'Upsell',
               										LeadSource = 'Sales'
               										//WhatId = Contact.Id
               										);
               									
               insert o;
               
               
               OpportunityContactRole ocr=new OpportunityContactRole(Role='Decision Maker',OpportunityId=o.Id,ContactId=NewContact.Id,Isprimary=true);
     insert ocr;
               
               
                Task newTask = new Task(Description = 'Survey Transaction',
                                        Priority = 'Normal', 
                                        Status = 'Inbound Email', 
                                        Subject = 'Other', 
                                        IsReminderSet = true, 
                                        ReminderDateTime = System.now()+1,
                                        WhatId = o.id 
                                        );                
                insert newTask;
                

                
    }
    
}

 

Hi there,

 

New to this.

 

Trying a (what probably is so simple) IF statement in a VF email template where I want an output "He" or "She" depending on the a Gender field in a related lookup record.

 

Here is my code which keeps returning a syntax error;

 

<apex:outputText value="{!IF ({!relatedTo.Custom_Contact__r.Gender__c} =='Male', 'He', 'She')}"></apex:outputText>

 

Thank you in advance!

 

 

regards,

 

Al

  • December 09, 2012
  • Like
  • 0

do you use the original field name: example Account or renamed Household when writing Apex code.

using '' try catch'' i want to display the error message from the catch(exception e) code on to the layout when trigger gets fired.

 

How to show the error message on layout??

  • November 27, 2012
  • Like
  • 0

This VisualForce page shows the account details for an account using an apex:detail object:

 

<apex:page standardController="Account">
          <apex:detail relatedList="false"/>
</apex:page>

 

Does anyone know why this page would show an error when you call it with an invalid account id in the url?  The error is:

 

Insufficient Privileges

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.

 

The page works properly when you call it with an valid account id in the url.  I gave all roles permissions to view the page in the security definitions for the page, and I'm the admin in this developer account.

 

When other pages with a standard controller are called with an invalid account id, they return the VisualForce error:

 

Visualforce Error
Id value 001U0000005W2cu1 is not valid for the Account standard controller

 

Hi,

 

I am made a button on contact page to open a VF page in new window, and wish to refresh the contact page when I click Submit in the VF page.

 

My VF page contains iframe, so I write javascript as below 

 

function refreshparent()

{

top.window.opener.location.href= '/' + id;

}

 

on button:

<apex:commandButton action="{!Submit}" value="Submit" onComplete="refreshparent('{!Contact.Id}')"/> 

 

This works find in Firefox, but not working in IE neither Google Chrome, any one has ideas to help me?

 

Thank you very much!!!

i have 50000 records, and in all the 50000 records there is a field called status, my req is, i want to change the status field that will happen to all 50000 records at a time ? how can i achieve this? any suggestions on this?
我们公司的客户在我们自己的网站上注册了,用户信息如何关联到force中
 I have a scheduled daily task in Informatica which queries data from Salesforce to SQL. This task has been working fine but has been failing in the past few days. There were no changes made on this task recently. Below is a screenshot from the activity log with the error message:

User-added image

I've read a few discussions about this error and most of them would say that it is Salesforce-related. Any ideas on how to get rid of this error?
Hi,
I'm trying to pass a picklist value into a url, whcih then links to a report which is filtered based on that value. However, I'm getting an error when trying to save the VF page, which says Error: Unsupported attribute action in <apex:outputLink> in Special_Reports at line 10 column 75

VF Page Code:

<apex:page controller="dynamicpicklist" >
    <apex:form >
    <apex:sectionHeader title="Dynamic Picklist" subtitle="Reusable code"/>
        <apex:pageblock >
            <apex:pageBlockSection title="Dynamic picklist" columns="1">
                <apex:outputlabel value="Pollinator" for="values" />
                <apex:selectList value="{!pollinator}" size="1" id="values">
                    <apex:selectOptions value="{!pollinatornames}"/>
                </apex:selectList>
                <apex:outputLink id="link" action="{!processLinkClick}">Process Report</apex:outputLink>                                          
            </apex:pageblocksection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Class:

public class dynamicpicklist
{
    public String pollinator{get; set;}

    public List<SelectOption> getpollinatornames()
        {
          List<SelectOption> options = new List<SelectOption>();
          List<User> pollinatorlist = new List<User>();
          pollinatorlist = [Select Id, Name FROM User ];
          options.add(new SelectOption('--None--','--None--'));
          for (User users : [SELECT Id, Name FROM User WHERE Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC])
              {
                  options.add(new selectOption(users.Id, users.Name));
              }
      return options;
        }
    public string pollinatorurl{get;set;}
        public PageReference processLinkClick() {
        return new PageReference('/00O90000005uwmQ?pv1='+pollinatorurl);
    }
}
  • March 24, 2014
  • Like
  • 0
I want to write a workflow rule which will update a field if any of three checkbox is changed from blank to true . I tried ISchanged . It is giving me error . Any suggestions ?
I am trying to get a Javascript button to work - it is working when it comes up updating the lead fields however the task is not being created and the page is not being reloaded.  Any ideas where I am going wrong?

{!REQUIRESCRIPT('/soap/ajax/28.0/connection.js')}

var lead = new sforce.SObject('Lead');
lead.id ='{!Lead.Id}';
lead.strike__c = '1';
lead.status = 'Contact Not Made'
lead.Lead_Status_Details__c = 'Called LM & Emailed'

try{
var result = sforce.connection.update([lead]);

var task = new sforce.SObject('Task');
task.RecordTypeId = '012D0000000B9be';
task.OwnerId = '{!User.Id}';
task.Subject = 'No Connect';
task.Description = 'Left Message and Sent Email';
task.WhatId = '{!Lead.Id}';
task.Type = 'No Connect';
task.ActivityDate = new Date();
task.Status = 'Completed';

var resultTask = sforce.connection.create([task]);

if(resultTask[0].success=='true' && resultLead[0].success=='true'){
alert('The Lead has been Updated Successfully and the Task was Created.');
location.reload();
}
}
catch(e){
alert('An Error has Occured. Error: ' + e);
}
Hello. Very new to APEX so be kind :)

I have a rather simple trigger which evaluates Applications (children of Contact) Depending on some specific logic I want to update the Contact. I will have multuple Applciations for the same Contact so I put them in a Set. The last one added should be the only one persisted as I am adding to a Set. However, I get System.ListException when here:

List<Contact> toUpdate = new List<Contact>();
        toUpdate.addAll(student);              // add SET to LIST
     
        update toUpdate;                          //this operation throws: System.ListException: Duplicate id in list

Here is whole trigger.

Thanks,
Jon

trigger studentStage on TargetX_SRMb__Application__c (before insert, before update) {

Set<Contact> student = new Set<Contact>();

for (TargetX_SRMb__Application__c app : trigger.new) {

  if ( app.TargetX_SRMb__Level__c != null && app.TargetX_SRMb__Level__c.equals('Undergraduate')){
     try{
   
      if (      String.IsBlank(app.TargetX_SRMb__Application_Decision__c) ||
                app.TargetX_SRMb__Application_Decision__c.length() == 0 ||
                app.TargetX_SRMb__Application_Decision__c.equals('Cancelled Implied') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Waitlist') ||              
                app.TargetX_SRMb__Application_Decision__c.equals('Cancelled before offer') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Denied') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Conditional status') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Accepted to ELA program') ) {
                         
         student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Applicant' ));
  
      }else if (app.TargetX_SRMb__Application_Decision__c.equals('Accepted') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Cancelled after order') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Deferral') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Accepted to EOP program') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Waitlist admit'))  {
         student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Admitted' ));
    
      }else if (app.TargetX_SRMb__Application_Decision__c.equals('Confirmed') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Confirmed 2') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Cancelled after confirmed'))  {
         student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Confirmed' )); 
           
      }else if (app.TargetX_SRMb__Contact__r.TargetX_SRMb__Anticipated_Start_Term__c == null) {
    
   
      }
    
      }catch(NullpointerException ne){
         student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Applicant' ));
       //   studentList.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Applicant' ));
      }catch(ListException le) {
      }
   

    }else if (app.TargetX_SRMb__Level__c.equals('Graduate') || app.TargetX_SRMb__Level__c.equals('Doctoral') ){

System.debug('student is graduate' + app.TargetX_SRMb__Level__c+ ' '+ app.TargetX_SRMb__Application_Decision__c);


 
     try{
   

   
       if (     String.IsBlank(app.TargetX_SRMb__Application_Decision__c) ||
                app.TargetX_SRMb__Application_Decision__c.length() == 0 ||
                app.TargetX_SRMb__Application_Decision__c.equals('Cancelled Implied') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Denied') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Conditional status') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Accepted ELA program')
                 ) {


System.debug('adding to list '+app.TargetX_SRMb__Application_Decision__c);
   
         student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Applicant' )); 

      }else if (app.TargetX_SRMb__Application_Decision__c.equals('Accepted') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Cancelled after offer') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Conditional status') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Deferral') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Accepted EOP offer') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Waitlist admit') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Accepted EOP program')  )  {
         student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Admitted' ));
      
        System.debug('adding to list '+app.TargetX_SRMb__Application_Decision__c);
     }else if (app.TargetX_SRMb__Application_Decision__c.equals('Confirmed') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Confirmed 2') ||
                app.TargetX_SRMb__Application_Decision__c.equals('Cancelled after confirmed'))  {
         student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Confirmed' ));
  
      }else if (app.TargetX_SRMb__Contact__r.TargetX_SRMb__Anticipated_Start_Term__c == null){
      //   student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Inquiry' ));
      }  
   
 
   
     }catch(NullpointerException ne){
        student.add(new Contact(Id = app.TargetX_SRMb__Contact__c, TargetX_SRMb__Status__c = 'Applicant' ));

     }catch(ListException le) {
     
     }
  
   
     }


    
    }// end for loop
  

    if(!student.isEmpty()){
  
    try{

    
        List<Contact> toUpdate = new List<Contact>();
        toUpdate.addAll(student);              // add set to list
          System.debug('update contacts');
        update toUpdate;                          //this operation throws: System.ListException: Duplicate id in list
          System.debug('after update');

    }catch(ListException le) {
      System.debug('error : '+le);
    }
    }




}
As I am not an Apex guy, I need some help. I have this trigger that I inheritied, but it only works for US zip code. I need to eithr modify it or add another trigger that will work for Canadian zip codes. We have a custom object called zip code table that lists all Us zip code by 5 digit, but canadian zip codes by first 3 digits (that is where this breaks down, I bleieve) 

Can anyone assist>
trigger UpdateZipCode on Account (before insert, before update) {
  list<string> zipcodeList = new List<string>();

  string zipCode;
 
  for (integer i = 0; i <trigger.new.size(); i++) {
    zipcode = trigger.new[i].billingpostalCode;
    system.debug('ZipCode: ' + zipcode);
   
    if (zipcode != null) {
      integer index = zipcode.indexof('-',0);
   
      if (index != -1) {
      zipcode = zipcode.substring(0, index);
      }
      system.debug('ZipCode after the filter: ' + zipcode);
      zipcodeList.add(zipCode);
    }
  }
  system.debug('zipcode size: ' + zipcodelist.size());

    if (zipcodelist.size() > 0) {
      List<Zip_Code_Table__c> zipCodeTableList = [Select id, name from Zip_Code_Table__c where name in :zipcodeList];
    system.debug('Data returned by zipcodeTable : ' + zipCodeTableList.size());
   
   
    if (zipCodeTableList.size() > 0) {
      //Add the zip code into a map
      map<string, id> mapZipName= new map<string, id>();
    for (integer i=0; i<zipcodeTableList.size(); i++) {
      mapZipName.put(zipcodeTableList[i].name, zipcodeTableList[i].id);
    }
         
      //There is possibility that the number of zipcode from account is more than the zipcodeid return from zipcode table
      id zipcodeid;
      for (integer i = 0; i <trigger.new.size(); i++) {
      zipcode = trigger.new[i].billingpostalCode;
      if (zipcode != null) {
        integer index = zipcode.indexof('-',0);
     
        if (index != -1) {
        zipcode = zipcode.substring(0, index);
        }
       
        zipcodeid = mapZipName.get(zipcode);
        system.debug('zipcodeid: ' + zipcodeid);
        Trigger.new[i].Zip_Code__c = zipcodeid;
      }
      }
    }
    }
}
Hi as title indicates i'm trying to make a condition that if 2 specific fields = blank or Null for a flag to appear.

Here is formula i've managed so far, but seems i have an error, as blank or not it returns green flag.

if(ISNULL(Account__r.Banking_Username__c + Account__r.Banking_Password__c  ) , IMAGE("/img/samples/flag_red.gif", "red"), IMAGE("/img/samples/flag_green.gif", "green"))

If someone could help me with Syntax I would greatly appreciate it

thx
  • March 06, 2014
  • Like
  • 0