• Vijaya Amarnath
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 11
    Replies
Hi All,


We are integrating from salesforce to one of our client server using REST API, here we are not sending any data to the endpoint. In the endpoint we are just sending one AgentId based on the current logged in User. This one we are doing from Vf page and class, through a custom button. Here the problem is most of the times the request reaching to the client server very late and also some times it's getting Timeout. Can anyone help us, how to resolve this?..

 
HI,
I want to query Id of a Custom LookUp or Master-Detail Filed. Example: "Opportunity" is the Parent object for "Project" object, and Opportunity__c is the field API in Project object now I want to query the Id of "Opportunity__c" field in "Project" object. How can I achive this. Can any body help on this. Thanks in Advance...
I am stuck with this if clause in my Test Clasuse. Can anybody help me. Here is my code example
public MethodName(ApexPages.StandardController Controller){

Newflag = false; //(variable Initialized as false)

if(Newflag )
{
// Do some stuff
}
//No else present or needed in this case.
}


When i am trying to pass this method by calling MethodName in my test class, 
and initializing the Newflag as true in the testclass, it not getting passed, as NewFlag is already initialized as false in the main class,
 and the testclass flag is getting overwritten by false. 

What should it do here

 
trigger NumOfContacts on contact (after insert, after update, after delete, after undelete) 
{
    
    List<account> acc = new List<account>();
    
    Set<Id> sid = new Set<Id>();
    
    if(Trigger.isDelete) 
    {
        for(contact con:Trigger.Old) 
        {
            sid.add(con.accountId);   
        }    
    }
    else
        if(Trigger.isUpdate) 
    {
        
        for(contact con:Trigger.New) 
        {            
            sid.add(con.accountId);   
        }
        
        for(contact con:Trigger.Old)
        {
            sid.add(con.accountId);   
        }   
    }
    
    else
    {
        for(contact con:Trigger.New) 
        {
            sid.add(con.accountId);   
        }
    }
    
    AggregateResult[] groupedResults = [SELECT COUNT(Id),accountId FROM contact where accountID IN :sid GROUP BY accountID ];
    
    for(AggregateResult ar:groupedResults) 
    {
        
        Id custid = (ID)ar.get('accountId');
        
        Integer count = (INTEGER)ar.get('expr0');
        
        account cust1 = new account(Id=custid);
        
        cust1.No_Of_Contacts__c = count;
        
        acc.add(cust1);
        
    }
    
    
    update acc;
    
}
Hi all,
I want to update the status field when an record is created in the 3rd object. Let say I have 3 objects A B and C. When a record is created in object C before inserting the record I want to check the email ID in the remaning objects A and B if the mail ID is matching with remaning two object i want show the flag symbool in those two objects and update the picklist in the object C. Can anyone help me over here.

Thanks in advance,
Regards,
mac.
Hi everyone,

I have this apex class for insert a new lead :
public class LeadClass
{
    public ContentVersion cont {get;set;}
    public String theValue {get;set;}
    public String company {get;set;}
    public String plate {get;set;}
    
    public LeadClass() {
        cont = new ContentVersion();
    }
    
    public PageReference NewLead(){
        List<User> updatedUsers = new List<User>();
        Decimal score = 0;
        List<User> myUsers = [SELECT Id, PhotoLead_Points__c
                              FROM User
                              WHERE Id=:userinfo.getuserId()];
        
        for (User myUser: myUsers) {
            myUser.PhotoLead_Points__c += 50;
            score = myUser.PhotoLead_Points__c;
            updatedUsers.add(myUser);
        }
        update updatedUsers;
        
        DateTime dt = DateTime.now();
        String formattedDt = dt.format('MM-dd-yyyy  hh:mm:ss');
        cont.PathOnClient = 'file' + Datetime.now() + '.jpg';
        cont.title = 'On the road ' + formattedDt;
        cont.Origin = 'H';
        upsert cont;
        
        Lead l = new Lead(PhotoLead_Image__c=cont.id, Company=company, Status='Open',LastName='On the road ' + formattedDt, Photo_location__c=theValue, Licence_plate__c=plate);
        insert l;
        
        PageReference pr = new PageReference('/'+l.id);
        return pr;
    }
    
    public PageReference doCancel()
    {
        return new PageReference('/00Q/o');
    }
    
    public PageReference game()
    {
        return new PageReference('/apex/Gamification');
    }
}
I tried to make a test class for this but i am still with a 0% code coverage :
@isTest 
public class LeadClassTest
{
    static testMethod void testMethod1() 
    {
        Lead newLead = new Lead() ;
        newLead.LastName = 'Swain';
        newLead.Company = 'BlueWave';
        newLead.Status = 'contacted';
        newLead.Photo_location__c = 'France';
        newLead.Licence_plate__c = 'GG-258-HH';
        insert newLead;
        
        User userToCreate = new User();
        
        // Do you recognize these fields?
        userToCreate.FirstName = 'Titi';
        userToCreate.LastName = 'Toto';
        userToCreate.Email = 'bdgdf@gmail.com';
        userToCreate.Username = 'fgnfy@gmail.com';
        userToCreate.Alias = 'huhu';
        userToCreate.ProfileId = '01er0010000iTqy';
        userToCreate.PhotoLead_Points__c = 50;
        insert userToCreate;
        
        userToCreate =[select IsActive from User  limit 1];
        userToCreate.IsActive = false;
        userToCreate.PhotoLead_Points__c = 100;
        update userToCreate;
        
    }
}
Any help would be appreaciated.
Thanks !
  • January 31, 2017
  • Like
  • 0
Hi All,


We are integrating from salesforce to one of our client server using REST API, here we are not sending any data to the endpoint. In the endpoint we are just sending one AgentId based on the current logged in User. This one we are doing from Vf page and class, through a custom button. Here the problem is most of the times the request reaching to the client server very late and also some times it's getting Timeout. Can anyone help us, how to resolve this?..

 
Hello,
please help the below code

Underwriting_Opportunity_Owner__c  is lookup from opportunity to user.

public static void TaskFire(List<Opportunity> opps) { 
               if (opps == null) {
            return;
        }
        Set<Id> oppownerIds=new Set<Id>();
         for (Opportunity opp : opps) {
            if (opp.Underwriting_Opportunity_Owner__c != null) {    //we need to get under writing opportunity owner id here
                oppownerIds.add(opp.Underwriting_Opportunity_Owner__c);
            }
         }
            List<user> userlist = [select id, Renewal_Threshold__c from user where id in :oppownerIds]; 
            List<Task> Taskcreation = new list<task>();

            for(Opportunity opp : opps){
            if(userlist!=null && !userlist.isEmpty()) {
            for(User ur :userlist)
            if(opps!=null && !opps.isEmpty()) {
            system.debug('test1');
            If( opp.recordtypeid==CBRenewal && opp.Amount>ur.Renewal_Threshold__c && opp.RenewalDate__c >= System.TODAY()){ 
            system.debug('test2');
                                 Task accTask = new Task();                                                                
                                    accTask.WhatId = ur.Id;                                                    
                                    accTask.ActivityDate = system.today();
                                    accTask.Type = 'Follow Up';
                                    accTask.OwnerId = Underwriting_Opportunity_Owner__c.Id;
                                    accTask.Status = 'Not Started';
                                    accTask.Priority = 'Normal';
                                    accTask.Comments__c = 'test.';
                                    accTask.Subject = 'subjectTest';
                                   Taskcreation.add(accTask);
                                   system.debug('test3'+Taskcreation.Size()); 
                                   
                  }
              }
              }
           }
           Insert Taskcreation;
        }  


Thanks,
Bheem
HI,
I want to query Id of a Custom LookUp or Master-Detail Filed. Example: "Opportunity" is the Parent object for "Project" object, and Opportunity__c is the field API in Project object now I want to query the Id of "Opportunity__c" field in "Project" object. How can I achive this. Can any body help on this. Thanks in Advance...

Is it possible to do a SOQL query that allows me to obtain the SF Id of a master-detail custom field I have in a custom object?  I'm not wanting the ID for a record in the object I want the Id for the actual field.  Field API name is Opportunity__c in a custom object with an API name of Win_Form__c.