• monika sdfc
  • NEWBIE
  • 50 Points
  • Member since 2014
  • Nanomindz Technologies PVT Ltd

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 16
    Replies
Hi all,

I am new to MarketingCloud.I have task where i need to delete files from portfolio.

Can anyone help me.
Thanks in advance
Monika
Hi all,

 My requirement is i need to integrate with 3rd party .They have a registration form.Now we have to capture those values in lead Object.
They have some feilds where Lead status required feild is not covering . So i need to define a default value to it while creating the WSDL.

Can any one help me out how to give a default value for it.

Thanks in advance.
global class OPsCMMIBatchSendMail implements Database.Batchable<Sobject>,Database.AllowsCallouts
{
        
        
       /*  pmPlan__c cpm = pmPlan__c.getInstance('replyToAddress');          
         String reply = cpm.replyTo__c; */

       global Database.QueryLocator start(Database.BatchableContext BC)
        {
            String query = 'SELECT Id,Name,DM_s_E_Mail_ID__c,PM_s_EMAIL_Id__c FROM Ops_CMMI__c';
            return Database.getQueryLocator(query);
        }
       
       global void execute(Database.BatchableContext BC, List<Ops_CMMI__c> scope)
        {
            //List<String> maill=new List<String>();
         //   Set<String> email_new = new Set<String>();       
          ApexPages.PageReference report = new  ApexPages.PageReference('/00O61000002bwj9?csv=1');                          
          Messaging.EmailFileAttachment Attachment = new Messaging.EmailFileAttachment();  
          Attachment.setFileName('CMMI Report.csv');
        
         Attachment.setBody(report.getContent());
          Attachment.setContentType('csv');
         /*for(Ops_CMMI__c mp : scope)
          {
               List<String> email=new List<String>();
                Integer i;
                String mail = mp.PM_s_EMAIL_Id__c;
               
                if(mail!=Null)
                {
                    email = mail.split(',');
                   // system.debug(email);
                }
                for(i=0;i<email.size();i++)
                {
                   
                    email_new.add(email[i]);
                   // system.debug(maill);
                }
                if(mp.DM_s_E_Mail_ID__c!=Null)
                {
                    email_new.add(mp.DM_s_E_Mail_ID__c);
                     system.debug(i);
                }       
          }*/
              Messaging.SingleEmailMessage smail = new Messaging.SingleEmailMessage();  
              //List<Messaging.SingleEmailMessage> lMail = new List<Messaging.SingleEmailMessage>();        
             /*  List<String> setTo = new List<String>(email_new); 
                 integer num = setTo.size();               
                 system.debug(num);   */     
                smail.setToAddresses(new string[]{'abc@gmail.com'});
               
                smail.setReplyTo('xyz@gmail.com' (mailto:'xyz@gmail.com'));
                String messageBody = 'Dearr,';
                       messageBody +=' ';
                       messageBody +='One action.';
                       messageBody +=' PS:  This Automation.';                      
                smail.setHtmlBody(messageBody);
                              smail.setSenderDisplayname('mo');             
                smail.setSubject('CMMI Project(s)');          
                smail.setFileAttachments(new Messaging.EmailFileAttachment[]{Attachment});
                      
           Messaging.sendEmail(new Messaging.SingleEmailMessage[]{smail});
           
        }
           
       global void finish(Database.BatchableContext BC)
        {
           
        }

}




This is how the out put is..
This is the way my output after opening the attachment.

Any help appreciated .
Thanks in advance.
Hi,

Can any one please help me out . No error message but not working.

global class sendEmails implements Database.Batchable<sObject> 
{
         List<Messaging.SingleEmailMessage> lMail = new List<Messaging.SingleEmailMessage>();
         
    global Database.QueryLocator start(Database.BatchableContext BC) 
        {
            String query = 'SELECT Id,Name,Pm_email__c FROM Employee__c';
            return Database.getQueryLocator(query);
        }
    global void execute(Database.BatchableContext BC, List<Employee__c> scope) 
        {
            for(Employee__c emp : scope)
            {
                String emails = emp.Pm_email__c; //takes whole emailID in string
                List<String> email = emails.split(',');//divides the string with ',' and stores in a list.
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(email);  
                mail.setSubject('Welcome to Sweet 16 Siebel Batch');
                String messageBody = '<html><body>Hi ' + ',Welcome </body></html>';
                mail.setHtmlBody(messageBody);   
                mail.setSubject('Quality Assurance');
                system.debug(mail);
                
                lMail.add(mail);
            }
                Messaging.sendEmail(lMail);
        }
    global void finish(Database.BatchableContext BC)
        {
            
        }
  
}

