• eclf
  • NEWBIE
  • 30 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 12
    Replies
I'm trying to create a trigger which updates the custom Contact__c lookup field on the Opportunity record. It uses the Contact record associated with the related Account record and selects the Contact record marked as isPrimary firsthen selects the Contact record with the earliest Created Date.

The trigger works on a custom object but when I do this in Opp, I get this error:

Error: Compile Error: Incompatible element type SOBJECT:Account for collection of Id at line 14 column 13



trigger updateOppContact on Opportunity (before insert, before update) {


//This Trigger updates the direct contact link/ Contact__c lookup field on the Opportunity record
//It uses the Contact record associated with the related Account record
//Selects the Contact record marked as isPrimary first
//Then selects the Contact record with the earliest Created Date


    List <Id> AccountIds = new List <Id> ();
   
    for (Integer i = 0; i < Trigger.new.size(); i++) {
         {
            AccountIds.add(Trigger.new[i].Account);       // Add AccountIds to List
        }
    }
   
    //Select the Contact that has the same Account, choose the primary first, then the first created
   
    List <Contact> ContactList = new List <Contact> ([Select Id, AccountId, isPrimary__c from Contact where AccountId in :AccountIds ORDER BY isPrimary__c ASC, createdDate DESC]);
   
    for(Contact con : ContactList) {
   
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            if (con.AccountId  == Trigger.new[i].Account) {
                Trigger.new[i].Contact__c = con.Id;
            }
        } 
         
    }
   

}
Hello, 

I have a trigger where I need to create two sets of cases, parent cases and child cases, and relate them automatically.

Say I need to create 3 cases: 1 parent, 2 childs; when the trigger fires, it creates the 2 child cases and stores them in a List <Case> and then it creates the parent case and stores all 3 of them in a Map <Case, List<Case>>.

Obviously, I have no IDs since they're new records, that's why I use the map to be able to relate the records after I insert them. 

The map is created perfectly; the problem happens when I try to insert the records. First I insert the parent cases (in Map.keyset()), to be able to retrieve the IDs and assign them to the child cases (in Map.values()). After I insert the records in Map.keyset(), for some strange reason I "lose" all records in Map.values().

Don't understand why it's happening... does anyone have any idea? 

I know I've done something similar to this before, not necessarilly parent and child situation, but inserting records of primary object, relating primary object to secondary object and inserting records of secondary object. And it worked, but both of them were custom objects, so I don't know if there's a difference there. 

Thanks in advance, 

eclf

  • March 03, 2014
  • Like
  • 0

Hello SF people out there!

 

So I've got a situation:

I'm building a site where users can register and login and do stuff. I would like to create a system that when the user logs in, it sets a cookie and when he jumps from page to page, it does a verification of the user's session. I thought about doing this using a visualforce component and putting it in every page; basically, the users logs in, creates the session and every page he goes the component has an action to perform the verification. And I would onky have to code this once, rather than doing this for every controller of every page.

 

1st -- I would like to know if this is a good approach? Or if there are other/better ways to do this? 

 

2nd -- Can I call this verification function (from the component controller) on page load and then send it to login page if it's doesn't verify? I tryed using actionFuntion but it seems it's not calling the function, I have nothing in log.

 

Anyone who has some insight in this... please.

 

Thank you.

 

  • May 30, 2013
  • Like
  • 0
Hello, 

I have a trigger where I need to create two sets of cases, parent cases and child cases, and relate them automatically.

Say I need to create 3 cases: 1 parent, 2 childs; when the trigger fires, it creates the 2 child cases and stores them in a List <Case> and then it creates the parent case and stores all 3 of them in a Map <Case, List<Case>>.

Obviously, I have no IDs since they're new records, that's why I use the map to be able to relate the records after I insert them. 

The map is created perfectly; the problem happens when I try to insert the records. First I insert the parent cases (in Map.keyset()), to be able to retrieve the IDs and assign them to the child cases (in Map.values()). After I insert the records in Map.keyset(), for some strange reason I "lose" all records in Map.values().

Don't understand why it's happening... does anyone have any idea? 

I know I've done something similar to this before, not necessarilly parent and child situation, but inserting records of primary object, relating primary object to secondary object and inserting records of secondary object. And it worked, but both of them were custom objects, so I don't know if there's a difference there. 

Thanks in advance, 

eclf

  • March 03, 2014
  • Like
  • 0
I'm trying to create a trigger which updates the custom Contact__c lookup field on the Opportunity record. It uses the Contact record associated with the related Account record and selects the Contact record marked as isPrimary firsthen selects the Contact record with the earliest Created Date.

