• nagas
  • NEWBIE
  • 50 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 35
    Replies

hi ,

 

I have an S-Control in our Organization which needs to be replaced by VisualForce Page. Can anybody help me how to build a visualforce page for this S-Control logic. I am posting the S-Control logic below.

 

 

<script type="text/javascript"> 
if({!ISNULL( User.Partner_PIF__c )})
{
alert("You do not have Access to PIF. Please Contact System Administrator for further assistance");
}
else{
top.location.href ="/{!User.Partner_PIF__c}"; 
}
</script>

 

 

  • January 27, 2011
  • Like
  • 0

hi friends,

How are you all doing. I hope everybody is rocking in there jobs. I have an issue and i need some help from you guys. I have Batch Class which basically queries the Audit history of an Object and do some operation on the other Object. I willl provide you the code of my Batch class Below.

 

global class ProcessCorpTerrMapAudit  implements Database.Batchable<sObject>{

private Datetime startTime;
private Datetime lastRunTime;
private Batch_Scheduler_Configuration__c config;
private String lastRunTimeString;
public String recId;


global ProcessCorpTerrMapAudit(){
   
    startTime = System.now();
    config = [select id, Last_Run_Date_Time__c from Batch_Scheduler_Configuration__c where Job_Type__c='ProcessCorpTerrMapAudit'];
   
    lastRunTime = config.Last_Run_Date_Time__c;
   
    lastRunTimeString = ''+lastRunTime;
    lastRunTimeString = lastRunTimeString.replace(' ', 'T')+'.000Z';
    system.debug('now ' + lastRunTime);
    system.debug('nowstring ' + lastRunTimeString);
           
}

global Database.QueryLocator start(Database.BatchableContext BC){
    String query='Select c.ParentId, c.OldValue, c.NewValue, c.Id, c.Field, c.Division, c.CreatedDate, c.CreatedById From Corp_Terr_Map__History c where c.CreatedDate>'+lastRunTimeString;
    if(recId!=null){
        query +=' and c.Id = \''+recId+'\'';
    }
    return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<sObject> scope){
   
        List<Corp_Terr_Map_Audit__c> audits = new List<Corp_Terr_Map_Audit__c>();
       
        for(sobject s : scope){
            Corp_Terr_Map__History hist = (Corp_Terr_Map__History)s;
            Corp_Terr_Map_Audit__c audit = new Corp_Terr_Map_Audit__c();
            audit.ParentId__c = hist.ParentId;
            if(hist.Oldvalue==null){
                audit.OldValue__c=null;
            } else {
                audit.OldValue__c = ''+hist.Oldvalue;
            }
            if(hist.Newvalue==null){
                audit.NewValue__c=null;
            } else {
                audit.NewValue__c = ''+hist.Newvalue;
            }
            audit.Field__c = hist.Field;
            audit.Unique_Id__c = hist.Id;
            audit.CreatedById__c = hist.CreatedById;
            audit.CreatedDateTime__c = hist.CreatedDate;
            audits.add(audit);
        }
       
        if(audits.size()>0){
            upsert audits Unique_Id__c;
        }
}

global void finish(Database.BatchableContext BC){


   
    AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
                        TotalJobItems, CreatedBy.Email
                        from AsyncApexJob where Id =:BC.getJobId()];

    if(a.NumberOfErrors<=0){
        config.Last_Run_Date_Time__c = startTime;
        update config;     
    }
    // Send an email to the Apex job's submitter notifying of job completion.
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = label.System_Admin_Email_Notification.split(';');
    mail.setToAddresses(toAddresses);
    mail.setSubject('Process Corp Terr Map process completed with status  - '+ a.Status);
    mail.setPlainTextBody('Process Corp Terr Map : Total Job Items ' + a.TotalJobItems + ' batches with '+ a.NumberOfErrors + ' failures.');
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });  
}


}

 

 

 

For this class i have written the Test class where i found an issue. I am posting the code of the test class below:

 

 

@isTest
private class ProcessCorpTerrMapAuditTest {

