• Sharat C 2
  • NEWBIE
  • 95 Points
  • Member since 2015

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

I'm attempting to deploy the CustomSearchController class as written in the official developer documentation here:

https://developer.salesforce.com/docs/atlas.en-us.communities_dev.meta/communities_dev/communities_dev_example_search.htm
 
public class CustomSearchController {
	@AuraEnabled
	public static List<String> searchForIds(String searchText) {
		List<List<SObject>> results = [FIND :searchText IN ALL FIELDS  RETURNING Account(Id), Campaign(Id), 		Contact(Id), Lead(Id)];
		List<String> ids = new List<String>();
		for (List<SObject> sobjs : results) {
			for (SObject sobj : sobjs) {
				ids.add(sobj.Id);
			}
		}
		 return ids;
	}
}

However I can't see any instruction for writing the test class required. Can anyone please help with this?

Thanks,

Tristan
Hi there,
I have an custom object and has field State__c, When State__c value will Booked. Email Send on associated account. Account is lookup on this Custom Object. Here is my Code:


trigger EmailToPatient on Proposed_Appointment__c (after insert,after update) {
    list<Account> acconts2Update = new list<Account>();
    List<Messaging.SingleEmailMessage> allMails = new List<Messaging.SingleEmailMessage>();
        for(aqthc__Proposed_Appointment__c pro :[SELECT Id,Patient__r.Name,
                                   Patient__r.PersonMobilePhone,Patient__r.PersonEmail,Patient__r.FirstName,Patient__r.LastName,patient__r.id,
                                   aqthc__State__c,Patient__c FROM aqthc__Proposed_Appointment__c
                                   WHERE Id IN: trigger.newMap.keySet()]){
            //Account acc = new Account();
            if(pro.aqthc__State__c == 'Booked'){
             Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
             list<String> toAddresses = new list <string>{pro.Patient__r.PersonEmail};
             mail.setToAddresses(toAddresses);
             system.debug('==========='+toAddresses);
             mail.setTemplateId('00X1U000000uRqr');
             mail.setWhatId(pro.id);
             mail.setBccSender(false);
             mail.setUseSignature(false);
             mail.setReplyTo('Laxminarayan.sfdc@gmail.com');
             mail.setSenderDisplayName('My service');
             mail.setSaveAsActivity(false);
             allMails.add(mail);
       }   
       //acconts2Update.add(acc);
   }
}

Thanks
How do i make a post callout for this specific url ?

http://www.test.com/ComposeSMS.aspx?username=username&password=password&sender=senderid&to=MobileNo&message=Message

I am not able to figure out how to create the header and body for this specific url. I need to passs username , password , senderid , mobile number and message as parameters.

Any code snippet will be highly appreciated
  • April 07, 2019
  • Like
  • 0
I need help to create custom button for cloning the Case using lightning Web component . I pretty new to lightning , can somebody please guide me ?
Thanks !
Hello,
I am actually writing a code that helps to get automatically the dependencies between Object.
While writing my code, I faced an issue. I cannot find a way to know when an object doesn't have a parent object.
How can I find that in apex ?
Hi, Could some one please share me information on "How to display content only on last page of a PDF in Salesforce "

Thanks in advance
  • June 07, 2019
  • Like
  • 0
Hi, 

On Account Object we have 4 field sets. In apex, i need to query all the fieldsets and get the value of each field and dispay on VF page.

In the below syntax, we have to mention the FS name which i dont want.
List<Schema.FieldSetMember> fields = Schema.SObjectType.Account.fieldSets.getMap().get('field_set_name').getFields();

Regards,
Desai
  • May 29, 2019
  • Like
  • 0
Hi 

I have a button on a lightning component that basically executes 

      window.location.reload()
         
I was trying to see if it is possible to call this action - either via process builder or a trigger. I can't seem to find a way so far :( 

Sarah 
I need our reps to only be able to transfer ownership if the lead belongs to a queue, I was able to successfully to this with a validation. But because I have the "Transfer Leads" permission enabled it has exposed the "Mass Transfer" lead link on the Lead object. 

So I am trying to write a trigger to prevent any profile other than  System Administrator from being able to bulk transfer, but I have no idea what I am doing. Can someone help me with the code for this trigger?


This is what I have so far: 

Trigger LeadMassTransfernotallowed on Lead (after update){

Id userProfileId = userinfo.getProfileId(); 
  String userProfileName = [SELECT ID, Name from Profile Where Id = :userProfileId].Name;
  
  for(Lead leadInsert: Trigger.new){
  if(userProfileName <> 'System Administrator'){
  //system.debug('my Oldvalue');
lead.adderror('You do not have the permission to mass transfer Lead Ownership, contact SalesOp')
  if(trigger.new[0].OwnerId!=trigger.old[0].OwnerId){
   }
  }
 }
}

 
trigger countmeetings on Event (after insert, after delete) {
List<id> levent = new List<id>();
Set<id> accid = new Set<id>();
List<Event> eventtoupdate = new List<Event>();
public integer inp=0;
if(trigger.isInsert){
for(Event ce:trigger.new){
accid.add(ce.WhatId);
}
}
if(trigger.IsDelete){
for(Event ce: trigger.old){
accid.add(ce.WhatId);
}
}
for(Event ev:[SELECT id FROM event WHERE whatid=:accid]){
    levent.add(ev.id);
}
for(Event event :[SELECT id,Distribution_Meetings__c FROM Event WHERE id=:levent]){
    event.Distribution_Meetings__c = levent.size();
    eventtoupdate.add(event);
    }
If(eventtoupdate.size()>0){
    update eventtoupdate;
}
    }
  • April 11, 2019
  • Like
  • 0
 I need to create a trigger that can send email off of opportunity and send the template that has opportunity merge fields.I get the email from this trigger but it is missing the merge field. My trigger looks like below:

