• VRK SFDC
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 7
    Replies
Hi ,
I need to query on task object and fetch the record which are pending and Created date today and status is Open

SELECT Id, Attended_By__c,Activity_State__c,WhoID,CreatedDate,IsClosed  from Task where Assigned ='a1T90000005zXDg' AND CreatedDate = TODAY OR (CreatedDate < TODAY AND Task_Status__c !='Closed')
Hi,
We are looking to integrate Salesforceforce with PHP application using SAOP API .Can any one help on these  ?
What are the stepts we have to do in Salesforce and in PHP application  with sample code 
 
Hello,
I have a scenario where i need to update the all the Due date on Open Task of same task Type when a task has been closed of same taskType

We have task on custom object XYZ__c .We have custom field Type__c on Task object.There are 6 Followup task has been created a automatically when the custom object XYZ__c created of Type__c Followup and Subject values with Followup 1 ,Followup 2 ....Follow up 6 .When the first follow up task Subject equals Followup 1 has been closed we need to update all the due date of next five followup task with the closed task due date + 5 months 

Can any one help on these trigger ?
Hi ,
I am trying to create a validation rule where the Stage is Tommorow and if the Date is not equal to tommorw then Error should display as "select tommorws date ".Can any one help

ISPICKVAL( Stage__c, "Schedule given for tomorrow")   && (Date_and_Time__c   !=  NOW()+1)
Hi,I am new to the development
I am tring to write a trigger where i need to compare 2 string values befor updating a lead or insert if the lead is not exist.Below are the fields where i am trying to compare to update from another table

C_Number__c and Mobile_Number__c

If C_Number__c and Mobile_Number__c on the lead is are already present then it should get update or it should be inserted

For example for existing lead  C_Number__c is 123 and Mobile Number is 8521365478 it should get update to these existing lead . C_Number__c is 123 and Mobiel number is 789456321 it should get update on these lead .If Both are not present then it should get inserted as new lead




trigger LeadTrigger on Lead_Table__c (before insert,before update) {
    
    //Fetch given Lead Numbers
    Set<String> cNumber = new Set<String>();
    
    for(Lead_Table__c leadData :Trigger.new){
        cNumber.add(leadData.C_Number__c);
        cNumber.add(leadData.Mobile_Number__c);
    }

    
 
    Map<String, Lead> leadMap = new Map<String,Lead>(); 
    
    for(Lead cq :[SELECT Id,C_Number__c,Mobile_Number__c FROM Lead WHERE C_Number__c in :cNumber OR Mobile_Number__c in :cNumber]){
        leadMap.put(cq.C_Number__c,cq);
        leadMap.put(cq.Mobile_Number__c,cq);
        
        
    }


    
   List<Lead> leadToInsert = new List<Lead>();
   List<Lead> leadToUpdate = new List<Lead>();
 

    for(Lead_Table__c leadData :Trigger.new){

        Integer isUpdate=0;
        Lead lead = new Lead();
             
        if(leadMap.containsKey(leadData.Cheque_Number__c) ){
            

                 Lead newCheque = leadMap.get(leadData.C_Number__c);
         
                    newCheque.Name = leadData.Customer_Name__c; 
                    newCheque.Mobile_Number__c = leadData.Mobile_Number__c; 

                    newCheque.Cheque_Number__c = leadData.C_Number__c;
                    newCheque.Cheque_Status__c = leadData.C_Status__c;
                    
          
                    
            leadToUpdate.add(newCheque);
                
                    isUpdate=1;   
                     
          
       }                           
       else{
       

        
           
                lead =  new Lead();
             
                        lead.Name = leadData.Customer_Name__c; 
                        lead.Mobile_Number__c = leadData.Mobile_Number__c; 
                        
                        lead.Cheque_Number__c = leadData.C_Number__c;
                        lead.Cheque_Status__c = leadData.C_Status__c;

           leadToInsert.add(lead);
          
       
     }
        } 
        
        
    
     if(leadToInsert.size() > 0 || leadToUpdate.size() > 0)
    {  
        insert leadToInsert; 
        update leadToUpdate;
    }
}
 