    static testMethod void myUnitTest() {
        
        Corp_Terr_Map__c cmp = new Corp_Terr_Map__c(name = 'testterr1',Geo__c = 'AMS'  ,Super_Org__c ='CA_SO', Organization__c = 'CANADA_FIELD', Region__c = 'CANADA', Area__c = 'CA_ENTERPRISE_1', District_Team__c = 'CA_DISTRICT_1', Sector_Vertical__c = 'HEALTHCARE', Segment__c = 'COMMERCIAL', Territory_Type__c = 'HEALTHCARE_ISV_TERRITORY', Active_Flag__c = 'Active', Fiscal_Year__c = 'Old', Open_Territory__c = false , Effective_Start_Date__c = System.today(), Effective_End_Date__c = null, Business_Reason__c = 'Test Purpose', Quota_Bearing__c = true , OIC_Territory_Flag__c = false );
        insert cmp;
        Corp_Terr_Map__c cup = [select id,name,quota_bearing__c from Corp_Terr_Map__c where id=:cmp.id];
        cup.Quota_Bearing__c = false;
        update cup;
        system.debug('TerrName'+cmp.name);  
        ProcessCorpTerrMapAudit pctm = new ProcessCorpTerrMapAudit();
        test.startTest();
        Id batchProcessid = Database.executeBatch(pctm);
        test.stopTest();
    }
}

 

 


the issue is when i am doing the insert or update on the object it should update the Audit History of that object. But here in the test class its not doing it.

I want to ask you guys whether the operations done in the test Instance updates the audit History of that object? If not how can i make this test class to be covered the execution part of the batch class.

cheers,

 

 

 

 

 

  • January 27, 2011
  • Like
  • 0

hi i am trying to insert a closed opportunity in a test class,is it possible, i have given all the required conditions to make a opportunity closed, and when i insert that territory its getting inserted as open opportunity. Can anybody tell me how to make a opportunity closed logically other than UserInterface.

 

cheers,

naga

  • December 14, 2010
  • Like
  • 0

hi,

 

I am trying to write a test class for a class named SystemUtility in which i couldnt make the coverage go more than 62%

 

Class code:

 

global class SystemUtility {
    public static String getErrorString(List<Database.Saveresult> saveResult){
        String error='';
        for(Database.Saveresult result : saveResult){
            if(!result.isSuccess()){ 
                
                for(Database.Error err : result.getErrors()){
                    error+=err;
                    
                }
                return error;
            }
        }
        return error;       
    }
}

 Test class:

 

 

@isTest
private class SystemUtilityTest {

    static testMethod void myUnitTest() {
          
          Territory ter = new Territory(name = 'testterr1',Geo__c = 'AMS'  ,Super_Org__c ='CA_SO', Organization__c = 'CANADA_FIELD', Region__c = 'CANADA', Area__c = 'CA_ENTERPRISE_1', District_Team__c = 'CA_DISTRICT_1', Sector_Vertical__c = 'HEALTHCARE', Segment__c = 'COMMERCIAL', Territory_Type__c = 'HEALTHCARE_ISV_TERRITORY', Active_Flag__c = 'Active', Fiscal_Year__c = 'Old', Open_Territory__c = false , Effective_Start_Date__c = System.today(), Effective_End_Date__c = null, Business_Reason__c = 'Test Purpose', Quota_Bearing__c = true , OIC_Territory_Flag__c = false );
          List<Territory> terrs = new List<Territory>();
          terrs.add(ter);
          
          Profile prof =[select id from profile where name = 'Master GCM Administrator'];
          User us = [select id,profileId from user where profileId =:prof.Id and IsActive = true LIMIT 1];
          
          // Run as Master GCM Administrator
          System.runAs(us){
            
          // Start the Test  
          Test.startTest();
          
          List<Database.Saveresult> res = Database.Insert(terrs);
          String errorStr = SystemUtility.getErrorString(res);
          
          //Stop the Test
          Test.stoptest();
          
          }
    }
}

 

I am facing the coverage issue with the database.error part of the test class. Can anybody let me know how can i make it covered.

 

 

  • December 14, 2010
  • Like
  • 0

hi I have a ApexScheduler Class which need to be test inorder to
deploy can anybody suggest me the way to achieve it to get the
coverage. I am posting the code below

 

global class ScheduleTerritoryInactiveMemberCheck implements 
Schedulable { 
    global void execute(SchedulableContext SC) { 
        TerritoryInactiveMemberCheck bcc = new 
TerritoryInactiveMemberCheck(); 
          bcc.query = 'select id,name from territory'; 
             Database.executeBatch(bcc,200); 
  }
 
} 

 cheers,

naga

 

  • December 03, 2010
  • Like
  • 0

how to fetch the organizational id thrrough APEX

  • November 03, 2010
  • Like
  • 0

