• balaji Jayararman
  • NEWBIE
  • 95 Points
  • Member since 2016

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 14
    Replies
Hi, 

I'm trying to update a field named Primary Partner Gross Margin on the opportunity object based on opportunity line items. 
The code compiles, but it doesn't update the field on update. Any idea why ? 
trigger OpportunityTriggers on Opportunity (before update) {
    
    // Quand 1 Opp a un Primary Partner Account Reseller, remplir le champs "Primary Partner Gross Margin" = Sum OpportunityLineItems Software  * Primary_Partner_Margin__c
    // C'est forcément before car on a besoin d'update des records, et quand on est en after, les records sont lock
    
    // Prendre la liste des opportunités pour lesquelles on va peupler Primary_Partner_Gross_Margin__c
    For (Opportunity opp : [SELECT Id,Primary_Partner_Gross_Margin__c,Primary_Partner_Margin__c 
                            FROM Opportunity
                            WHERE Primary_Partner_Role__c ='Reseller'
                            AND Deal_with_a_partner__c = 'Yes'
                            AND Id IN :Trigger.old
                           ]) {
                               
                               // Updater le champs Primary_Partner_Gross_Margin__c
                               Double GrossMargin = [SELECT TotalPrice 
                                                      FROM OpportunityLineItem
                                                      WHERE PricebookEntry.product2.Family='Software'
                                                      AND  OpportunityId =: opp.Id ][0].TotalPrice;
                               
                               
                               opp.Primary_Partner_Gross_Margin__c=GrossMargin*opp.Primary_Partner_Margin__c;
                               opp.Name = 'Worked';
                               
                           }
}

 
Hi experts..
pls find below my requirement scenario :
i have custom object (test_custObj) and  fileds  are ( age,street city, phone,email and contact_lookup( contact lookup field) ).  i already maintaed lookup relationship between custom object and contact .
Thrid party system sending details based on Contact ......i can able to store all the fields but not contact_lookup field . 
for example :
my third party sending details like   '23',' YG colony',' Hyd','88888888','abc@gmail.com'  and ' AMAR'.
i can able to store all the values expect 'AMAR' ( contact_lookup)
can some one help me how can i save/store  contact_lookup filed in custom object ?  
its urgent one ....thanks 


 
  • June 19, 2018
  • Like
  • 0
My Requirment :
Is to count all amount field values in all opportunity records and show in seperate field in  account record(parent record)

As per my client i must do by using triggers only

How can i achieve it

can anyone help writing trigger for oppoartunity records on account 

Thanks InAdvance.....................
  • June 14, 2018
  • Like
  • 0
I have requirement to display image in Public site using content version record.

Ex: https://mydomain.com/sfc/servlet.shepherd/version/download/0681U000008x0I7QAI

However the image is not rendering, because of permission issue in guest user profile. Please help me to resolve this issue..
As per winter 21 release notes, view all and modify all permissions are removed at object level for guest user profile.

In my case, i have apex class with sharing mode enabled and gave read and create permission for custom object(Technologies__c) for guest user profile. But no Technologies__c records are retrieved.

if i give view all permission for custom object(Technologies__c) for guest user profile. I see Technologies__c records are rerieved. Any work around for retreiving the records by giving read and create permission alone at object level for guest user profile?
Hi,

In Salesforce documentation, i read contact id does not count against email limitation. But it does counting.

Please refer the below code:
Messaging.SingleEmailMessage[] lst_EmailMsg = new List<Messaging.SingleEmailMessage>();
for (contact con : [SELECT Id from Contact where Email like '%ABC%']) {
	Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
	mail.setTargetObjectId(con.ID);
	mail.setSubject('TEST subject');
	mail.setPlainTextBody('test');
	mail.setHtmlBody('test');
	lst_EmailMsg.add(mail);
}
Messaging.SendEmailResult[] lst_EmailResults = Messaging.sendEmail(lst_EmailMsg, false);

 
Hi all,

