• mxalix258
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 39
    Replies

I'm trying to create a very simple visualforce form, that just doesn't seem to be working and I don't know why

 

VF:

<apex:page controller="SubmitReferralController" standardStylesheets="false" showHeader="false" sidebar="false">
    <apex:stylesheet value="{!$Resource.semantic}"/>
<html lang="en">
<head>
</head>
<body>
<div style="margin-left:200px">    
<h1>Referrals Fee Program</h1>
<p>
  Any questions? Contact the <a href="semantic-form.css">Referral team</a>.
</p>
</div>
<apex:form styleClass="semantic"> 
<apex:pageBlock >
<div style="margin-left:200px">
<apex:outputPanel >
    <div>
      <apex:outputlabel Value="First Name"></apex:outputlabel>
      <apex:inputText value="{!c.FirstName}" size="30" id="referrer_first_name"/>
      <apex:outputlabel Value="Last Name"></apex:outputlabel>
      <apex:inputText value="{!c.LastName}" size="30" id="referrer_last_name"/>
     </div>
<div style="margin-left:200px">
<apex:commandButton value="Submit Referral" action="{!submitReferral}"/>
</div>
</apex:outputPanel>
</div>
</apex:pageBlock>
</apex:form>         
</body>
</html>
</apex:page>

 Controller:

public class SubmitReferralController {
    
    public Contact c { get; set; }
    
    public PageReference submitReferral(){
        try {
        insert c;
       }
       catch(System.DMLException e) {
           ApexPages.addMessages(e);
       return null;
       }
       return null;
     }
}

 

I'm sure it's something really stupid, but I just can't sort it out.

 

Any help would be greatly appreciated!

I'm trying to create a trigger on attachments, so that when an attachment is added to a Task, and the Task is related to an opportunity, the attachment will be cloned onto the Opportunity.

 

Below is the code I have so far, but I can only get it to work if I remove the if(a.parentid == t.id) before creating the new attachment. Any thoughts?

 

trigger CloneOppTask on Attachment (after insert, after update) {

    Attachment[] insertAttList = new Attachment[]{};
    Set<ID> taskset = new Set<ID>();
    List<Attachment> attlist = [Select Id, parentId, name, body from Attachment where Parent.Type='Task' AND Id in :Trigger.new];

        for(Attachment a : attlist){
            taskset.add(a.parentId);
            }
            
        for(Task t: [Select ID, WhatId From Task Where WhatID in :taskset]){
            for(Attachment a: attlist){
                if(a.parentid == t.id){
                    Attachment att = new Attachment(name = a.name, body = a.body, parentid = t.WhatId);
                    
                    insertAttList.add(att);
                }
            }
        }
        if(insertAttList.size() > 0){
            insert insertAttList;
        }
}

 

I've created a trigger on Contact that will roll-up opportunities into given fields. These fields are seperated by FY and other criteria that aren't doable by a formula or roll-up summary.

 

The problem is, the information only updates when opportunities related to that given contact are updated. For example, if an opportunity is entered it will calculated the $ amount in the "Current FY" field, but if no further updates happen, that field will remain populated.

 

My thought was to create a scheduled batch apex job to happen each fiscal year to reconcile the information - is this the best way to do this?

 

Here is the code that I have so far:

 

global class scheduledMonthly implements Schedulable {

    public static String CRON_EXP = '0 0 0 21 AUG ? *';
 
    global static String scheduleIt() {
        scheduledMonthly sm = new scheduledMonthly();
        return System.schedule('Monthly Reconciliation', CRON_EXP, sm);
    }
 
    global void execute(SchedulableContext sc) {
    
    ExampleBatchClass ebc = new ExampleBatchClass();
    Database.executeBatch(ebc);

    }
}

 

