• Ashwani Pradhan
  • NEWBIE
  • 40 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 11
    Replies
I am able to created an excel csv file attaching it with my mail. But all the information is being put inside the first column. I want to place the separate field values in separate columns. Can anyone suggest how can I do it using only Apex (as that is my strict requirement) and not using VisualForce or any plugins or xml file ?
I am running below SOQL in Developer Console and its working fine -
SELECT MSRE_Contact__r.name, MSRE_Contact__r.MSRE_Company__c, MSRE_Contact__r.MSRE_Contact_Title__c, MSRE_Investor__r.name, MSRE_Investor__r.Parent.Name, MSRE_Investment__c, MSRE_Investment__r.Product2.name, MSRE_Contact_Relationship__c, MSRE_Distribution__c, MSRE_Quarterly__c, MSRE_Legal__c, MSRE_Tax__c, Webcast__c, MSRE_Annual_Meeting__c, MSRE_Adv_Committee__c, CreatedDate, LastModifiedDate, lastModifiedBy.Name, IsDeleted FROM MSRE_Correspondence__c

Now same query if I am using in Apex calss below error coming -
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field. Asset.Name

Here Product2 is lookup in Investment(Asset). Why its working in Developer Console and not in Apex? Any help would be appreciated.
I am try below code and its not showing email display name, even its not showing full email address. Its just picking before the @ symbol like if my org wide address is asw_india_supp@gmail.com then in from it will come asw_india_supp

Here is my code peice 
Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage ();
	String [] toAddresses = new list<string> {'ashwani.pradhan@test.com'};
	
	//Set recipient list
	DateTime d = DateTime.now() ;
	String dateStr =  d.format('MMM-dd-yyyy');
	// Use Organization Wide Address  
	for(OrgWideEmailAddress owa : [select Id, Address, DisplayName from OrgWideEmailAddress]) {
		if(owa.Address.contains('ir')) singEmail.setOrgWideEmailAddressId(owa.id); 
	}  

	singEmail.setToAddresses (toAddresses);
	singEmail.setSubject('Salesforce Contact Correspondence Details Report as of '+ dateStr);
	
	singEmail.setHtmlBody('Hello');

	Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});
Please help..
 
I have a list with duplicate elements like below -

List<Contact_c> corr = [SELECT Contact_r.Name, Id, Name From Contact_c];

Now in result of corr getting same Contact_r.Name multiple times and I need to show all those contacts whose occurrence in list > 1
If I group Contact_r.Name and try to count then list will only give contact one time which will force me to query in loop to get all and heap size issue occuring.

If I am trying to use Map to occurrence then again heap issue came.

So I have only one option left that any how in corr iteration I can check frequency of Contact_r.Name in corr and if its greater than 1 then show record else continue

Please help me how can we achieve under Apex.
I am running below SOQL in Developer Console and its working fine -
SELECT MSRE_Contact__r.name, MSRE_Contact__r.MSRE_Company__c, MSRE_Contact__r.MSRE_Contact_Title__c, MSRE_Investor__r.name, MSRE_Investor__r.Parent.Name, MSRE_Investment__c, MSRE_Investment__r.Product2.name, MSRE_Contact_Relationship__c, MSRE_Distribution__c, MSRE_Quarterly__c, MSRE_Legal__c, MSRE_Tax__c, Webcast__c, MSRE_Annual_Meeting__c, MSRE_Adv_Committee__c, CreatedDate, LastModifiedDate, lastModifiedBy.Name, IsDeleted FROM MSRE_Correspondence__c

Now same query if I am using in Apex calss below error coming -
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field. Asset.Name

Here Product2 is lookup in Investment(Asset). Why its working in Developer Console and not in Apex? Any help would be appreciated.
I am try below code and its not showing email display name, even its not showing full email address. Its just picking before the @ symbol like if my org wide address is asw_india_supp@gmail.com then in from it will come asw_india_supp

Here is my code peice 
Messaging.SingleEmailMessage singEmail = new Messaging.SingleEmailMessage ();
	String [] toAddresses = new list<string> {'ashwani.pradhan@test.com'};
	
	//Set recipient list
	DateTime d = DateTime.now() ;
	String dateStr =  d.format('MMM-dd-yyyy');
	// Use Organization Wide Address  
	for(OrgWideEmailAddress owa : [select Id, Address, DisplayName from OrgWideEmailAddress]) {
		if(owa.Address.contains('ir')) singEmail.setOrgWideEmailAddressId(owa.id); 
	}  

	singEmail.setToAddresses (toAddresses);
	singEmail.setSubject('Salesforce Contact Correspondence Details Report as of '+ dateStr);
	
	singEmail.setHtmlBody('Hello');

	Messaging.SendEmailResult [] r = Messaging.sendEmail (new Messaging.SingleEmailMessage [] {singEmail});
Please help..
 
HI All,

How to write a test class for schedule apex class?
give explanation about this variable, String sch = '0 0 2 * * ?';
I have a list with duplicate elements like below -

List<Contact_c> corr = [SELECT Contact_r.Name, Id, Name From Contact_c];

Now in result of corr getting same Contact_r.Name multiple times and I need to show all those contacts whose occurrence in list > 1
If I group Contact_r.Name and try to count then list will only give contact one time which will force me to query in loop to get all and heap size issue occuring.

If I am trying to use Map to occurrence then again heap issue came.

So I have only one option left that any how in corr iteration I can check frequency of Contact_r.Name in corr and if its greater than 1 then show record else continue

Please help me how can we achieve under Apex.
I am able to created an excel csv file attaching it with my mail. But all the information is being put inside the first column. I want to place the separate field values in separate columns. Can anyone suggest how can I do it using only Apex (as that is my strict requirement) and not using VisualForce or any plugins or xml file ?
Hi All
         Could you please suggest me how to make a validation rule (want to do using validation rule only)in a custom field in account object
 if the field(text field) is empty, the user can change. Once entered or if provided by the data file, user needs to go to administrator to change
Hi Team,

When we are using Below SOQL we are facing Erro Like "the line breaks not allowed in string literals"

SOQL:

Public String query = 'SELECT id,name,Opportunity.RecordType.name,
       (SELECT Id,Ownerid, ActivityDate FROM OpenActivities Order By LastModifiedDate ASC),(SELECT LastModifiedDate,TeamMemberRole FROM OpportunityTeamMembers WHERE TeamMemberRole = \'Team\'') From Opportunity where id =  'OptyID';

How to remove the litterals from above query.Please Help us

Thanks
  • July 14, 2016
  • Like
  • 0
Hi there,

I am trying to retrieve all records only in the recycle bin, and I learnt from the forum that they can be selected by IsDeleted=true, but the problem is that those records hard delected from the recycle bin (which means they actually do not exist in the org any more) are still marked as IsDeleted=true.

Could any expert help find a way to rule them out? Or would anyone know the object name of the recycle bin if there is one?

Many thanks and best regards,
Stellar 
Hi,

We have registered My Domain for our instance few days before but didin't recieve any Confirmation email. 
In setup page, its showing "Your domain name registration is pending" message.

Any help will be appriciated.

Thanks,
Shashank.