I have apex method that will send outbound email. The issue is "it Count against singleEmail limit for contact and lead, but not for user"?
List<TSB__Survey_Recipients__c> lst_SurveyRecipients = [SELECT Id, TSB__ObjectId__c, TSB__Email_Address__c, TSB__Survey_Master__c FROM TSB__Survey_Recipients__c WHERE Id IN :lst_SurveyRecipientsToProcess];
        Set<String> st_StandardObjIdPrefixes = new Set<String> {'003', '005', '00Q'};
		if (!lst_SurveyRecipients.isEmpty()) {
            TSB__Survey_Master__c surMaster = [SELECT Id, TSB__Email_Template__c, TSB__From_Name__c, TSB__From_Address__c FROM TSB__Survey_Master__c WHERE Id = :lst_SurveyRecipients[0].TSB__Survey_Master__c];
            OrgWideEmailAddress[] owdEmailAddr = [select Id from OrgWideEmailAddress where Address = :surMaster.TSB__From_Address__c];
            String domainUrl = getSiteUrlString();
			Messaging.SingleEmailMessage[] lst_EmailMsg = new List<Messaging.SingleEmailMessage>();
            for (TSB__Survey_Recipients__c surveyRecipient : lst_SurveyRecipients) {
            	Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
				if (String.isNotBlank(surveyRecipient.TSB__ObjectId__c) && (surveyRecipient.TSB__ObjectId__c.length() == 18) && st_StandardObjIdPrefixes.contains(surveyRecipient.TSB__ObjectId__c.subString(0, 3))) {
					System.debug('passing Id = '+surveyRecipient.TSB__ObjectId__c);
					//mail.setToAddresses(new String[]{surveyRecipient.TSB__ObjectId__c});
					mail.setTargetObjectId(surveyRecipient.TSB__ObjectId__c);
					mail.setTreatTargetObjectAsRecipient(true);
					mail.setSaveAsActivity(false);
					if (surveyRecipient.TSB__ObjectId__c.startsWithIgnoreCase('005')) {
						mail.setSaveAsActivity(false);
					}
				} else {
					System.debug('passing email Id = '+surveyRecipient.TSB__Email_Address__c);
					mail.setToAddresses(new String[]{surveyRecipient.TSB__Email_Address__c});
				}
				if (String.isNotBlank(emailSubject)) {
					mail.setSubject(emailSubject);
				}
                if (!owdEmailAddr.isEmpty()) {
                    mail.setOrgWideEmailAddressId(owdEmailAddr[0].Id);
                } else if (String.isNotBlank(surMaster.TSB__From_Name__c)) {
                	mail.setSenderDisplayName(surMaster.TSB__From_Name__c);  
                }
				if (String.isNotBlank(emailBody)) {
					emailBody = emailBody.unEscapeHtml4();
					String url='<a href=\''+domainUrl+surveyRecipient.Id+'\'>click here</a>';					
					emailBody = emailBody.replaceAll('<URL>', url);
					mail.setPlainTextBody(emailBody);
                	mail.setHtmlBody(emailBody);
				}
				System.debug('get Target Object ID = '+mail.getTargetObjectId());
				System.debug('get To Address = '+mail.getToAddresses());
                lst_EmailMsg.add(mail);
            }
            Messaging.SendEmailResult[] lst_EmailResults = Messaging.sendEmail(lst_EmailMsg, false);
			for (Integer i = 0; i < lst_EmailResults.size(); i++) {
				Messaging.SendEmailResult emailResult = lst_EmailResults[i];
				if (emailResult.isSuccess()) {
					lst_SurveyRecipients[i].TSB__Survey_Status__c = 'Email Sent';
				} else {
					lst_SurveyRecipients[i].TSB__Survey_Status__c = 'Delivery Failed';
					lst_SurveyRecipients[i].TSB__Delivery_Failed_Reason__c = '';
					for (Messaging.SendEmailError emailError : emailResult.getErrors()) {
						lst_SurveyRecipients[i].TSB__Delivery_Failed_Reason__c += emailError.getMessage();
					}
				}
			}
			Database.update(lst_SurveyRecipients, false);
		}

 
In which layer visual flow lies in MVC pattern?
In which layer Schema builder lies in MVC pattern?
What is VAN and why we are using it?
How to customize Page Header and Footer Sections in salesforce home page? 
I wrote a batch class and set the batch size to 10. To process 6000 records, it took 5 hours. Is there any way to increase the speed? 
What is the role of transaction database engine in Force.com metadata driven architecture?
Hi,
     I want to get the jobname for the schedule class by using apex schedule class name or id. I don't know the when it was scheduled and job Name. Now I would like to add this schedule class and reschedule it again. When i try to add this job i am getting the following error "This Apex class has batch or future jobs pending or in progress" .