global class ExampleBatchClass implements Database.Batchable<sObject>{

    String query;

    global ExampleBatchClass(){
    // Batch Constructor
    }

    // Start Method
    global Database.QueryLocator start(Database.BatchableContext BC){
        query = 'select id from contact';
        return Database.getQueryLocator(query);
    }

    // Execute Logic
    global void execute(Database.BatchableContext BC, List<sObject> scope){

        List<Contact> conlist = (List<Contact>)scope;
        List<Contact> contoupdate = new List<Contact>();
                //Get all contacts
                for (Contact con : conlist){
                    //execute logic inside for loop

                    contoupdate.add(con);
                }
        database.update(contoupdate);         
    }

    global void finish(Database.BatchableContext BC){
        // Logic to be Executed at finish
    }
}

 Does this seem like the best way to go about this? Thank you!

trigger accountTestTrggr on Account (before insert, before update) {

  List<Account> accountsWithContacts = [select id, name, (select id, salutation, description, 
                                                                firstname, lastname, email from Contacts) 
                                                                from Account where Id IN :Trigger.newMap.keySet()];
	  
  List<Contact> contactsToUpdate = new List<Contact>{};

  for(Account a: accountsWithContacts){

     for(Contact c: a.Contacts){
   	  c.Description=c.salutation + ' ' + c.firstName + ' ' + c.lastname; 

   	  contactsToUpdate.add(c);
     }    	  
   }
      
   update contactsToUpdate;
}

 

Taking this fairly simple code, how can I take the contacts from the second for loop, and either find the contact that was created most recently, or create a list and sort by created date? The trick is that it will have to be specific to the parent, so most recent contact, for each account record.

 

I'm not sure how to go about this, any thoughts?

 

Thank you!

What's the best way to have product images (that are hosted in Salesforce) be displayed in a gallery format on a sites page? Does anyone have recommendations?

 

Thanks!

If I wanted to run a online store out of Salesforce, and I had a "product" object and attached images in the "notes and attachments" section....is it possible to have those images display externally? If so, what would the best way to go about that be?

 

Thank you!

If I want to have a trigger on a record in one object, that updates a record in another object, how can I accomplish this without having  a SOQL query inside a for loop? We are going to want to map a couple fields back to the other record, so I'm not sure the most efficient way to do this. I was thinking something like this:

 