=============================

global class ScheduleEmail implements Schedulable
{
    global void execute(SchedulableContext sc)
    {
        ID BatchId = Database.executeBatch(new sendEmails(),200);
    }
    public void SchedulerMethod()
    {
        String timer ='0 2 0 * * ?';
        system.Schedule('sendEmailsTest',timer,new ScheduleEmail());
        
    }
}

In anonymous Block i am executing in this way 

ScheduleEmail se = new ScheduleEmail();
String tim ='0 02 9 10 10 ?';
system.debug(tim);
system.schedule('ExecuteScheduler',tim,new ScheduleEmail());


Thanks in advance.
Hi all,

Registration__c is my custom object with 2 recordtypes Recordtype1 or RecordType2
Now i am fetching the records from recordtype1. 

List<Registration__c> reg=[Select id, name, RecordType.Name FROM Registration__c
WHERE recordtypeid in (Select Id From RecordType where sobjecttype = 'Registration__c' and DeveloperName IN ('Recordtype1'))];
for(Registration__c rg : reg)
System.debug(rg.Name);

Thanks in advance.
Monika.
Hi guys,

Recently I have came across very interesting scenario and I am now struggling to find the root cause of it.

Its related to Impact of Rollup summary fields on the execution of triggers.

Scenario : 
(Parent object --> X)
(Child object --> Y)
>>I have one rollup summary field on X doing Sum operation on one of Y field say 'Amount'.
>>Now I have updated my parent's record, and it execute the "before update" trigger of X.
>>In this trigger I am updating Opportunity records and in one of triggers defined on Opportunity I am updating the 'Amount' field of child object Y.

*So due to the rollup summary field it will again enforce to run the trigger of Parent object X and will throw the ERROR of "Self reference recursion"

*This behavior is expected but when I changed the trigger of X from "before update" to "after update" it resolve my issue, but how?

It seems like Salesforce do not like to update the field involved in Rollup summary field of parent before the data commit to database.

Please share your thoughts that why it fixed in after update event ?

Thanks --
I have a lookuprelation in obj1(Registration__c), Now on insert i need to create a record on obj2(OutPatient__c) with lookup relation object values.