Thanks,
Mohan S
I create a website in salesforce developer.
How can copy struct of database from salesforce developer to salesforce production?
Or have to create again in salesforce production?
Hi, 

I'm trying to update a field named Primary Partner Gross Margin on the opportunity object based on opportunity line items. 
The code compiles, but it doesn't update the field on update. Any idea why ? 
trigger OpportunityTriggers on Opportunity (before update) {
    
    // Quand 1 Opp a un Primary Partner Account Reseller, remplir le champs "Primary Partner Gross Margin" = Sum OpportunityLineItems Software  * Primary_Partner_Margin__c
    // C'est forcément before car on a besoin d'update des records, et quand on est en after, les records sont lock
    
    // Prendre la liste des opportunités pour lesquelles on va peupler Primary_Partner_Gross_Margin__c
    For (Opportunity opp : [SELECT Id,Primary_Partner_Gross_Margin__c,Primary_Partner_Margin__c 
                            FROM Opportunity
                            WHERE Primary_Partner_Role__c ='Reseller'
                            AND Deal_with_a_partner__c = 'Yes'
                            AND Id IN :Trigger.old
                           ]) {
                               
                               // Updater le champs Primary_Partner_Gross_Margin__c
                               Double GrossMargin = [SELECT TotalPrice 
                                                      FROM OpportunityLineItem
                                                      WHERE PricebookEntry.product2.Family='Software'
                                                      AND  OpportunityId =: opp.Id ][0].TotalPrice;
                               
                               
                               opp.Primary_Partner_Gross_Margin__c=GrossMargin*opp.Primary_Partner_Margin__c;
                               opp.Name = 'Worked';
                               
                           }
}

 
Hi, i wrote one trigger on account object, when even an account is created automatically create a contact for that account. And my trigger is 
trigger acc_con on Account (after insert) {
    List<Contact> cons = new List<Contact>();
    for(Account a:trigger.new) {
        Contact c =new Contact();
        c.lastName = a.Name;
        c.Phone = a.phone;
        c.AccountId = a.id;
        cons.add(c);
    }
    insert cons;
}
Hi experts..
pls find below my requirement scenario :
i have custom object (test_custObj) and  fileds  are ( age,street city, phone,email and contact_lookup( contact lookup field) ).  i already maintaed lookup relationship between custom object and contact .
Thrid party system sending details based on Contact ......i can able to store all the fields but not contact_lookup field . 
for example :
my third party sending details like   '23',' YG colony',' Hyd','88888888','abc@gmail.com'  and ' AMAR'.
i can able to store all the values expect 'AMAR' ( contact_lookup)
can some one help me how can i save/store  contact_lookup filed in custom object ?  
its urgent one ....thanks 


 
  • June 19, 2018
  • Like
  • 0
Hi,

Is there overview documentation about the ...
How many cloud (sales, service etc) and what are the special functions for what kind of companies and customers or partners.

Thanks in advance for sharing...

Regards,
LinThaw
My Requirment :
Is to count all amount field values in all opportunity records and show in seperate field in  account record(parent record)

As per my client i must do by using triggers only

How can i achieve it

can anyone help writing trigger for oppoartunity records on account 

Thanks InAdvance.....................
  • June 14, 2018
  • Like
  • 0
Hello Team,

I have user (lookup field )on opportunty i want to make that field manadatory through trigger..

i want show message user is manadatory field please select user.

trigger opportunityTeamMemberTrigger  on OpportunityTeamMember (Before Insert, Before Update) {
     for (OpportunityTeamMember oppTeam: Trigger.new)
       { 
           
           if(oppTeam.User == Null){
           
           
           oppTeam.addError('please select the user');
                     
           }
                  
                } 
      
}


the trigger is active and it not working can any one tell what went wrong 
I want to access a static value in apex which will be different for UAT and Prod. 
e.g: i want to send an email to ABC in UAT but in prod i want the same email to be sent to PQR. I want to provide this email to APEX using some configuration file, the way we do in Java or .net using web.xml or config.xml.
Do we have this kind of option in Salesforce?