trigger ContactUpdater on Custom_Object_Name__c (after update) {

 List<Contact> Contactlist = new List<Contact>();
 List<Contact> updatedContacts = new List<Contact>();

 for(Custom_Object_Name__c p : trigger.new){

        If(p.Associated_Contact__c != Null){ 
          Contactlist.add(p.Associated_Contact__c);

          }

	for(Contact c : [SELECT Id FROM Contact WHERE Id IN :Contactlist]){
             c.FieldToUpdate = p.FieldValue;

             updatedContacts.add(c);
          }

         update updatedContacts; 

    }

 

Is there anything inherently wrong with how this is coded?

 

Hi,

 

I am running into a bit of an issue with an apex trigger. Inside the apex class that gets called from the trigger, I filter on some of the records I want to work with like so:

 

for (Object__c ob : recordsFromTrigger){
        if (ob.picklist__c== 'X Summer 2013' || ob.picklist__c == 'X Fall 2013' etc etc){
Do something here;
        }

 

But in this case, one of the criteria will change pretty frequently. It is a picklist on the object that will be constantly updated depending on the time of year. For example 'X Summer 2013' 'X Fall 2013'. How do I go about filtering on if that field INCLUDES 'X' and ignores the date portion? Is this possible someway? I'm just wary of hardcoding the individual picklists in and think it will require a lot of maintenance that will be forgotten.

 

thank you!

 

 

If I have a trigger, is there any benefit to only passing the records that I want to be processed? For example, if i want a trigger list to be passed to an apex class....should I filter the selected records inititally in the trigger? In the case shown below, when it gets to the "trigger.new" does it pass ALL the records that are in the list? or only the ones that fit the criteria of objectc.field='x'?

 

ApexClass ac = new ApexClass ();

if (objectc.field = 'x'){
ac.acMethod(Trigger.new);

}

I'm trying to write a test class for a trigger that performs a new record insertion. The trigger is before update, and will insert a record on an associate object. When writing the test class, I am getting this error:

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateOnboardingRecord: execution of BeforeUpdate

caused by: System.DmlException: Insert failed. First exception on row 0 with id 00Tc0000004Q0dqEAC; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

Class.CreateOnboardingFromApplication.createOnboard: line 121, column 1
Trigger.CreateOnboardingRecord: line 7, column 1: []

 

 Any idea where I may be going wrong?

 

Thanks!

So, if I have seperate apex classes that have the same method names and I invoke the method name from the button on a visualforce page, how does it know which apex class to invoke from?

 

In addition, is it possible to have it invoke the method from the wrong class?

 

Thanks!

I cannot figure out why I am receiving this null pointer exception on line 23. I thought it would be similar to this article: http://cloudnow.wordpress.com/2011/04/04/apex-bloopers-why-art-thou-null/ but the code seems correct to me. The code works when creating single records in the database, but when i try to bulk upload, it fails with the null pointer exception. Any ideas?

 

trigger kiprolerequestTrigger on Application__c (after insert) 
{
    Set<Id> KIPCanIds = new Set<Id>();

    Map<Id, KIP_Candidates__c> kipportalcan = new Map<Id, KIP_Candidates__c>();

    for (Application__c app : Trigger.new) 
    {
       if (app.RecordTypeId == '012C0000000Bhsr' && app.Program__c == 'KIP Summer 2013'){
        KIPcanIds.add(app.Contact__c);
    }
    }
    if(KIPcanIds.size() > 0)
    {
        for(KIP_Candidates__c kippc : [SELECT Id, Associated_Contact__c FROM  KIP_Candidates__c WHERE Associated_Contact__c IN :KIPCanIds])
        {
            kipportalcan.put(kippc.Associated_Contact__c , kippc);
        }
    if(kipportalcan.size() > 0)
    {
        for (Application__c app : Trigger.new)
        {
            Id kipId = kipportalCan.get(app.Contact__c).Id;

            if(kipId <> null)
            {
               app.KIP_Portal_Candidate__c = kipId;
               }   
            }
        }
    }
}

Could anyone help with this SOQL statement? It seems basic, but I can't get it right for some reason.

 

    String soql = 'select id, name from account';
    if(searchString != '' && searchString != null)
      soql = soql +  ' where name LIKE \'%' + searchString +'%\'';
    soql = soql + ' limit 25';

 all I'm trying to do is an an additional condition on the statement to say something like Industry = 'Education'

 

Any help would be appreciated!

I'm getting a null pointer exception on the line shown below in this trigger when doing bulk uploads, but seems to work fine in one off cases...anyone have a guess as to why?

 

trigger rolerequestTrigger on Application__c (before insert) 
{
    Set<Id> CanIds = new Set<Id>();

    Map<Id, KAP_Portal_Candidates__c> portalcan = new Map<Id, KAP_Portal_Candidates__c>();

    for (Application__c app : Trigger.new) 
    {
       if (app.RecordTypeId == '012C0000000Bhsr' && app.Program__c == 'KAP 2013-14'){
        canIds.add(app.Contact__c);
    }
    }
    if(canIds.size() > 0)
    {
        for(KAP_Portal_Candidates__c kpc : [SELECT Id, Associated_Contact__c FROM KAP_Portal_Candidates__c WHERE Associated_Contact__c IN :canIds])
        {
            portalcan.put(kpc.Associated_Contact__c , kpc);
        }
    if(portalcan.size() > 0)
    {
        for (Application__c app : Trigger.new)
        {

Id kapID = portalCan.get(app.Contact__c).Id;

            if(kapId != null)
            {
               app.KAP_Portal_Candidate__c = kapId;
               }   
            }
        }
    }
    Set<Id> KIPCanIds = new Set<Id>();

    Map<Id, KIP_Candidates__c> kipportalcan = new Map<Id, KIP_Candidates__c>();

    for (Application__c app : Trigger.new) 
    {
       if (app.RecordTypeId == '012C0000000Bhsr' && app.Program__c == 'KIP Summer 2013'){
        KIPcanIds.add(app.Contact__c);
    }
    }
    if(KIPcanIds.size() > 0)
    {
        for(KIP_Candidates__c kippc : [SELECT Id, Associated_Contact__c FROM KIP_Candidates__c WHERE Associated_Contact__c IN :KIPcanIds])
        {
            kipportalcan.put(kippc.Associated_Contact__c , kippc);
        }
    if(kipportalcan.size() > 0)
    {
        for (Application__c app : Trigger.new)
        {
            Id kipId = kipportalCan.get(app.Contact__c).Id;

            if(kipId != null)
            {
               app.KIP_Portal_Candidate__c = kipId;
               }   
            }
        }
    }
}

 

I'm having trouble creating a basic trigger to update a user record. Basically, we have an object that has a lookup to a user. When the object meets a certain criteria I would like to deactivate the associated User. Here is what I've come up with so far that doesn't seem to be working:

 

Trigger:

 

trigger deactivateuser on On_Off_Boarding__c (before update) {

	List<On_Off_Boarding__c> oblist = Trigger.new;

	for(On_Off_Boarding__c ob : oblist){
		
		if(ob.Last_Day__c == date.today()){

		DeactivateUser user = new DeactivateUser (ob);

		user.deactivateUser();

		}

	}

}

 

Class

public class DeactivateUser {

private On_Off_Boarding__c obAttribute;

//Constructor that accepts a On/Offboarding record
public DeactivateUser(On_Off_Boarding__c constructorob){

    obAttribute = constructorob;

}

@future
static public void deactivateUser(){

    if(obAttribute != null){
        User u = new User();
        u = [Select ID, Name, IsActive FROM User Where ID =:obAttribute.Associated_User__c];
        u.IsActive=False;

    }
    
Database.update(userAttribute);

}
}

 

Where am I going wrong? When trying to create the class, I get the "obAttribute.Associated_User__c variable does not exist".

 

Thanks!

If I create a trigger that inserts new records based on a given condition, for example:

 

for (object__c obj : Trigger.new) {

  if (obj.name ='x')

 Do this


 add obj. to list

 

How could I do multiple SOQL conditions and upload all the records to the same list to be imported? For example:

 

for (object__c obj : Trigger.new) {

  if (obj.name ='x')

     obj.field='Some Value"

 

  if(obj.name ='y')

     obj.field='Some other value"


 add obj. to list

 

Thanks!

If I wanted to have some sort of button on a record in salesforce, and when I pushed it it would make a call out to another database and retrieve a document and attach it to the record in salesforce - is there a way to do that? Can someone point me in the right direction?

 

Thanks!

Hi,

 

I have a piece of code that is a command button that links to another page, the problem is since the visualforce page is embedded as an iFrame, it only loads within the iframe. How can I get it so that it reloads the entire window with the URL that I am looking to go to?

 

    <apex:pageblockButtons location="top">
                <apex:commandbutton action="/a02/o" title="View All" value="View All"> 
                </apex:commandbutton>
    </apex:pageblockButtons>

 

So, if I have a sites page that displays various links (some of which are pages contained in the customer portal) when they click the link they are taken to the generic customer portal login, how do I route it so they get taken to a login page that I create myself?

 

Thanks

I want to have a series of unauthenticated visualforce pages that are displayed via sites, but at a certain point, I want the user to login and authenticate to go any further.

 

When I setup a sites page how do I link to another visualforce page without it being routed to the standard customer portal login? I have created a custom login, but when I change the "Authorization required" page in the sites layout, it still goes to the generic customer portal login.

 

Any help would be appreciated!

What's the best way to have product images (that are hosted in Salesforce) be displayed in a gallery format on a sites page? Does anyone have recommendations?

 

Thanks!

I'm trying to create a very simple visualforce form, that just doesn't seem to be working and I don't know why

 

VF:

<apex:page controller="SubmitReferralController" standardStylesheets="false" showHeader="false" sidebar="false">
    <apex:stylesheet value="{!$Resource.semantic}"/>
<html lang="en">
<head>
</head>
<body>
<div style="margin-left:200px">    
<h1>Referrals Fee Program</h1>
<p>
  Any questions? Contact the <a href="semantic-form.css">Referral team</a>.
</p>
</div>
<apex:form styleClass="semantic"> 
<apex:pageBlock >
<div style="margin-left:200px">
<apex:outputPanel >
    <div>
      <apex:outputlabel Value="First Name"></apex:outputlabel>
      <apex:inputText value="{!c.FirstName}" size="30" id="referrer_first_name"/>
      <apex:outputlabel Value="Last Name"></apex:outputlabel>
      <apex:inputText value="{!c.LastName}" size="30" id="referrer_last_name"/>
     </div>
<div style="margin-left:200px">
<apex:commandButton value="Submit Referral" action="{!submitReferral}"/>
</div>
</apex:outputPanel>
</div>
</apex:pageBlock>
</apex:form>         
</body>
</html>
</apex:page>

 Controller:

public class SubmitReferralController {
    
    public Contact c { get; set; }
    
    public PageReference submitReferral(){
        try {
        insert c;
       }
       catch(System.DMLException e) {
           ApexPages.addMessages(e);
       return null;
       }
       return null;
     }
}

 

I'm sure it's something really stupid, but I just can't sort it out.

 

Any help would be greatly appreciated!

I'm trying to create a trigger on attachments, so that when an attachment is added to a Task, and the Task is related to an opportunity, the attachment will be cloned onto the Opportunity.

 

Below is the code I have so far, but I can only get it to work if I remove the if(a.parentid == t.id) before creating the new attachment. Any thoughts?

 

trigger CloneOppTask on Attachment (after insert, after update) {

    Attachment[] insertAttList = new Attachment[]{};
    Set<ID> taskset = new Set<ID>();
    List<Attachment> attlist = [Select Id, parentId, name, body from Attachment where Parent.Type='Task' AND Id in :Trigger.new];

        for(Attachment a : attlist){
            taskset.add(a.parentId);
            }
            
        for(Task t: [Select ID, WhatId From Task Where WhatID in :taskset]){
            for(Attachment a: attlist){
                if(a.parentid == t.id){
                    Attachment att = new Attachment(name = a.name, body = a.body, parentid = t.WhatId);
                    
                    insertAttList.add(att);
                }
            }
        }
        if(insertAttList.size() > 0){
            insert insertAttList;
        }
}

 

I've created a trigger on Contact that will roll-up opportunities into given fields. These fields are seperated by FY and other criteria that aren't doable by a formula or roll-up summary.

 

The problem is, the information only updates when opportunities related to that given contact are updated. For example, if an opportunity is entered it will calculated the $ amount in the "Current FY" field, but if no further updates happen, that field will remain populated.

 

My thought was to create a scheduled batch apex job to happen each fiscal year to reconcile the information - is this the best way to do this?

 

Here is the code that I have so far:

 

global class scheduledMonthly implements Schedulable {

    public static String CRON_EXP = '0 0 0 21 AUG ? *';
 
    global static String scheduleIt() {
        scheduledMonthly sm = new scheduledMonthly();
        return System.schedule('Monthly Reconciliation', CRON_EXP, sm);
    }
 
    global void execute(SchedulableContext sc) {
    
    ExampleBatchClass ebc = new ExampleBatchClass();
    Database.executeBatch(ebc);

    }
}

 

global class ExampleBatchClass implements Database.Batchable<sObject>{

    String query;

    global ExampleBatchClass(){
    // Batch Constructor
    }

    // Start Method
    global Database.QueryLocator start(Database.BatchableContext BC){
        query = 'select id from contact';
        return Database.getQueryLocator(query);
    }

    // Execute Logic
    global void execute(Database.BatchableContext BC, List<sObject> scope){

        List<Contact> conlist = (List<Contact>)scope;
        List<Contact> contoupdate = new List<Contact>();
                //Get all contacts
                for (Contact con : conlist){
                    //execute logic inside for loop

                    contoupdate.add(con);
                }
        database.update(contoupdate);         
    }

    global void finish(Database.BatchableContext BC){
        // Logic to be Executed at finish
    }
}

 Does this seem like the best way to go about this? Thank you!

If I want to have a trigger on a record in one object, that updates a record in another object, how can I accomplish this without having  a SOQL query inside a for loop? We are going to want to map a couple fields back to the other record, so I'm not sure the most efficient way to do this. I was thinking something like this:

 

trigger ContactUpdater on Custom_Object_Name__c (after update) {

 List<Contact> Contactlist = new List<Contact>();
 List<Contact> updatedContacts = new List<Contact>();

 for(Custom_Object_Name__c p : trigger.new){

        If(p.Associated_Contact__c != Null){ 
          Contactlist.add(p.Associated_Contact__c);

          }

	for(Contact c : [SELECT Id FROM Contact WHERE Id IN :Contactlist]){
             c.FieldToUpdate = p.FieldValue;

             updatedContacts.add(c);
          }

         update updatedContacts; 

    }

 

Is there anything inherently wrong with how this is coded?

 

Hi,

 

I am running into a bit of an issue with an apex trigger. Inside the apex class that gets called from the trigger, I filter on some of the records I want to work with like so:

 

for (Object__c ob : recordsFromTrigger){
        if (ob.picklist__c== 'X Summer 2013' || ob.picklist__c == 'X Fall 2013' etc etc){
Do something here;
        }

 

But in this case, one of the criteria will change pretty frequently. It is a picklist on the object that will be constantly updated depending on the time of year. For example 'X Summer 2013' 'X Fall 2013'. How do I go about filtering on if that field INCLUDES 'X' and ignores the date portion? Is this possible someway? I'm just wary of hardcoding the individual picklists in and think it will require a lot of maintenance that will be forgotten.

 

thank you!

 

 

I'm trying to write a test class for a trigger that performs a new record insertion. The trigger is before update, and will insert a record on an associate object. When writing the test class, I am getting this error:

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateOnboardingRecord: execution of BeforeUpdate

caused by: System.DmlException: Insert failed. First exception on row 0 with id 00Tc0000004Q0dqEAC; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

Class.CreateOnboardingFromApplication.createOnboard: line 121, column 1
Trigger.CreateOnboardingRecord: line 7, column 1: []

 

 Any idea where I may be going wrong?

 

Thanks!

I cannot figure out why I am receiving this null pointer exception on line 23. I thought it would be similar to this article: http://cloudnow.wordpress.com/2011/04/04/apex-bloopers-why-art-thou-null/ but the code seems correct to me. The code works when creating single records in the database, but when i try to bulk upload, it fails with the null pointer exception. Any ideas?

 

trigger kiprolerequestTrigger on Application__c (after insert) 
{
    Set<Id> KIPCanIds = new Set<Id>();

    Map<Id, KIP_Candidates__c> kipportalcan = new Map<Id, KIP_Candidates__c>();

    for (Application__c app : Trigger.new) 
    {
       if (app.RecordTypeId == '012C0000000Bhsr' && app.Program__c == 'KIP Summer 2013'){
        KIPcanIds.add(app.Contact__c);
    }
    }
    if(KIPcanIds.size() > 0)
    {
        for(KIP_Candidates__c kippc : [SELECT Id, Associated_Contact__c FROM  KIP_Candidates__c WHERE Associated_Contact__c IN :KIPCanIds])
        {
            kipportalcan.put(kippc.Associated_Contact__c , kippc);
        }
    if(kipportalcan.size() > 0)
    {
        for (Application__c app : Trigger.new)
        {
            Id kipId = kipportalCan.get(app.Contact__c).Id;

            if(kipId <> null)
            {
               app.KIP_Portal_Candidate__c = kipId;
               }   
            }
        }
    }
}

Could anyone help with this SOQL statement? It seems basic, but I can't get it right for some reason.

 

    String soql = 'select id, name from account';
    if(searchString != '' && searchString != null)
      soql = soql +  ' where name LIKE \'%' + searchString +'%\'';
    soql = soql + ' limit 25';

 all I'm trying to do is an an additional condition on the statement to say something like Industry = 'Education'

 

Any help would be appreciated!

I'm getting a null pointer exception on the line shown below in this trigger when doing bulk uploads, but seems to work fine in one off cases...anyone have a guess as to why?

 

trigger rolerequestTrigger on Application__c (before insert) 
{
    Set<Id> CanIds = new Set<Id>();

    Map<Id, KAP_Portal_Candidates__c> portalcan = new Map<Id, KAP_Portal_Candidates__c>();

    for (Application__c app : Trigger.new) 
    {
       if (app.RecordTypeId == '012C0000000Bhsr' && app.Program__c == 'KAP 2013-14'){
        canIds.add(app.Contact__c);
    }
    }
    if(canIds.size() > 0)
    {
        for(KAP_Portal_Candidates__c kpc : [SELECT Id, Associated_Contact__c FROM KAP_Portal_Candidates__c WHERE Associated_Contact__c IN :canIds])
        {
            portalcan.put(kpc.Associated_Contact__c , kpc);
        }
    if(portalcan.size() > 0)
    {
        for (Application__c app : Trigger.new)
        {

Id kapID = portalCan.get(app.Contact__c).Id;

            if(kapId != null)
            {
               app.KAP_Portal_Candidate__c = kapId;
               }   
            }
        }
    }
    Set<Id> KIPCanIds = new Set<Id>();

    Map<Id, KIP_Candidates__c> kipportalcan = new Map<Id, KIP_Candidates__c>();

    for (Application__c app : Trigger.new) 
    {
       if (app.RecordTypeId == '012C0000000Bhsr' && app.Program__c == 'KIP Summer 2013'){
        KIPcanIds.add(app.Contact__c);
    }
    }
    if(KIPcanIds.size() > 0)
    {
        for(KIP_Candidates__c kippc : [SELECT Id, Associated_Contact__c FROM KIP_Candidates__c WHERE Associated_Contact__c IN :KIPcanIds])
        {
            kipportalcan.put(kippc.Associated_Contact__c , kippc);
        }
    if(kipportalcan.size() > 0)
    {
        for (Application__c app : Trigger.new)
        {
            Id kipId = kipportalCan.get(app.Contact__c).Id;

            if(kipId != null)
            {
               app.KIP_Portal_Candidate__c = kipId;
               }   
            }
        }
    }
}

 

If I create a trigger that inserts new records based on a given condition, for example:

 

for (object__c obj : Trigger.new) {

  if (obj.name ='x')

 Do this


 add obj. to list

 

How could I do multiple SOQL conditions and upload all the records to the same list to be imported? For example:

 

for (object__c obj : Trigger.new) {

  if (obj.name ='x')

     obj.field='Some Value"

 

  if(obj.name ='y')

     obj.field='Some other value"


 add obj. to list

 

Thanks!

If I wanted to have some sort of button on a record in salesforce, and when I pushed it it would make a call out to another database and retrieve a document and attach it to the record in salesforce - is there a way to do that? Can someone point me in the right direction?

 

Thanks!

Hi,

 

I have a piece of code that is a command button that links to another page, the problem is since the visualforce page is embedded as an iFrame, it only loads within the iframe. How can I get it so that it reloads the entire window with the URL that I am looking to go to?

 

    <apex:pageblockButtons location="top">
                <apex:commandbutton action="/a02/o" title="View All" value="View All"> 
                </apex:commandbutton>
    </apex:pageblockButtons>

 

I want to have a series of unauthenticated visualforce pages that are displayed via sites, but at a certain point, I want the user to login and authenticate to go any further.

 

When I setup a sites page how do I link to another visualforce page without it being routed to the standard customer portal login? I have created a custom login, but when I change the "Authorization required" page in the sites layout, it still goes to the generic customer portal login.

 

Any help would be appreciated!