I have an issue with an batch apex code I wrote a batch apex to go a ahead check on territory object where it checks its related object and if it didnot find matching records keeps all the records in a string. That  string is passed as an attachment to an custom object once the batch process is completed. I wrote the logic but finally when i run it the string is returning null. saying argument cannot be null.

 

 

global class UserTerritoryCheck implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallOuts {

     String myString ;
     
     
        
    /* Start Method*/
     global Database.QueryLocator start(Database.BatchableContext BC)
     {
       
        String query ='select t.id,t.name from territory t where (t.id IN (select ut.territoryid from userterritory ut))'; 
       system.debug('query ----->' +query);
        return(Database.getQueryLocator(query));
        
     }
     
     /*Execute Method*/
     global void execute(Database.BatchableContext BC, list<Sobject> scope)
     { 
        list<String> UsT = new list<String>();
        for(Sobject cc : scope)
           {
            UsT.add(cc.Id);
           }
          map<id,territory> StdTerritory = new map<id,territory>();
    
    for(territory ter:[select id,name from territory  where id IN :ust])
    {
    
    if(!stdterritory.containskey(ter.id))
     {
       stdterritory.put(ter.id,ter);
     }
    
    }
  
  map<id,userterritory> ustr = new Map<id,userterritory>();
  
  for(userterritory uter:[select id,userid,territoryid,IsActive from userterritory where territoryid  IN :stdterritory.keyset()and IsActive=true ])
    {
      if(!ustr.containskey(uter.territoryid))
      {
         ustr.put(uter.territoryid,uter);
      }
    
    }
  
   Map<id,user_territory_shadow__c> ushadow = new Map<id,user_territory_shadow__c>([Select u.User__c, u.Territory_ID__c From User_Territory_Shadow__c u Where( u.User__c IN  (Select ut.UserId From UserTerritory ut))  AND u.Territory_ID__c IN :stdterritory.keyset()]);
   
   
       String myString='TerritoryName,UserID';

        for(Territory terr :stdTerritory.values())
        {
            if(ustr.containskey(terr.id))
            {
                if(!ushadow.containskey(terr.id))
                {
                    
                    myString+='\n'  + terr.name + ',' + ustr.get(terr.id).Userid;
                      
                }
            }
            
        }
        
        
          
       
     }   
   
     /*Finish Method*/
     global void finish(Database.BatchableContext BC)
    { 
          errorlog__c myobj = new errorlog__c();
          insert myobj; 
         
          Attachment att=new Attachment();
          att.Body=Blob.valueOf(mystring);
          att.name = 'errordetails.csv';
          att.ParentId = myobj.id;
          insert att; 
    }
    

 the error showing at the redcoded line. i tried keeping all the inserting custom object and attaching the file in the execute method then i am not getting the errors the object is creating with attachements. But in my case i have 3000 territories the batch size if i give 1000 there 3 batches running with 3 custom objects created. I want only one object to be created for the whole  process. So i moved that code to finish method which is giving these errors. Can anyone help me in solving this error.

 

 

  • October 20, 2010
  • Like
  • 0

hi ,

 

I am working in a solution where i run a batch class which gives me the all the ids of an object based on some criteria. In this i need to collect all these ids and put it into a csv file and send an email with the csv file attached to the email.

 

Can anybody suggest me the code to accomplish this.

  • October 19, 2010
  • Like
  • 0

hi ,

 

I am trying to do a custom solution for a scenario at our work place. I wrote a batch class to compare two objects and find the synchronization is working properly or not.

 

In this scenario in the batch class i am comparing the objects , if any object id is not equal to id of other object i need to capture that object information and write that into a csv file and save it as an attachment to a custom object .

 

can anybody guide me how to write to a csv file and attach it to a custom object. how can i write to a csv fiel and how can i format the data in the file as i want like the rows and columns.

 

cheers, 

  • October 18, 2010
  • Like
  • 0

hi i am trying to write an batch apex class which conducts a check between two objects. Basically i have two objects

 

object1 and object2. object2 is a replica of object1.  So what are all the records exists in object1 should also exist in object2.

 

So i want to write a batch apex class and schedule it to run everynight to check the the both objects and make sure both are in sync.

 

If a record exists in object1 and not in object2 it should generate an error . All these errors should be displayed in a form of error log and displayed at the final result. So the output should be an error report.

 

 

Did anybody faced same scenario and worked on it,can u share the code or give an suggestion how to go ahead with this.

 

cheers,

naga

  • October 13, 2010
  • Like
  • 0

hi i have written a asynchronous class for a trigger which i giving me an error 

 

Attempt to de-reference a null object

 

I am attaching my code below please let me know if anybody find an error in it.

 

Trigger:

 

 

trigger enddatechild on Territory (before insert,before update) {

List<Id> currentparent = new List<Id>();

for(Territory t :Trigger.New){
   if(t.enddate__c !=null)
   {
     currentparent.add(t.Id);
   }
}

updateTerritory.updatechildterr(currentparent);
}

 

 

Asynchronous Class:

 

 

public class updateTerritory
  {
     @future
     public static void updatechildterr(List<Id> currentparent)
      {
       List <Territory> Tl = new List <Territory>();
       List<Id> MasterTerrList = new List<ID>();
       Map<Id,Territory> child = new Map<Id,territory>();
       boolean endStatus = False;
       
       while (!endStatus)
    {
        Tl = [Select a.id, a.ParentTerritoryId From Territory a  Where a.ParentTerritoryId IN :currentParent];

        If(Tl.size() != 0)
        {
            currentParent.clear();
            for (Integer i = 0; i < Tl.size(); i++)
            {
                Territory T = Tl[i];
                currentParent.add(T.id);
                MasterTerrList.add(T.id);
            }
        }
        else
            endStatus = True;
    }
    
    for(Territory terry:[select id,enddate__c from territory where id IN :masterterrlist and enddate__c = null])
    {
        if(!child.containskey(terry.id))
        {
            child.put(terry.Id,terry);
        }
    }
    if(!child.isempty())
    {
        trigger.new[0].addError('You cannot enddate the parent territory until you enddate your child territories');
    }
    
    }
    }

 the error is showing up at the line i have marked in red color. Its not invoking the future method throwing this error.

 

  • October 11, 2010
  • Like
  • 0

hi all,

 

I am trying to rename the name of couple of objects. I know there will be dependency for that if any apex references exists for the object it will not allow to rename. In the same way if i try change in the apex and try to save it will not allow since the object doesnot exists

 

Is there anyway to overcome this and rename the objects..

  • October 08, 2010
  • Like
  • 0

hi,

 

I have a scenario here where i need to create a trigger.

 

scenario:  I have 3 objects objectA, object B, and object C. object B is an mirror image of object A. object B and object C have one-many relationship. object C lies in related list of object B.

 

I want to write a trigger on object A when a filed called "status is updated to "open"" a trigger should fire and check for object B for any matching records matching the Id of object A and then check for the object C whether the Id of object B exists in it and check a filed named "territory role" and if its value is "quota rep" the trigger should shoot an error message saying "you cannot update the status field".

 

Note:  there is no direct relationship between object A and object C.

 

trigger opencheck on Territory (before update) {
    
    Map<Id,Territory_Shaddow__c> tshadow = new Map<Id,Territory_Shaddow__c>();
    
    Map<String,Territory_Member_Shaddow__c> mshadow = new Map<String,Territory_Member_Shaddow__c>();
    
    for(Territory_Shaddow__c ts :[select territory_Id__c,name from territory_shaddow__c where Territory_Id__c  =:Trigger.new[0].id])
    {
        if(!tshadow.containsKey(ts.Territory_Id__c))
        {
            tshadow.put(ts.Territory_Id__c,ts);
        }
    }
    
    for(Territory_Member_Shaddow__c ms : [select territory_shaddow__c,territory_role__c from territory_member_shaddow__c where territory_role__c = 'primary quota rep' and territory_shaddow__c IN :tshadow.keySet()])
    {
        
        if(!mshadow.containskey(ms.territory_shaddow__c))
        {
            mshadow.put(ms.territory_shaddow__c,ms);
        }
    }
    for(territory t :Trigger.New)

{
   if(t.status__c == 'open')
   {
   
        if(tshadow.containskey(t.Id))
        {
          if(!mshadow.Isempty())
          {
            Trigger.new[0].status__c.addError('You cannot select the status as open since it has primary quota rep assigned to it');
           } 
        }
     }

 

 

I wrote a trigger but its not working .

 

  • October 05, 2010
  • Like
  • 0

hi,

 

I have a requirement where two sections 

 

1. it has a search input filed where the user enters a name and clicks on search which will display a list of users with check boxes and the user is allowed to select the checkboxes what user they want.

 

2. in this section it should display the users which the user selected using the checkboxes in the top section if a user deselects on the top section it should deselect in the bottom section also.

 

Can anybody explain me how it can be achieved. I know may be it can achieved using java script but not sure how to start with i may cretae a onclick function which calls the javascript and in the java script i can add all the selected users to below section. but not sure about the code i dont know javascript much. 

  • September 29, 2010
  • Like
  • 0

hi i want to create a formula field on an object which acts like a link so that when a user clicks on it , it should redirect to a visualforce page.

Can anyone give an example how it can be achieved.

  • September 28, 2010
  • Like
  • 0

hi i wrote visualforce page in which the user enters search criteria and enters a list of records comes up with radio buttons where the user should select one and click on submitt and some operation will be done. everything is going good but when i display those records the user is able to select mutiple radio buttons how can i restrict so that the user can only select one radio button.

  • September 27, 2010
  • Like
  • 0

hi 

 

i ahve written a small trigger which will block the deletion of a "territory" if it finds a matching record in another object "userterritory". The trigger is working fine with that but the error message which it supposed to display is not displaying. Its displaying some other message standard from salesforce which is not related to this context.

 

 

trigger dontdel on Territory (before delete) {

 Territory ter = new Territory();
 List<userterritory> uter = [select territoryid from userterritory where territoryid=:Trigger.old[0].id];

 if(uter.size()>0)

     Trigger.old[0].id.addError('You cannot delete this territory since you have assigned users to this');
  
  

}

 its working fine its not allowing to delete the territory but the error message which it is displaying is

 

 

Cannot Delete the Territory
You cannot delete the territory because at least one territory rolls up to it. 

Click here to return to the previous page.

 

this message should be displayed when we trying to delete a parent terrirory with childs.

 

 

  • September 23, 2010
  • Like
  • 0

hi ,

 

I have an S-Control in our Organization which needs to be replaced by VisualForce Page. Can anybody help me how to build a visualforce page for this S-Control logic. I am posting the S-Control logic below.

 

 

<script type="text/javascript"> 
if({!ISNULL( User.Partner_PIF__c )})
{
alert("You do not have Access to PIF. Please Contact System Administrator for further assistance");
}
else{
top.location.href ="/{!User.Partner_PIF__c}"; 
}
</script>

 

 

  • January 27, 2011
  • Like
  • 0

hi I have a ApexScheduler Class which need to be test inorder to
deploy can anybody suggest me the way to achieve it to get the
coverage. I am posting the code below

 

global class ScheduleTerritoryInactiveMemberCheck implements 
Schedulable { 
    global void execute(SchedulableContext SC) { 
        TerritoryInactiveMemberCheck bcc = new 
TerritoryInactiveMemberCheck(); 
          bcc.query = 'select id,name from territory'; 
             Database.executeBatch(bcc,200); 
  }
 
} 

 cheers,

naga

 

  • December 03, 2010
  • Like
  • 0

Hi Everybody,

                          Is there any possible way to delete all data from Custom Object , by clicking a Command Button  In a Visual

Force Page.....???

Hi there,

 

I want to know if it's possible to check if the current user's Role is higher than another user's role through Apex. Is this possible? Thanks.

 

Sanch

  • October 21, 2010
  • Like
  • 0

I have an issue with an batch apex code I wrote a batch apex to go a ahead check on territory object where it checks its related object and if it didnot find matching records keeps all the records in a string. That  string is passed as an attachment to an custom object once the batch process is completed. I wrote the logic but finally when i run it the string is returning null. saying argument cannot be null.

 

 

global class UserTerritoryCheck implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallOuts {

     String myString ;
     
     
        
    /* Start Method*/
     global Database.QueryLocator start(Database.BatchableContext BC)
     {
       
        String query ='select t.id,t.name from territory t where (t.id IN (select ut.territoryid from userterritory ut))'; 
       system.debug('query ----->' +query);
        return(Database.getQueryLocator(query));
        
     }
     
     /*Execute Method*/
     global void execute(Database.BatchableContext BC, list<Sobject> scope)
     { 
        list<String> UsT = new list<String>();
        for(Sobject cc : scope)
           {
            UsT.add(cc.Id);
           }
          map<id,territory> StdTerritory = new map<id,territory>();
    
    for(territory ter:[select id,name from territory  where id IN :ust])
    {
    
    if(!stdterritory.containskey(ter.id))
     {
       stdterritory.put(ter.id,ter);
     }
    
    }
  
  map<id,userterritory> ustr = new Map<id,userterritory>();
  
  for(userterritory uter:[select id,userid,territoryid,IsActive from userterritory where territoryid  IN :stdterritory.keyset()and IsActive=true ])
    {
      if(!ustr.containskey(uter.territoryid))
      {
         ustr.put(uter.territoryid,uter);
      }
    
    }
  
   Map<id,user_territory_shadow__c> ushadow = new Map<id,user_territory_shadow__c>([Select u.User__c, u.Territory_ID__c From User_Territory_Shadow__c u Where( u.User__c IN  (Select ut.UserId From UserTerritory ut))  AND u.Territory_ID__c IN :stdterritory.keyset()]);
   
   
       String myString='TerritoryName,UserID';

        for(Territory terr :stdTerritory.values())
        {
            if(ustr.containskey(terr.id))
            {
                if(!ushadow.containskey(terr.id))
                {
                    
                    myString+='\n'  + terr.name + ',' + ustr.get(terr.id).Userid;
                      
                }
            }
            
        }
        
        
          
       
     }   
   
     /*Finish Method*/
     global void finish(Database.BatchableContext BC)
    { 
          errorlog__c myobj = new errorlog__c();
          insert myobj; 
         
          Attachment att=new Attachment();
          att.Body=Blob.valueOf(mystring);
          att.name = 'errordetails.csv';
          att.ParentId = myobj.id;
          insert att; 
    }
    

 the error showing at the redcoded line. i tried keeping all the inserting custom object and attaching the file in the execute method then i am not getting the errors the object is creating with attachements. But in my case i have 3000 territories the batch size if i give 1000 there 3 batches running with 3 custom objects created. I want only one object to be created for the whole  process. So i moved that code to finish method which is giving these errors. Can anyone help me in solving this error.

 

 

  • October 20, 2010
  • Like
  • 0

hi ,

 

I am working in a solution where i run a batch class which gives me the all the ids of an object based on some criteria. In this i need to collect all these ids and put it into a csv file and send an email with the csv file attached to the email.

 

Can anybody suggest me the code to accomplish this.

  • October 19, 2010
  • Like
  • 0

Is there a way to clone a price book using Apex code? I know you can via the GUI...but i cant find how to do it using Apex code.

 

Thanks.

All:

 

Been searching all day for help, new to APEX triggers, and need to know if anyone can help:

 

I have two customer objects that I am using. I need to run a lookup to pull a field value from one custom object to another.

 

I have the field "Customer Name"  in Household Addresses. I need the value from "Customer Name"  to appear in the "Household Name" field of custom object GPON Addresses, if a certain criteria is met (if the address field is a match). I have tried a VLOOKUP but since the obejcts are not related in the API I cannot get it to work. Please let me know if more detail is needed.

 

Matthew Hampton

Hi All,

 

I'm very brand new to apex coding and need a little help creating a trigger that will update a picklist field (Occupied_Status__c) from one custom object (Inspection_Checklist__c) to another custom object (Property_Evaluation__c) only when another field is TRUE in the original object that is being updated (Inspection_Checklist__c.Inspection_Complete__c = TRUE).

 

Below is the code I've created so far, I might be completely off, but any help would be appreciated. Thanks in advance! 

 

Right now I'm getting the following error in line 6: Save error: unexpected token: ':'

 

 

trigger OccupancyStatus on Inspection_Checklist__c (after update) {
	
	List<Property_Evaluation__c> eval =
	    [SELECT j.Occupied_Status__c
	     FROM Inspection_Checklist__c j
	     WHERE j.Inspection_Checklist__c.Inspection_Complete__c = TRUE : Trigger.new
	      FOR UPDATE];
	      
	for (Property_Evaluation__c li: eval){
		li.Occupied_Status__c=li.Inspection_Checklist__r.Occupied_Status__c;
	}
    update eval;
}

 

 

 

 

hi ,

 

I am trying to do a custom solution for a scenario at our work place. I wrote a batch class to compare two objects and find the synchronization is working properly or not.

 

In this scenario in the batch class i am comparing the objects , if any object id is not equal to id of other object i need to capture that object information and write that into a csv file and save it as an attachment to a custom object .

 

can anybody guide me how to write to a csv file and attach it to a custom object. how can i write to a csv fiel and how can i format the data in the file as i want like the rows and columns.

 

cheers, 

  • October 18, 2010
  • Like
  • 0