trigger ImplementationProject_EmailAlert on Opportunity (after update) {

      List<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();

    for(Opportunity newItem : trigger.new) {


        
        if (newItem.StageName == 'Closed Won ')
        system.debug('stagename@@' +newItem.stageName);
        {
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
//List <Contact> Con= [select id, name from Contact where name =:'Richa Paliwal']; 
            
            //system.debug('contact id@@' +Con);
            
//mail.setTargetObjectId(Con[0].id); 
mail.setSenderDisplayName('Salesforce Support'); 
mail.setUseSignature(false); 
mail.setBccSender(false); 
mail.setSaveAsActivity(false); 
EmailTemplate et=[Select id, Subject, Body from EmailTemplate where Name=:'ZSYSGEN_EXPEDITED Close Won Notification']; 
             system.debug('Template id@@' +et);
mail.setTemplateId(et.id); 
          mails.add(mail);

        }
        }

Messaging.SendEmailResult [] r = Messaging.sendEmail(mails);

}

and out of the box template looks like:
The following Opportunity includes Expedited Implementation as a product and has reached Closed Won stage: 

Date Closed Won: {!Opportunity.CloseDate} 
Opportunity: {!Opportunity.Name} 
Opportunity Type: {!Opportunity.Type} 

Account: {!Opportunity.Account} 
Agency Code: {!Opportunity.Agency_Code__c} 
Shipping State: {!Opportunity.Shipping_State__c} 

Implementation Note: {!Opportunity.Implementation_Notes__c} 

Opportunity Description: {!Opportunity.Description} 


Opportunity Link: {!Opportunity.Link}

 
Hi all,

I'm attempting to deploy the CustomSearchController class as written in the official developer documentation here:

https://developer.salesforce.com/docs/atlas.en-us.communities_dev.meta/communities_dev/communities_dev_example_search.htm
 
public class CustomSearchController {
	@AuraEnabled
	public static List<String> searchForIds(String searchText) {
		List<List<SObject>> results = [FIND :searchText IN ALL FIELDS  RETURNING Account(Id), Campaign(Id), 		Contact(Id), Lead(Id)];
		List<String> ids = new List<String>();
		for (List<SObject> sobjs : results) {
			for (SObject sobj : sobjs) {
				ids.add(sobj.Id);
			}
		}
		 return ids;
	}
}

However I can't see any instruction for writing the test class required. Can anyone please help with this?

Thanks,

Tristan
Hi All,

How can I access the Custom label translations in apex?
 
Hi there,
I have an custom object and has field State__c, When State__c value will Booked. Email Send on associated account. Account is lookup on this Custom Object. Here is my Code:


trigger EmailToPatient on Proposed_Appointment__c (after insert,after update) {
    list<Account> acconts2Update = new list<Account>();
    List<Messaging.SingleEmailMessage> allMails = new List<Messaging.SingleEmailMessage>();
        for(aqthc__Proposed_Appointment__c pro :[SELECT Id,Patient__r.Name,
                                   Patient__r.PersonMobilePhone,Patient__r.PersonEmail,Patient__r.FirstName,Patient__r.LastName,patient__r.id,
                                   aqthc__State__c,Patient__c FROM aqthc__Proposed_Appointment__c
                                   WHERE Id IN: trigger.newMap.keySet()]){
            //Account acc = new Account();
            if(pro.aqthc__State__c == 'Booked'){
             Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
             list<String> toAddresses = new list <string>{pro.Patient__r.PersonEmail};
             mail.setToAddresses(toAddresses);
             system.debug('==========='+toAddresses);
             mail.setTemplateId('00X1U000000uRqr');
             mail.setWhatId(pro.id);
             mail.setBccSender(false);
             mail.setUseSignature(false);
             mail.setReplyTo('Laxminarayan.sfdc@gmail.com');
             mail.setSenderDisplayName('My service');
             mail.setSaveAsActivity(false);
             allMails.add(mail);
       }   
       //acconts2Update.add(acc);
   }
}

Thanks
public class BatchApexController{
 
      public void callBatch(){
      
        database.executebatch(new LoanofficerBatch());
    database.executebatch(new RealtorBatch());
    database.executebatch(new BuilderBatch());
      }
}
please help
 
How do i make a post callout for this specific url ?

http://www.test.com/ComposeSMS.aspx?username=username&password=password&sender=senderid&to=MobileNo&message=Message

I am not able to figure out how to create the header and body for this specific url. I need to passs username , password , senderid , mobile number and message as parameters.

Any code snippet will be highly appreciated
  • April 07, 2019
  • Like
  • 0