The trigger works on a custom object but when I do this in Opp, I get this error:

Error: Compile Error: Incompatible element type SOBJECT:Account for collection of Id at line 14 column 13



trigger updateOppContact on Opportunity (before insert, before update) {


//This Trigger updates the direct contact link/ Contact__c lookup field on the Opportunity record
//It uses the Contact record associated with the related Account record
//Selects the Contact record marked as isPrimary first
//Then selects the Contact record with the earliest Created Date


    List <Id> AccountIds = new List <Id> ();
   
    for (Integer i = 0; i < Trigger.new.size(); i++) {
         {
            AccountIds.add(Trigger.new[i].Account);       // Add AccountIds to List
        }
    }
   
    //Select the Contact that has the same Account, choose the primary first, then the first created
   
    List <Contact> ContactList = new List <Contact> ([Select Id, AccountId, isPrimary__c from Contact where AccountId in :AccountIds ORDER BY isPrimary__c ASC, createdDate DESC]);
   
    for(Contact con : ContactList) {
   
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            if (con.AccountId  == Trigger.new[i].Account) {
                Trigger.new[i].Contact__c = con.Id;
            }
        } 
         
    }
   

}

Hello SF people out there!

 

So I've got a situation:

I'm building a site where users can register and login and do stuff. I would like to create a system that when the user logs in, it sets a cookie and when he jumps from page to page, it does a verification of the user's session. I thought about doing this using a visualforce component and putting it in every page; basically, the users logs in, creates the session and every page he goes the component has an action to perform the verification. And I would onky have to code this once, rather than doing this for every controller of every page.

 

1st -- I would like to know if this is a good approach? Or if there are other/better ways to do this? 

 

2nd -- Can I call this verification function (from the component controller) on page load and then send it to login page if it's doesn't verify? I tryed using actionFuntion but it seems it's not calling the function, I have nothing in log.

 

Anyone who has some insight in this... please.

 

Thank you.

 

  • May 30, 2013
  • Like
  • 0
  • I want to remove records from sobject using enhancedlist. iam looking for that functionality.

 

 

  • Anyone who can help in this regard would be great
  • September 13, 2012
  • Like
  • 0

So I'm trying to deploy our Apex code and workflows over to our production app from our sandbox. I go to Setup->Setup->Deployment Connections in order to authorize the connections. However, in both the dev and production environments, I cannot find any sort of "edit" option next to the name of the connection. When I click on the connection, it gives me two checkboxes for authotizing inbound and outbound changes, but they are greyed out and I cannot check either. I have added the following permissions and all other necessary ones for them:

 

Deploy Change Sets

Create and Upload Change Sets

Create AppExchange Packages

Upload AppExchange Packages

Download AppExchange Packages

 

I am an admin for the app, so I can't figure out any other reason why I cannot edit the deployment connections.

CMSForce2 is a free content management system from Force.com Labs.  This app is unsupported, but the community posts and answers questions here as well as on the salesforce.com community site.

 

1. I attempted to install CMSForce2 but received a failure message.  Why won't it install?  The most common problem is that you need an active Force.com site up and running at the time of install.  Post

2. Is there a managed app version of CMSForce2?  No.  CMSForce2 is only available unmanaged.

3. Is this the same as Siteforce?  No.  Siteforce is a product expected to be GA in 2011.

4. Can I insert multiple records with a single call?  Not out of the box (Post).

5. Can I use a picklist in a webform?  Yes (Post).

6. Why can't I add content to CMSForce2?  Your security is probably misconfigured. Check pages 3-4 of the install guide.  Post

  • January 31, 2011
  • Like
  • 0
Hello,
I am getting the following error when trying to parse a WSDL and generate the relevant Apex classes in SalesForce:
 
"Error: Failed to parse wsdl: Found schema import from location https://*.xsd. External schema import not supported."
 
I believe that the following (edited) section of the WSDL referring to an external schema is what's causing the problem:
 
...

<wsdl:types>

<xs:schema>

<xs:import namespace="" schemaLocation="https://*.xsd"/>

</xs:schema>

<xs:schema>

<xs:import namespace="" schemaLocation="https://*.xsd"/>

</xs:schema>

</wsdl:types>

...

Can anyone confirm that this is in fact not allowed by Salesforce and if there is any remedy other than embedding the schema in the WSDL?

 
Thanks,
agab-
  • March 03, 2008
  • Like
  • 0