• Sarah Dallimore
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
Hello

I use Declarative Lookup ROllup Summary which will no longer work now that I have enabled Chatter Answers -  I get the following error message.

ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ProfileId]: [ProfileId] Class.ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser: line 31, column 1

We don't use Chatter so that people can register so I don't believe we need the actual class at all but I can't see a way to deploy deleted ape classes to production. I have tried making a few amendments based on amending the class on instructios in this link: https://success.salesforce.com/issues_view?id=a1p300000008XHfAAM

However when i then deploy to production i get the following error: 
System.AssertException: Assertion Failed: A new user should have been created 
Stack Trace: Class.ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser: line 11, column 1

I don't really know the first thing about apex classes and i am not a developer so need as much help as possible with this. I don't have Eclipse or anything like that. APpreciate any help with this. Cheers
 
Hi - I am a bit of a novice when it comes to triggers, any help on where I have gone wtrong would be great.

I am trying to update a custom lookup field on the Opportunity called Participant_Name__c with the Primary Contact on the Contact Role object. Below is the code I have used (which I have copied and pasted from a forum and amended with the custom field name I have set up. I just tested it... nothing happens. Any idea what could be wrong? Thanks in advance

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

Set<Id> OppIds = new Set<Id>();
for (Opportunity o : Trigger.new) {OppIds.add(o.id);}

Map<Id, List<OpportunityContactRole>> Opp_OCR = new Map<Id, List<OpportunityContactRole>>();

for (OpportunityContactRole ocr: [select id, ContactId, Opportunityid, role, isPrimary from 
OpportunityContactRole where opportunityid in :OppIds and isPrimary = true]) {

List<OpportunityContactRole> tmp_ocr = new List<OpportunityContactRole>();
tmp_ocr = Opp_OCR.get(ocr.opportunityid);
if (tmp_ocr == null) {
Opp_ocr.put(ocr.opportunityid, new List<OpportunityContactRole>{ocr});
} else {

tmp_ocr.add(ocr);
Opp_ocr.put(ocr.opportunityid, tmp_ocr);
}

system.debug('Final OCR map: '+Opp_OCR);


for (Opportunity opps : Trigger.new) {
List<OpportunityContactRole> this_OCR = new List<OpportunityContactRole>();
this_ocr = Opp_ocr.get(opps.id);
system.debug('this Opps ('+opps.id+') list of OCRs: '+this_ocr);

if (this_ocr == null) opps.Participant_Name__c = null;
else {

for (OpportunityContactRole r : this_ocr) {
if (r.isprimary) opps.Participant_Name__c = r.ContactId;




}
Hello

I use Declarative Lookup ROllup Summary which will no longer work now that I have enabled Chatter Answers -  I get the following error message.

ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [ProfileId]: [ProfileId] Class.ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser: line 31, column 1

We don't use Chatter so that people can register so I don't believe we need the actual class at all but I can't see a way to deploy deleted ape classes to production. I have tried making a few amendments based on amending the class on instructios in this link: https://success.salesforce.com/issues_view?id=a1p300000008XHfAAM

However when i then deploy to production i get the following error: 
System.AssertException: Assertion Failed: A new user should have been created 
Stack Trace: Class.ChatterAnswersAuthProviderRegTest.validateCreateUpdateUser: line 11, column 1

I don't really know the first thing about apex classes and i am not a developer so need as much help as possible with this. I don't have Eclipse or anything like that. APpreciate any help with this. Cheers
 
Hi - I am a bit of a novice when it comes to triggers, any help on where I have gone wtrong would be great.

I am trying to update a custom lookup field on the Opportunity called Participant_Name__c with the Primary Contact on the Contact Role object. Below is the code I have used (which I have copied and pasted from a forum and amended with the custom field name I have set up. I just tested it... nothing happens. Any idea what could be wrong? Thanks in advance

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

Set<Id> OppIds = new Set<Id>();
for (Opportunity o : Trigger.new) {OppIds.add(o.id);}

Map<Id, List<OpportunityContactRole>> Opp_OCR = new Map<Id, List<OpportunityContactRole>>();

for (OpportunityContactRole ocr: [select id, ContactId, Opportunityid, role, isPrimary from 
OpportunityContactRole where opportunityid in :OppIds and isPrimary = true]) {

List<OpportunityContactRole> tmp_ocr = new List<OpportunityContactRole>();
tmp_ocr = Opp_OCR.get(ocr.opportunityid);
if (tmp_ocr == null) {
Opp_ocr.put(ocr.opportunityid, new List<OpportunityContactRole>{ocr});
} else {

tmp_ocr.add(ocr);
Opp_ocr.put(ocr.opportunityid, tmp_ocr);
}

system.debug('Final OCR map: '+Opp_OCR);


for (Opportunity opps : Trigger.new) {
List<OpportunityContactRole> this_OCR = new List<OpportunityContactRole>();
this_ocr = Opp_ocr.get(opps.id);
system.debug('this Opps ('+opps.id+') list of OCRs: '+this_ocr);

if (this_ocr == null) opps.Participant_Name__c = null;
else {

for (OpportunityContactRole r : this_ocr) {
if (r.isprimary) opps.Participant_Name__c = r.ContactId;




}