• Vee_R
  • NEWBIE
  • 0 Points
  • Member since 2011
  • Senior Software Enginner
  • HP

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies
Hi All,

We have a batch class which runs daily. Issue is that sometimes batch is not processing records. We have something like this-
Start(){
  query
  create batch log record with status='processing'- say BL1
}
Execute(){
   try{
        some DML operation on the list in the scope
   }
   catch(exception){
         Update Batch Log record BL1 with status='Failed in execute'
    }
   Update Batch Log record BL1 with status='Completed'
}
This year batch has run daily except three times. We can see BL1 has status='processing'. It was never updated to either completed or failed in execute. Please let me know on how to track exact error.

Thanks in advance!
  • June 08, 2016
  • Like
  • 0
Hi.

I have a custom object (TargetX_SRMb__Application__c) It has a relationship to Contact defined in WSDL by:

  <complexType name="TargetX_SRMb__Application__c">
                <complexContent>
                    <extension base="ens:sObject">

...
                       <element name="TargetX_SRMb__Contact__c" nillable="true" minOccurs="0" type="tns:ID"/>
                        <element name="TargetX_SRMb__Contact__r" nillable="true" minOccurs="0" type="ens:Contact"/>

However, when I run SOQL test as:

 Contact contact = [SELECT  c.Id, c.lastName, (Select CreatedDate  FROM TargetX_SRMb__Contact__r) FROM Contact c]

I get error:

Error: Compile Error: Didn't understand relationship 'TargetX_SRMb__Contact__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name

I also tries adding a "s" as follows: Same error.

 Contact contact = [SELECT  c.Id, c.lastName, (Select CreatedDate  FROM TargetX_SRMb__Contacts__r) FROM Contact c]

 Is this not the correct syntax to query child records from a custom object?

Thanks in advance,

Jon
/*Date.............12/06/2014,VivekSingh
Discription.......
This trigger is work on the opportunity object this is bulkify trigger update contact role in opportuniy
*/


trigger OpportunityTrigger on Opportunity (After insert,After update)
{
    if(trigger.isAfter )
   
    {
        if(trigger.isInsert){
            List<OpportunityContactRole> lstContactRoletoUpdate = new List<OpportunityContactRole>();
            Set<String> setOppId = new Set<String>();
                    system.debug('!!!!After insert');
                    List<OpportunityContactRole> lstOppContactRolePrimary = new List<opportunityContactRole>();
                    for(Opportunity o:trigger.new)
                    {
                        setOppId.add(String.valueOf(o.id));
                    }
                    lstOppContactRolePrimary = [select id,contactId,opportunityId from OpportunityContactRole where opportunityId in :setOppId];
                    no primaryContact role found at all have make from scratch
                    if(lstOppContactRolePrimary.size() > 0)
                    {
                        Map<String,OpportunityContactRole> mapOppIdConrole = new Map<String,OpportunityContactRole>();
                        for(OpportunityContactRole conRole:lstOppContactRolePrimary)
                        {
                            mapOppIdConrole.put(String.valueOf(conRole.opportunityId),conRole);
                        }
                        for(String id:setOppId)
                        {
                            if(mapOppIdConrole.containsKey(id))
                            {
                                Opportunity oppTeamp = trigger.newMap.get(id);
                                if(oppTeamp.buyer__c == mapOppIdConrole.get(id).contactId)
                                {
                                    both are equal , we will just have to update the role
                                    OpportunityContactRole tempRole = mapOppIdConrole.get(id);
                                    tempRole.Role = 'Buyer';
                                    lstContactRoletoUpdate.add(tempRole);
                                }
                                else
                                {
                                    we have the contact role but the contacts are different
                                    OpportunityContactRole tempRole = mapOppIdConrole.get(id);
                                    tempRole.Role = 'Buyer';
                                    tempRole.contactId = oppTeamp.buyer__c;
                                    lstContactRoletoUpdate.add(tempRole);
                                }
                            }else
                            {
                                 we have to make contact role
                                System.debug('####Creating absolutely new one 1');
                                OpportunityContactRole tempRole = new OpportunityContactRole();
                                tempRole.Role = 'Buyer';
                                tempRole.contactId = trigger.newMap.get(id).buyer__c;
                                tempRole.isPrimary = true;
                                lstContactRoletoUpdate.add(tempRole);
                            }
                        }
                    }else
                    {
                        System.debug('####Creating absolutely new one 2');
                        opportunityTriggerHandler objopportunityTriggerHandler = new opportunityTriggerHandler();
                        objopportunityTriggerHandler.createNewContact(trigger.new);
                    }
                if(lstContactRoletoUpdate.size() > 0)
                {
                    upsert lstContactRoletoUpdate;
                }  
           
        }
    }
   
    if(trigger.isBefore)
    {
        if(trigger.isInsert)
        {
                    system.debug('!!!!Before Insert');
                    for(Opportunity o:trigger.new)
                {
                    List<OpportunityContactRole> lstOppContactRolePrimary = [select id,contactId from OpportunityContactRole where opportunityId =: o.id];
                    System.debug('!!!!Before insert contact id'+o);
                    System.debug('!!!!Before insert buyer id'+o.buyer__c);
                    System.debug('!!!!Before lstOppContactRolePrimary = >'+lstOppContactRolePrimary);
                }
           
        }
    }
    
        opportunityTriggerHandler objopportunityTriggerHandler = new opportunityTriggerHandler();
        objopportunityTriggerHandler.createNewContact(trigger.new);
   
   
    code added by deepak dhingra on 13/6/2014 to update the line items
     if(trigger.isAfter && trigger.isUpdate)
     {
        Set<string> qualifiedOppId = new Set<string>();
        for(Opportunity o:Trigger.new)
        {
            if(o.Agency_Discount_Percentage__c != Trigger.Oldmap.get(o.id).Agency_Discount_Percentage__c)
            {
                qualifiedOppId.add(String.valueOf(o.id).left(15));
            }
           
        }
       
        if(qualifiedOppId.size() > 0)
        {
            List<OpportunityLineItem> lstLineItems = new List<OpportunityLineItem>();
            lstLineItems  = [select id from OpportunityLineItem where opportunityid in :qualifiedOppId];
            if(lstLineItems.size() > 0)
            {
                update lstLineItems;
            }
        }
       
       
     }
}

Hi

I have simple requirement, I need to disaplay  a document list in alpha order and have an alpha bar navigation to easily jump to pages on Visualforce page(Similar to apex class/ visualforce list page which displays the list of class and on click of specific character like "C" or "D" or any other char it display result based on the charecter clicked) I need a soultion something like that any suggestion is highly appricated.

 

Thanks in Advance.

  • June 25, 2013
  • Like
  • 0

Hello

 

I have issue with exporting to excel using Visualforce:

 

I am having around 30 columns and around 1000 records....

 

When I click on export to excel button then it shows error - "unable to read file". Then when we open that file then data is present but it shows that error of unable to read file.

 

Also if I reduce the records by limiting the query to 500 then I don't get the error. If I keep all records and reduce the columns to 4 or 5 then also error does not come but if I keep all columns and all records then error is coming...

 

VF page line:

<apex:page controller="CONTROLLER" contentType="application/vnd.ms-excel#FILENAME.xls" cache="true">

 

Has anyone faced anything like this?? I came across few blogs and few communities but found no alternative that solves my problem.