• B Nagarjuna
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
I have a requirement to create a YTD column based on the login history of the year (i.e) the login history for the current physical year of the user .I need this to be done in matrix report.

User-added image

when you look at the screen shot the YTD calculates the logins only on the current physical year(jan14-mar14).Grand total should display the asusal the entire total. Does this can be achieved in matrix report? or by anyother reports.

Thanks
arjun

trigger cloningopportunity on Opportunity (after insert) {

set<id> oid = new set<id>();
RecordType record =[select id from RecordType where name='1*2'];
for(Opportunity opp : Trigger.new)
{
if(opp.RecordTypeId == record.Id)
{
oid.add(opp.Id);
System.debug('cloningvalues:' + oid);
}

}
list<Opportunity> olist = [select id,Name,CloseDate,StageName,RecordTypeId from Opportunity Where Id in:oid];

for(Opportunity opps :olist)
{
Opportunity o = new Opportunity();
o.Name=opps.Name;
o.CloseDate=opps.CloseDate;
o.StageName=opps.StageName;
o.RecordTypeId =opps.RecordTypeId ;
System.debug('cloningvalues1:'+o.StageName );
insert o;


}

}

 

throws error

 

AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY,

 

 

global class deleteAccounts implements Database.Batchable<Sobject>
{
global final String Query;
global deleteAccounts(String q)
{
Query=q;

 

}

global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<SObject> scope)
{
List<Account> lstAccount = new list<Account>();
for (SObject s : scope) //for all objects from our query

{
Account a = (Account)s;
lstAccount.add(a);

}
Delete lstAccount;
}

global void finish(Database.BatchableContext BC)
{
//Send an email to the User after your batch completes
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'na@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Batch Job is done');
mail.setPlainTextBody('The batch Apex job processed ');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

 

 

now iam learning stage in batch apex............so how to run the above batch program,i save this apex program in my developer instance with out errors but i dnt knw how to run and how to get output

trigger cloningopportunity on Opportunity (after insert) {

set<id> oid = new set<id>();
RecordType record =[select id from RecordType where name='1*2'];
for(Opportunity opp : Trigger.new)
{
if(opp.RecordTypeId == record.Id)
{
oid.add(opp.Id);
System.debug('cloningvalues:' + oid);
}

}
list<Opportunity> olist = [select id,Name,CloseDate,StageName,RecordTypeId from Opportunity Where Id in:oid];

for(Opportunity opps :olist)
{
Opportunity o = new Opportunity();
o.Name=opps.Name;
o.CloseDate=opps.CloseDate;
o.StageName=opps.StageName;
o.RecordTypeId =opps.RecordTypeId ;
System.debug('cloningvalues1:'+o.StageName );
insert o;


}

}

 

throws error

 

AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY,