• Govindaraj
  • SMARTIE
  • 980 Points
  • Member since 2015

  • Chatter
    Feed
  • 32
    Best Answers
  • 0
    Likes Received
  • 6
    Likes Given
  • 1
    Questions
  • 157
    Replies
I created a lookup relationship between leads and campaigns. When I go to add a campaign to the related list in leads the "New" button does not show up. How do I get this button to display?User-added imageUser-added image
Hi Team,

Need a Apex class for following:

     Create an Apex class called “SalesUtility”. Methods in this class must be accessible without creating an instance of it.
     And a utility method in “SalesUtility” which will return sum of “Expected Revenue” from Opportunity for current fiscal quarter. And 
     Write a utility method in “SalesUtility” class which will return all the Opportunity records having the same name as Lead Company field on Lead records. 
     Write a test class to verify all the above scenarios.

Thanks,
Aj
/*Write a trigger that creates two identical Contacts whenever an Account is created. Make sure both Contacts are associated with the Account. Use any values for the fields on the Contacts - just make sure to use variables when populating the fields of each Contact to make sure they are identical.*/

I am not able to associate contacts with Account , this is my code

trigger IdenticalContact on Account (before insert) {          for (Account a : trigger.new)     {         List<contact> cont = new List<contact> ();         for (integer i=0 ; i<2; i++)         {             contact newContact            = new contact();             newContact.AccountId          = a.id;             newContact.LastName           = 'kritpa';             newContact.FirstName          = 'ptName';             cont.add(newContact);         }      insert cont;     }



 
I want to create a new user which license is salesforce. But the license was all used.  Also can`t see the salesforce license user in Setup>Users page.How to find it?
public class clsShowCarousel {
    @AuraEnabled
    public static list<string> fetchPropertyImages(string RecordId){
        list<string> formulaFieldURL = new list<string>();
		//list<string> imageUrl = new list<string>();
		//list<string> lstAltText = new list<string>(); 
		list<WrapperClass> lstWrap = new list<WrapperClass>(); 
		
        list<Property__c> lstOfformulaFields = new list<Property__c>();
        
        lstOfformulaFields = [select id,ImageFormula1__c,ImageFormula2__c,ImageFormula3__c,ImageFormula4__c,ImageFormula5__c,ImageFormula6__c,ImageFormula7__c,ImageFormula8__c,ImageFormula9__c,ImageFormula10__c,ImageFormula11__c,ImageFormula12__c,ImageFormula13__c,ImageFormula14__c,ImageFormula15__c,ImageFormula16__c,ImageFormula17__c,ImageFormula18__c,ImageFormula19__c,ImageFormula20__c,Front_Image__c,Side_Image__c,Rear_Image__c,Near_Image__c from Property__c where id =: RecordId];
        
        if(lstOfformulaFields.size()>0){
			
			if(lstOfformulaFields[0].Front_Image__c != null && lstOfformulaFields[0].Front_Image__c != '')
				formulaFieldURL.add(lstOfformulaFields[0].Front_Image__c);
			if(lstOfformulaFields[0].Side_Image__c != null && lstOfformulaFields[0].Side_Image__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].Side_Image__c);
			if(lstOfformulaFields[0].Rear_Image__c != null && lstOfformulaFields[0].Rear_Image__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].Rear_Image__c);
			if(lstOfformulaFields[0].Near_Image__c != null && lstOfformulaFields[0].Near_Image__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].Near_Image__c);
            if(lstOfformulaFields[0].ImageFormula1__c != null && lstOfformulaFields[0].ImageFormula1__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula1__c);
            if(lstOfformulaFields[0].ImageFormula2__c != null && lstOfformulaFields[0].ImageFormula2__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula2__c);
            if(lstOfformulaFields[0].ImageFormula3__c != null && lstOfformulaFields[0].ImageFormula3__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula3__c);
            if(lstOfformulaFields[0].ImageFormula4__c != null && lstOfformulaFields[0].ImageFormula4__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula4__c);
            if(lstOfformulaFields[0].ImageFormula5__c != null && lstOfformulaFields[0].ImageFormula5__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula5__c);
            if(lstOfformulaFields[0].ImageFormula6__c != null && lstOfformulaFields[0].ImageFormula6__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula6__c);
            if(lstOfformulaFields[0].ImageFormula7__c != null && lstOfformulaFields[0].ImageFormula7__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula7__c);
            if(lstOfformulaFields[0].ImageFormula8__c != null && lstOfformulaFields[0].ImageFormula8__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula8__c);
            if(lstOfformulaFields[0].ImageFormula9__c != null && lstOfformulaFields[0].ImageFormula9__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula9__c);
            if(lstOfformulaFields[0].ImageFormula10__c != null && lstOfformulaFields[0].ImageFormula10__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula10__c);
            if(lstOfformulaFields[0].ImageFormula11__c != null && lstOfformulaFields[0].ImageFormula11__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula11__c);
            if(lstOfformulaFields[0].ImageFormula12__c != null && lstOfformulaFields[0].ImageFormula12__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula12__c);
            if(lstOfformulaFields[0].ImageFormula13__c != null && lstOfformulaFields[0].ImageFormula13__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula13__c);
            if(lstOfformulaFields[0].ImageFormula14__c != null && lstOfformulaFields[0].ImageFormula14__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula14__c);
            if(lstOfformulaFields[0].ImageFormula15__c != null && lstOfformulaFields[0].ImageFormula15__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula15__c);
            if(lstOfformulaFields[0].ImageFormula16__c != null && lstOfformulaFields[0].ImageFormula16__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula16__c);
            if(lstOfformulaFields[0].ImageFormula17__c != null && lstOfformulaFields[0].ImageFormula17__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula17__c);
            if(lstOfformulaFields[0].ImageFormula18__c != null && lstOfformulaFields[0].ImageFormula18__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula18__c);
            if(lstOfformulaFields[0].ImageFormula19__c != null && lstOfformulaFields[0].ImageFormula19__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula19__c);
            if(lstOfformulaFields[0].ImageFormula20__c != null && lstOfformulaFields[0].ImageFormula20__c != '')
                formulaFieldURL.add(lstOfformulaFields[0].ImageFormula20__c);
			
        }
		string altText = '';
		for(string strFieldValue :formulaFieldURL){
			if(strFieldValue!=null && strFieldValue!=''){
				WrapperClass objWrap = new WrapperClass();
				altText = strFieldValue.substringBetween('alt=','border');
				altText = altText.remove('"');
				
				strFieldValue = strFieldValue.substringBetween('src=', 'alt');
				strFieldValue = strFieldValue.remove('"');
				objWrap.alternativeText = altText;
				objWrap.url = strFieldValue;
					lstWrap.add(objWrap);
			}
		}
		return lstWrap;
    }
	public class WrapperClass{
		@AuraEnabled
		public string url {get;set;}
		@AuraEnabled
		public string alternativeText {get;set;}
	}
}

 
Please help me with simple code...
A trigger that will prevent a user from creating a lead that already exists as a contact. We will use the lead /contact email address to detect duplicates.
Lead is created or updated.
Lead has an email address.
2. Try to find a matching contact based on email address.(Using SOQL)
If a match is found give an error
 If a match is not found do nothing
Hi All,
I would like to display the Contact First Name and Last Name in a trailhead task.

In the Contact Object Manager, Fields & Relationship I am not able to find the First Name and Last Name fields. Seems both are concatenated and updated in Name field.

But how could I know that there is a concatenate happening at the background and why the First and Last Name fields are not displayed in the List.

Thanks
Vijay
  • April 13, 2019
  • Like
  • 0
Hello ,
I have created two lookup relationship on Contact object with Account Object. 
But i am unable to use SOQL query with one of the relationship. Can you please help me on this.
 Relationship Working with CustomAccount FieldRelationship not working with CustomContacts RelationshipUser-added imageUser-added image
Could you please help me to understand, as both the relationship from contact to account are same, why SOQL is working with other relationship and not with other one
To make a test class pass, our developer consultant has given "modify all" permission.  Is this really acceptable?  I am a sys admin - so I have a lot to learn here!
Please comment, or suggest resources for me to read.
I am having an issue with detecting lightning in our Production environment.

We have a redirect VF page that is overriding the edit action of one of our custom objects. The controller for this VF page does a check for lightning by checking UserInfo.getUiThemeDisplayed(). However, for some reason, the org is only returning Theme3 at the moment. I tested in a dev console, and typing in
System.debug( 'UI Theme displayed: ' + UserInfo.getUiThemeDisplayed() );
results in Theme3, regardless of whether I am running that anonymous code in Classic or LEX. I assume this is due to a weird quirk with the developer console. But the VF page is giving me the same response.

I am aware of a current bug with the UserInfo.getUiTheme[Displayed] functions that cannot detect the actual page the User is viewing. It only looks at the setting. For example, if the user clicks the link to switch back to Classic, but then opens a link that is specifically for lightning (eg hostname.my.salesforce.com/lightning/r/Account/[id]/view), it will open that link in the LEX context. But getUiTheme and getUiThemeDisplayed will still think that the page is in Classic since the User's setting is set to Classic. However, that bug is not what is happening here for me.

In my current situation, even if I click the "switch to lightning experience" link, it still continues to show Theme3 for getUiThemeDisplayed. I know we can detect lightning by checking the URL, but I'd rather avoid that hacky and unstable workaround.

Has anyone else experienced this kind of behavior and could give me some insights as to what is happening?

Somthing else that may be important to know is that I am currently unable to reproduce this in my dev org or any of our Sandboxes at the moment.
Hi,

I'm working on this trigger but I get an error at this line:

Contact contacts = Trigger.new;

Illegal assignment from List<Contact> to Contact ​​​​​​​

Do you know why?
How should it be done correctly?

​​​​​​​Thanks.
trigger TriggerAmbassadorUpdateCall on Contact (before insert, after insert, before update, after update) {
 
        system.debug('trigger new ***' + Trigger.new);
        system.debug('trigger new ***' + Trigger.old);
        
        //define variable data
        Contact contacts = Trigger.new;
        
        //create a set of contact Ids
        
       List<Id> contactIds = new List<Id>();
       // Map<Id, String> contactMaps = new Map<Id, String>();
        
        //loop through data
        for ( Contact contact : contacts ) {
           if( contact.Teacher_recuritment_status__c == 'Active' && contact.Ambassador__Short_Code__c!=null) {
           
            contactIds.add(contact.Id);
            }
        }
        
        if( Trigger.isUpdate) {
          //instantiate the class or create an object 
           
          //fire method
          ambassador.fireCall(contactIds);  
        }
        
        return;
  
}

 
I just started using lightning today.  Sorry for the simple question.  I am creating a lightning component where I need to display some fields from the Account on the lightning page and then pass the Account.Id to a controller to get some calculated data.

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >

What goes here?

<span>{!v.Name}</span>
</aura:component>
Assign the fields of one object to another. and  update data of Project_c
like this
I am System Administrator, and the following view has filter that all users having System Administrator profile, I see that some admins have Login link, so I can by click the Login to impersonate them, but some admins don't have the Login link, what causes the difference, they all have the same System Administrator profile.

Thanks.

User-added image
Hi,
i need help in creating Apex schedule jobs to check every 5 mins whether opportunity is newly created or not. I don't know how to start.
Please need your help to complete.

Thanks
I have 2 accounts, one is trailhead account, another one is developer edition account, both accounts are assigned with the system administrator profile. When I am on setup profiles page, I notice that the trailhead account has the Edit action next to each profile even it's standard profile, but with another account, the Edit action is not there, no matter it's custom or standard profile. Please see the screen shot. How to get the Edit action enabled? Thanks.

User-added image

User-added image
 
Hello I'm looking to display a list of cases for our community users. I would like to display the cases for the contact (community user) where even though they may not be a contact on the case, they are a related contact of the account to which the case refers to.

So for Case ABC that is related to the account: Test Account, if the contact is a related contact on Test Account, then they should be able to view Case ABC. 

I tried to create a list of accounts and cases but it's not filtering filtering the cases by contact. Thank you for your help. 

String userEmail = UserInfo.getUserEmail();
        list<account> listaccounts = [SELECT ID, Name, (SELECT name,AccountId, Contact.FirstName, Contact.Email, Contact.LastName FROM Contacts Where Contact.Email != Null AND Contact.Email =: userEmail AND Contact.Email = 'guestadmin@time.com' ) FROM Account ];     
        
        list<case> myCases = [select id, casenumber, AccountId,  subject, status, priority, createddate, closeddate from case Where  AccountId =: listaccounts ];
 
  • February 18, 2019
  • Like
  • 0
Hello,

I am not able to call an webservice it is giving me error saying ..
it cant make a callout if something is pending. 

What are other solutions i have in place.

Thank you for advise 
I have a client who wants to enter information into a Text (?) field on a Salesforce record.  Different users could update this field at various times, but when the user hits the Save button on the record, the information gets saved in that field, and the user name, and date/time should be stamped on the entry, as well.
Ideally, the most recent entry will always go to the top.  Thus, the next user entering information will see who made the last entry, when it was done, and determine what next steps might be.
Can I create a trigger to make that happen? 
  • February 07, 2019
  • Like
  • 0
Hi,
I'm getting empty list when trying to populate using server call.

Component:
<aura:component controller="Picklistcontroller" implements="force:appHostable" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <!-- <aura:attribute name="listOfAccount" type="string[]" default="Account1, Account2" />  -->
    <aura:attribute name="listOfAccount" type="string[]" />
    <aura:attribute name="selectedAccount" type="string" />
    <lightning:select name="accountList" label="List Of Accounts:" value="{!v.selectedAccount}" onchange="{!c.onChangeEvent}">
        <aura:iteration items="{!v.listOfAccount}" var="varAccount" >
            <option label="{!varAccount.label}" value="{!varAccount.value}"></option>   
        </aura:iteration>
    </lightning:select>
</aura:component>
Controller:
({
    doInit : function(component, event, helper) {
		var action = component.get("c.getAccountValues");
        var opts = [];
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state == 'SUCCESS') {
                var lstAccount = response.getReturnValue();
                console.log('lstAccount-->' +JSON.stringify(lstAccount));                 
                for (var i = 0; i < lstAccount.length; i++) {
                    opts.push({ 
                        label: lstAccount[i].Name,
                        value: lstAccount[i].Id
                    });
                }
                component.set('v.listOfAccount', opts);
                console.log('listOfAccount-->' +JSON.stringify(opts));
            }
        });
        $A.enqueueAction(action);
	},
    
	onChangeEvent : function(component, event, helper) {
		alert(component.get('v.selectedAccount'));
	}
})
Apex class:
public class Picklistcontroller {
    @AuraEnabled
    public static list<string> getAccountValues(){
        list<String> lstStringAccount = new list<String>();
        for(Account accObj : [SELECT Id, Name FROM Account Limit 10]) {
            lstStringAccount.add(string.valueOf(accObj));
        }
        return lstStringAccount;
    }
}
Screenshot:
User-added image

Can anyone pls assist on this ?
I created a lookup relationship between leads and campaigns. When I go to add a campaign to the related list in leads the "New" button does not show up. How do I get this button to display?User-added imageUser-added image
Hi,

Is there an easy way to confirm that my Salesforce org has access to an external endpoint? Just needing to simulate a call coming in from a Salesforce IP.

I have added the endpoint to the remote site settings also, and I've tried executing the below
 
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://www.yourendpoint.com');
req.setMethod('POST'); // you could also set this to 'GET' and remove the next line
req.setBody('body of the request');

HttpResponse response = http.send(req);
System.debug('BODY: ' + response.getBody());
System.debug('STATUS: ' + response.getStatusCode());
(replacing the placeholder endpoint url in the code with that of the external system - same one in the remote site setting)

However I'm getting an error message:

System.CalloutException: Read timed out

Any ideas?
I have a custom button within a custom object that was coded/made by Salesforce labs. The button works in classic, but it's not working as intended in Lightning. We need to make minor customization to the visual force codes in order to make this compatible with Lightning. Can anyone help with this? Or direct me to the right contact? Thanks!
Hi,

I deployed my changes from dev sandbox to UAt sandbox. When I ran the test classes in dev it works fine and no issues with code covera ge as well. But after deploying these changes to UAT test classes are failing and code coverage shows 0%.

Please help me out on this. 

Thanks and Regards,
Kishore
Hi Team,

Need a Apex class for following:

     Create an Apex class called “SalesUtility”. Methods in this class must be accessible without creating an instance of it.
     And a utility method in “SalesUtility” which will return sum of “Expected Revenue” from Opportunity for current fiscal quarter. And 
     Write a utility method in “SalesUtility” class which will return all the Opportunity records having the same name as Lead Company field on Lead records. 
     Write a test class to verify all the above scenarios.

Thanks,
Aj
/*Write a trigger that creates two identical Contacts whenever an Account is created. Make sure both Contacts are associated with the Account. Use any values for the fields on the Contacts - just make sure to use variables when populating the fields of each Contact to make sure they are identical.*/

I am not able to associate contacts with Account , this is my code

trigger IdenticalContact on Account (before insert) {          for (Account a : trigger.new)     {         List<contact> cont = new List<contact> ();         for (integer i=0 ; i<2; i++)         {             contact newContact            = new contact();             newContact.AccountId          = a.id;             newContact.LastName           = 'kritpa';             newContact.FirstName          = 'ptName';             cont.add(newContact);         }      insert cont;     }



 
Hi Everyone,

I need to change the object-level permissions on the user profile. When clicking on the Edit button (which present left side of profile name) the view is looking as similar to Permission set view. I am not sure why it is looking like that.
Can anyone please help me with this reg.

Thanks in advance.
 

We have a partner that is trying to integrate their app with our salesforce instance but is receiving an error message when trying to authenticate " {"error":"invalid_grant","error_description":"authentication failure”} " . We have their app added as a connected app. How can we resolve?
Hello Everyone,

I have a requirement wherein I need to make a Opportunity record read only when the opportunity stage reaches to Closed won or either Closed Lost.
Any help is much appreciated.

Thanks
Hi Team,

How to uniquely identify if the case was CREATED using email-to-case?

Thanks,

 
Hi,

How to decide how many record types types should we have?
Anyone can explain with examples?
my question is very basic. i have read many things on how to get through this 8th stage of the lightning experience specialist superbadge. but in order for it to make sense in my brain, i cannot get what everyone seems to think is the proper formatting of the explorers.csv sheet.

to me, in my thinking, on the explorers object, there is a field called 'name'. there are no fields for 'first name' or 'last name', so why on earth would i wish to parse out the 'full name' column of the .csv to show first/last? again, in my mind, it would be importing this parsed out first/last name data placing it...nowhere, as there are no specified areas for first/last.

if i can get an answer to this very basic question, then it all will likely make sense to me moving forward. thank you.
Hi All,

How to excute below code in Anonymous window 
 
public class UserUpdate {

    public static void updateUser(List<ID> ids){
    Id taskId = 'aAY2h0000004CANGA2';
       
       delete [SELECT Id from PermissionSetAssignment where AssigneeId=:userId and PermissionSet.ProfileId=null];
       delete [Select Id  from GroupMember where UserOrGroupID=:userId];
       delete [SELECT Id FROM UserPackageLicense where UserId=:userId];     
        
        Profile prf = [select id from Profile where Name='ServiceDesk Client'];
        User usr = [select IsActive,UserRoleId,ProfileId,Title,ManagerId from User where id=:userId];
        usr.UserRoleId = null;
        usr.ProfileId = prf.id;
        usr.Title = null;
        usr.ManagerId = null;
        usr.IsActive = false;
        update usr;
        
    }
    }

Kindly Support and suggest

Thanks 
  • May 14, 2019
  • Like
  • 0

When i click my custom button, a pop up window opens and again i have to click for me to perform the action and once processed, it doesn't get closed.

Two things here:

1)I don't want a pop up window, with only 1 click action should be performed

2)Once done window should be closed automatically

Hi, 

  In below code I am hard coding RW: and FW: in the loop to compare and replace please suggest me how to  user keywords. 
public static void processUpdate(list<Case> cseLst) {
        String FWSubject;
        String RWSubject;
        String CaseSubject;
        list<Case> caseLst = new list<Case>();
       
        for (Case c : cseLst) {       
            if(c.subject <> null){     
                // Remove FW and RW from case subject to get exact string
                if(c.subject.Contains('FW:')){
                    FWSubject = c.subject.replaceAll('FW:','');
                    System.debug('FQ Trim String :' + FWSubject);
                    CaseSubject = FWSubject;     
                } else if(c.subject.Contains('RW:')){ 
                    RWSubject = c.subject.replaceAll('RW:','');
                    System.debug('RW Trim String :' + RWSubject);   
                    CaseSubject = RWSubject;

   }
}

Thanks
GMASJ
  • February 28, 2019
  • Like
  • 2
I have a simple Contact trigger in a sandbox org that is exhibiting some serious performance issues. After doing some debugging it looks like the issue boils down to accessing the items inside Trigger.new list. I mean literally just doing this:
Contact c = Trigger.new[i]
is really slow.

For example, this code runs reasonably quickly (processing 1000 updates in about 30 seconds):
trigger MyTrigger on Contact (after insert, after update, before delete) {
    if (Trigger.isUpdate) {
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            Integer dummy = 0;
        }
    }
}

Results from bulk data load (coming from the bulk job details page):
Total Processing Time (ms): 29370
API Active Processing Time (ms): 27229
Apex Processing Time (ms): 28852

However, this code takes about six minutes to run:
trigger MyTrigger on Contact (after insert, after update, before delete) {
    if (Trigger.isUpdate) {
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            SObject o = Trigger.new[i];
        }
    }
}

Results from bulk data load:
Total Processing Time (ms): 321264
API Active Processing Time (ms): 319187
Apex Processing Time (ms): 893650

If I record the time required to access individual list items like this:
trigger MyTrigger on Contact (after insert, after update, before delete) {
    if (Trigger.isUpdate) {
        for (Integer i = 0; i < Trigger.new.size(); i++) {
            Long e = System.currentTimeMillis();
            SObject o = Trigger.new[i];
            Long s = System.currentTimeMillis();
            System.debug('time: ' + (e - s));
        }
    }
}

I see a lot of times around 400 milliseconds.

What's going on here? Does it really take that long to access an element in a list? Is there any way around this?
 
I'm trying to create an Apex Class that checks all Account records on a daily basis and sends an email to the email field on ones that have a review due on that date.

For example:
Vendor ABC Pty Ltd has opted in for reviews (Vendor Review: Reminders = true), has an annual review date set in their record (Vendor Review: Date = 17/02/2019), and an email address set in their record (Vendor Review: Email = abc@test.com).

Here is my code:
global class VendorReviewCronJob implements Schedulable{ 
    
        global void execute(SchedulableContext SC) {
            sendmail();
        }

        public List<Id> getVendorReviewEmailAddresses(Integer Month, Integer Day) 
        { 
            List<Id> mailToIds = new List<Id>();
             
            Account[] a = [SELECT Id, Vendor_Review_Email__c, Vendor_Review_Date__c, Vendor_Review_Reminders__c
                            FROM Account 
                            WHERE DAY_IN_MONTH(Vendor_Review_Date__c) = : Day 
                            AND CALENDAR_MONTH(Vendor_Review_Date__c) = : Month   
                            ];
        
            for(Account recipient : a) {
                    
                    System.Debug('\n*******Found VendorReview Recipient');
                                        
                    if (recipient.Vendor_Review_Reminders__c == true)
                    {
                        mailToIds.add(recipient.Id);
                        System.Debug('\n*******Recipient: '+ recipient.Vendor_Review_Email__c);
                         
                    } else {
                        System.Debug('\n*******NO Recipient');
                    }
                
            }

            return mailToIds;
        }




        public void sendMail() 
        {
      
            String debugAddress = 'eyewell@salesforce.com';
            String VendorReviewEmailTemplateName = 'User_Vendor_Review_Required';       
            String debugMessage;
            String[] toAddresses;

            Integer DayOfEvent   = date.today().day();
            Integer MonthOfEvent = date.today().month();

            List<Id> VendorReviewIdsList = getVendorReviewEmailAddresses(MonthOfEvent,DayOfEvent);

            EmailTemplate VendorReviewTemplate = [select Id,Name,Subject,body from EmailTemplate where DeveloperName = :VendorReviewEmailTemplateName];
 
            if(VendorReviewTemplate != null && VendorReviewIdsList.isEmpty() == false)
            {

                Messaging.MassEmailMessage VendorReviewMail = new Messaging.MassEmailMessage();
    
                VendorReviewMail.setTargetObjectIds(VendorReviewIdsList);
                VendorReviewMail.setTemplateId(VendorReviewTemplate.Id);
                VendorReviewMail.setUseSignature(false);
                VendorReviewMail.setSaveAsActivity(true);

                try {
                    Messaging.sendEmail(new Messaging.MassEmailMessage[] { VendorReviewMail });
                }catch(Exception e)
                {
                    System.Debug(e);
                }
           
            }
            else
            {
                System.Debug('VendorReviewCronJob:sendMail(): Either an email template could not be found, or no Account has a Vendor Review today');
            }

                
        }

    
}
I've scheduled the apex class to run daily, but although it's showing that it has run, the emails for the reviews due that day haven't sent, and I also haven't received the confirmation email of how many were sent.

Admittedly, I got the base of the code from a mailer that was checking for birthdays on a Contact object, but I felt the same principles still applied.

Can anybody see where I've gone wrong?
public class Lookup {

    
    @AuraEnabled 
    public static String searchDB(String objectName, String fld_API_Text, String fld_API_Val, 
                                  Integer lim,String fld_API_Search,String searchText ){
        
        searchText='\'%' + String.escapeSingleQuotes(searchText.trim()) + '%\'';

        
        String query = 'SELECT '+fld_API_Text+' ,'+fld_API_Val+
                        ' FROM '+objectName+
                            ' WHERE '+fld_API_Search+' LIKE '+searchText+ 
                        ' LIMIT '+lim;
        
        List<sObject> sobjList = Database.query(query);
        List<ResultWrapper> lstRet = new List<ResultWrapper>();
        
        for(SObject s : sobjList){
            ResultWrapper obj = new ResultWrapper();
            obj.objName = objectName;
            obj.text = String.valueOf(s.get(fld_API_Text)) ;
            obj.val = String.valueOf(s.get(fld_API_Val))  ;
            lstRet.add(obj);
        } 
         return JSON.serialize(lstRet) ;
    }
    
    public class ResultWrapper{
        public String objName {get;set;}
        public String text{get;set;}
        public String val{get;set;}
    }
}
  • February 04, 2019
  • Like
  • 1

I followed this tutorial, http://www.wadewegner.com/2013/03/creating-anonymous-rest-apis-with-salesforce-com/ , to create a public rest service in a developer sandbox. If I run any of the following:

curl GET http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl POST http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl PUT http://sitedomainname.cs1.force.com/services/apexrest/Widgets/
curl DELETE http://sitedomainname.cs1.force.com/services/apexrest/Widgets/

I get an HTTP 301 response.

But strangely, if I run that URL through POSTMAN, any request calls my GET method. And if I run it through SOAP UI, it calls my POST and GET methods correctly.

Finally, if I call the same url, but HTTPS, I get a HTTP 503 error.

Here is my class:
 
@RestResource(urlMapping='/Widgets/*')
global class WidgetController {

    @HttpGet
    global static String getWidgets() {
        return 'GET';
    }

    @HttpPost 
    global static String createNewWidget() {
        return 'POST';
    }

    @HttpDelete
    global static String deleteWidgetById() {
        return 'DELETE';
    }

    @HttpPut
    global static String updateWidget() {
        return 'PUT';
    }
}



I should also add that all of these methods work correctly when authenticated through workbench