here is my code.
trigger Outrecord on Registration__c (after insert) {
 public string DName;
    List<OutPatient__c> lop = new List<OutPatient__c>();
    Doctor__c doc = new Doctor__c();
    for(Registration__c reg : trigger.new)
    {
        system.debug(reg.name);
        if(reg.OutPatient__c==true)
        {
             OutPatient__c op = new OutPatient__c();
            op.Name=reg.Name__c;
            op.RegNumber__c=reg.Name;
             DName= [select Doctor__r.Name__c from Registration__c rgt where rgt.Doctor__r.Name =:reg.DoctorName__c];//this query is not working.
            op.DoctorName__c = DName;
            lop.add(op);
        }
        insert lop;
        
    }

Error:Didn't understand relationship 'Doctor__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
    
Registration__c is custom object having doctor__c has lookuprelation.
I required Name__c from Doctor__c in obje2(outpatient__c) while i insert a record in Registration__c

Thanks in advance.
Here is my code.

VFPage:-
<apex:page Standardcontroller="Doctor__c" extensions="DoctorView" >
<apex:form >
<apex:pageMessages />
<apex:tabPanel switchType="Client" >
<apex:tab label="Doctor" >
       <apex:pageBlock >
     
       <apex:pageBlockSection columns="2">
      <apex:inputField value="{!Doctor__c.Name__c}"/>
      <apex:inputField value="{!Doctor__c.DOB__c}"/>
      <apex:inputField value="{!Doctor__c.ContactNumber__c}"/>
      <apex:inputField value="{!Doctor__c.Department__c}"/>
       </apex:pageBlockSection>

      <apex:pageblockbuttons location="bottom">
        <apex:commandButton value="Save" action="{!doctorRecord}" />
 
       </apex:pageblockbuttons>
       </apex:pageBlock> 
      
       <apex:pageBlock >
        
        <apex:pageBlockButtons location="bottom">
         <apex:commandButton value="ViewDetails" action="{!viewRecords}" />
        </apex:pageBlockButtons>
       
            <apex:pageBlockTable value="{!doctorList}" var="dL">
                <apex:column headerValue="Name" value="{!dL.Name__c}"/>
                <apex:column headerValue="Phone" value="{!dL.ContactNumber__c}"/>
                <apex:column headerValue="DOB" value="{!dL.DOB__c}"/>
                <apex:column headerValue="Department" value="{!dL.Department__c}"/>
            </apex:pageBlockTable>
           
       </apex:pageBlock>
 </apex:tab>    
  </apex:tabPanel>
       </apex:form>
</apex:page>

Apexclass:-
public class DoctorView {
    
    public Doctor__c doctor = new Doctor__c();
    public List<Doctor__c> doctorList{get;set;}
    
    public DoctorView(ApexPages.StandardController controller) {
    
        this.doctor = (Doctor__c)controller.getRecord();

    }
    
    public pageReference doctorRecord()
    {
        insert doctor;
       
        return null;
    }
    
    public pageReference viewRecords()
    {
         doctorList = new List<Doctor__c>();
        doctorList = [Select Id,Name__c,ContactNumber__c,DOB__c,Department__c from Doctor__c];
        return null;
    }

}
i have a method 
public void Genericobject(Sobject obj)
{
----
}

How to call this method?
Well i am calling like this 
a.Genericobject(Account acc)

Thanks in advance
        but an error
expecting a right parentheses, found 'acc'                   
 
Hi,

Can any one please help me out . No error message but not working.

global class sendEmails implements Database.Batchable<sObject> 
{
         List<Messaging.SingleEmailMessage> lMail = new List<Messaging.SingleEmailMessage>();
         
    global Database.QueryLocator start(Database.BatchableContext BC) 
        {
            String query = 'SELECT Id,Name,Pm_email__c FROM Employee__c';
            return Database.getQueryLocator(query);
        }
    global void execute(Database.BatchableContext BC, List<Employee__c> scope) 
        {
            for(Employee__c emp : scope)
            {
                String emails = emp.Pm_email__c; //takes whole emailID in string
                List<String> email = emails.split(',');//divides the string with ',' and stores in a list.
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(email);  
                mail.setSubject('Welcome to Sweet 16 Siebel Batch');
                String messageBody = '<html><body>Hi ' + ',Welcome </body></html>';
                mail.setHtmlBody(messageBody);   
                mail.setSubject('Quality Assurance');
                system.debug(mail);
                
                lMail.add(mail);
            }
                Messaging.sendEmail(lMail);
        }
    global void finish(Database.BatchableContext BC)
        {
            
        }
  
}

=============================

global class ScheduleEmail implements Schedulable
{
    global void execute(SchedulableContext sc)
    {
        ID BatchId = Database.executeBatch(new sendEmails(),200);
    }
    public void SchedulerMethod()
    {
        String timer ='0 2 0 * * ?';
        system.Schedule('sendEmailsTest',timer,new ScheduleEmail());
        
    }
}

In anonymous Block i am executing in this way 

ScheduleEmail se = new ScheduleEmail();
String tim ='0 02 9 10 10 ?';
system.debug(tim);
system.schedule('ExecuteScheduler',tim,new ScheduleEmail());


Thanks in advance.
Hi all,

Registration__c is my custom object with 2 recordtypes Recordtype1 or RecordType2
Now i am fetching the records from recordtype1. 

List<Registration__c> reg=[Select id, name, RecordType.Name FROM Registration__c
WHERE recordtypeid in (Select Id From RecordType where sobjecttype = 'Registration__c' and DeveloperName IN ('Recordtype1'))];
for(Registration__c rg : reg)
System.debug(rg.Name);

Thanks in advance.
Monika.
Hello Everyone,
public class abc{
system.debug('abc');

/[Error] Error: Compile Error: expecting a right parentheses, found 'abc' at line 3 column 13

I am not sure why i am getting this error .

can you please help me out.

}
I have a lookuprelation in obj1(Registration__c), Now on insert i need to create a record on obj2(OutPatient__c) with lookup relation object values.

here is my code.
trigger Outrecord on Registration__c (after insert) {
 public string DName;
    List<OutPatient__c> lop = new List<OutPatient__c>();
    Doctor__c doc = new Doctor__c();
    for(Registration__c reg : trigger.new)
    {
        system.debug(reg.name);
        if(reg.OutPatient__c==true)
        {
             OutPatient__c op = new OutPatient__c();
            op.Name=reg.Name__c;
            op.RegNumber__c=reg.Name;
             DName= [select Doctor__r.Name__c from Registration__c rgt where rgt.Doctor__r.Name =:reg.DoctorName__c];//this query is not working.
            op.DoctorName__c = DName;
            lop.add(op);
        }
        insert lop;
        
    }

Error:Didn't understand relationship 'Doctor__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
    
Registration__c is custom object having doctor__c has lookuprelation.
I required Name__c from Doctor__c in obje2(outpatient__c) while i insert a record in Registration__c

Thanks in advance.
Hi
Can we perform Read/write on Trigger.new in before insert?
thanks
 
Here is my code.

VFPage:-
<apex:page Standardcontroller="Doctor__c" extensions="DoctorView" >
<apex:form >
<apex:pageMessages />
<apex:tabPanel switchType="Client" >
<apex:tab label="Doctor" >
       <apex:pageBlock >
     
       <apex:pageBlockSection columns="2">
      <apex:inputField value="{!Doctor__c.Name__c}"/>
      <apex:inputField value="{!Doctor__c.DOB__c}"/>
      <apex:inputField value="{!Doctor__c.ContactNumber__c}"/>
      <apex:inputField value="{!Doctor__c.Department__c}"/>
       </apex:pageBlockSection>

      <apex:pageblockbuttons location="bottom">
        <apex:commandButton value="Save" action="{!doctorRecord}" />
 
       </apex:pageblockbuttons>
       </apex:pageBlock> 
      
       <apex:pageBlock >
        
        <apex:pageBlockButtons location="bottom">
         <apex:commandButton value="ViewDetails" action="{!viewRecords}" />
        </apex:pageBlockButtons>
       
            <apex:pageBlockTable value="{!doctorList}" var="dL">
                <apex:column headerValue="Name" value="{!dL.Name__c}"/>
                <apex:column headerValue="Phone" value="{!dL.ContactNumber__c}"/>
                <apex:column headerValue="DOB" value="{!dL.DOB__c}"/>
                <apex:column headerValue="Department" value="{!dL.Department__c}"/>
            </apex:pageBlockTable>
           
       </apex:pageBlock>
 </apex:tab>    
  </apex:tabPanel>
       </apex:form>
</apex:page>

Apexclass:-
public class DoctorView {
    
    public Doctor__c doctor = new Doctor__c();
    public List<Doctor__c> doctorList{get;set;}
    
    public DoctorView(ApexPages.StandardController controller) {
    
        this.doctor = (Doctor__c)controller.getRecord();

    }
    
    public pageReference doctorRecord()
    {
        insert doctor;
       
        return null;
    }
    
    public pageReference viewRecords()
    {
         doctorList = new List<Doctor__c>();
        doctorList = [Select Id,Name__c,ContactNumber__c,DOB__c,Department__c from Doctor__c];
        return null;
    }

}
This is the Challenge:

To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.The Apex class must be called 'AccountHandler' and be in the public scope.
The Apex class must have a public static method called 'insertNewAccount'.
The 'insertNewAccount' method must accept an incoming string as a parameter, name the account after the parameter, insert it into the system and then return the account record.
The 'insertNewAccount' method must also accept an empty string, catch the failed DML and return null.


My Class:

public class AccountHandler {

    public static Account insertNewAccount (String accName, Account a) {
         try{   
          a.name = accName;
    
         insert a;
        return a;
        }
        catch(Exception e) {
            return null;
        }
    }    
}



User-added image


Throwing this error, how many times i modified the class.
what is the correct class.?
 
Hi,
 I have created and scheduled daily and weekly reports for leads in my CRM. 
And able to get the mails daily and weekly for the reports.
The problem is report is sent as mail not excel or csv file attachments.
How to get scheduled reports as excel/csv file attchments in mails .
Any help is really appreciated.

Thanks,
Naveen.
Create an Apex class that returns an array (or list) of strings: 
Create an Apex class that returns an array (or list) of formatted strings ('Test 0', 'Test 1', ...). The length of the array is determined by an integer parameter.The Apex class must be called 'StringArrayTest' and be in the public scope.
The Apex class must have a public static method called 'generateStringArray'.
The 'generateStringArray' method must return an array (or list) of strings. Each string must have a value in the format 'Test n' where n is the index of the current string in the array. The number of returned strings is specified by the integer parameter to the 'generateStringArray' method.

MyApexClass to above Challenge:

public class StringArrayTest {
    
    public static List<string> generateStringArray(Integer n)
    {
        List<String> myArray = new List<String>();
        
        for(Integer i=0;i<n;i++)
        {
            myArray.add('Test'+i);
            System.debug(myArray[i]);
        }
        return myArray;
        
    }


It's compile and execute as per requirement in Developer console. But Traihead showing the below error:

Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

Anyhelp would be greatly appreciated. Thanks.