Hi ,
Can any help on the test class for the below class  ?

public class LocationCallouts {

     @future (callout=true)
      static public void getLocation(Id propertyId){
        // gather account info
        getPLocation(pId);
    }
    
     @future (callout=true)
      static public void getLocation(List<Id> pIds){
        // gather account info
        for(Id pId: pIds){
            getPLocation(pId);
        }  
     }   
     
    
    static private void getPLocation(Id pId)
    {
        P__c pro = [SELECT City_Village__c, Taluka__c, District__c, State__c, Country__c, Pin_Code__c
            FROM P__c 
            WHERE id =: pId];

        // create an address string
        String address = '';
        if (pro.City_Village__c != null)
            address += pro.City_Village__c +', ';
        if (pro.Taluka__c != null)
            address += pro.Taluka__c +', ';
        if (pro.District__c != null)
            address += pro.District__c +', ';
        if (pro.State__c != null)
            address += pro.State__c +', ';
        if (pro.Country__c != null)
            address += pro.Country__c +', ';
        if (pro.Pin_Code__c != null)
            address += pro.Pin_Code__c +', ';        

        address = EncodingUtil.urlEncode(address, 'UTF-8');

        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyDNVjpv_oyICm84VhE5ToGZHKnTplM9S0Q&address='+address+'&sensor=false');
        req.setMethod('GET');
        req.setTimeout(60000);

        try{
            // callout
            HttpResponse res;
            
            if(!Test.isRunningTest()){
                res = h.send(req);
            }      

            // parse coordinates from response
            
            System.debug(res.getBody());
            
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }

                }
            }

            // update coordinates if we get back
            if (lat != null){
                pro.Location__Latitude__s = lat;
                pro.Location__Longitude__s = lon;
                
                TriggerContextUtilityForPTrigger.afterUpdateFlag = FALSE;
                update pro;
            }

        } catch (Exception e) {
            System.debug('Exception '+e);
        }
    }
}
Hi ,Iam trying to write a trigger where update a look up field  Opportunity__c on opportunity object by matching the Opportunity_Id__c with the Account_Id__c (String) and update the Acctount ID in the Opportunity__c (lookup) on opportunity object..

Can any one help on the below code ..


trigger UpdateAccount on Opportunity (before insert,before Update) {
    
    Set<id> accountIds = new Set<id>();
    for (Opportunity c: Trigger.new) {
       
            accountIds .add(c.Opportunity__c);   //Lookup field
            accountIds .add(c.Opportunity_Id__c);   //String
        }
    
 
  
    Map<Id, Account> acc= new Map<Id, Account>([
            select Id,AccountId__c
            from Account
            where AccountId__c In : accountIds
            ]);
    for (Opportunity c: Trigger.new) {
        if (c.Opportunity == null ){
         
            
            c.Opportunity=acc.get(c.Opportunity_Id__c).Id;

        }
    }

}
Hi,
Can any any one help to create test class for these Taskupdate batch class?


global class AllTaskUpdationBatch implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC){
       
        String query = 'SELECT Id,ParentId__c,WhatId,WhoID,Lead__c,Account__c,Opportunity__C FROM Task WHERE Task_Status__C!=\'Closed\' AND (Opportunity__C=null AND Lead__c=null AND Account__c=null )';
        return Database.getQueryLocator(query);
    }
    
    
    global void execute(Database.BatchableContext BC, List<task> taskList){
        System.debug(taskList+'#####');
        List<Task> tasksListToUpdate = new List<Task>();
        
        Schema.DescribeSObjectResult r = Service__c.sObjectType.getDescribe();
        String serviceObjectPrefix = r.getKeyPrefix();
        
        Schema.DescribeSObjectResult rp = Property__c.sObjectType.getDescribe();
        String propertyObjectPrefix = rp.getKeyPrefix();
        
        Schema.DescribeSObjectResult rv = Visit__c.sObjectType.getDescribe();
        String visitObjectPrefix = rv.getKeyPrefix();
        
        Schema.DescribeSObjectResult ds = Dispatch__c.sObjectType.getDescribe();
        String dispatchObjectPrefix = ds.getKeyPrefix();
        
        
        for(task tsk :taskList) {
        
         if(tsk.WhatId!=null) {
             
                tsk.Opportunity__c = null;
                tsk.Lead__c = null;
              
                        
        If(String.valueOf(tsk.WhatId).subString(0,3) == '001') {
            
                tsk.Account__c = tsk.WhatId;
                
            }
            
            else If(String.valueOf(tsk.WhatId).subString(0,3) == '006') {
                tsk.Opportunity__c = tsk.WhatId;
                
            }
         }
           if(tsk.WhoId!=null)  {
                If(String.valueOf(tsk.WhoId).subString(0,3) == '00Q') {
                    tsk.Lead__c = tsk.WhoID;
                   
                }
            }
            
            tasksListToUpdate.add(tsk);
            
        
        }
        try {
            if(tasksListToUpdate.Size()>0) {
                update tasksListToUpdate;
            }
        }
        catch(Exception e) {
            System.debug(e.getMessage()+'$$$$$$');
        }
    }
    
    
    global void finish(Database.BatchableContext BC){
    }
}
Hi ,
I am new to Developmet,Any insights can be helpful

I have custom Object Visit ,In the visit object i have 2 look up fields ,Exe__c (Look Up user),AssignTo__c (Lookup to custome Object Ex_User__c),AssignTo__c  field is a Name of the Person to whome the user is assiened
In Custome object Ex_User__c  i have Lookup field User (Lookup to User object) where i have a formula field User_Id__c which stores the UserId in  Ex_User__c object

Now ,
In Visit when i enter the AssignTo__c field .Exe__c (User Id) field should get auto popuplated upon save ..

Can any one suggest how to achive these through Trigger 
How do I write the the validation rule that makes a look-up field required based on Profile,Text Filed,Picklist?
I have tried with below validation rule
 For example:

AND(
   $Profile.Name <> "Inbound" || $Profile.Name <> "System Administrator" ,
 $Record_Type_Name = "Call"  ,
ISPICKVAL(Status, 'Open')
  )
Account.id=""
 


 
Hello,
I have a scenario where i need to update the all the Due date on Open Task of same task Type when a task has been closed of same taskType

We have task on custom object XYZ__c .We have custom field Type__c on Task object.There are 6 Followup task has been created a automatically when the custom object XYZ__c created of Type__c Followup and Subject values with Followup 1 ,Followup 2 ....Follow up 6 .When the first follow up task Subject equals Followup 1 has been closed we need to update all the due date of next five followup task with the closed task due date + 5 months 

Can any one help on these trigger ?
Hi ,Iam trying to write a trigger where update a look up field  Opportunity__c on opportunity object by matching the Opportunity_Id__c with the Account_Id__c (String) and update the Acctount ID in the Opportunity__c (lookup) on opportunity object..

Can any one help on the below code ..


trigger UpdateAccount on Opportunity (before insert,before Update) {
    
    Set<id> accountIds = new Set<id>();
    for (Opportunity c: Trigger.new) {
       
            accountIds .add(c.Opportunity__c);   //Lookup field
            accountIds .add(c.Opportunity_Id__c);   //String
        }
    
 
  
    Map<Id, Account> acc= new Map<Id, Account>([
            select Id,AccountId__c
            from Account
            where AccountId__c In : accountIds
            ]);
    for (Opportunity c: Trigger.new) {
        if (c.Opportunity == null ){
         
            
            c.Opportunity=acc.get(c.Opportunity_Id__c).Id;

        }
    }

}
Hi ,
I am new to Developmet,Any insights can be helpful

I have custom Object Visit ,In the visit object i have 2 look up fields ,Exe__c (Look Up user),AssignTo__c (Lookup to custome Object Ex_User__c),AssignTo__c  field is a Name of the Person to whome the user is assiened
In Custome object Ex_User__c  i have Lookup field User (Lookup to User object) where i have a formula field User_Id__c which stores the UserId in  Ex_User__c object

Now ,
In Visit when i enter the AssignTo__c field .Exe__c (User Id) field should get auto popuplated upon save ..

Can any one suggest how to achive these through Trigger