• GauravTrivedi
  • NEWBIE
  • 145 Points
  • Member since 2014
  • Senior Consultant

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 8
    Questions
  • 43
    Replies
I was thinking to create a mechanism which will give information about the deployment statuses using Metadata API. But I stuck at the point where I am not able to query records related to AsyncResult/DeployResult. I don't know whether it is possible or not.
Any suggestions would be really helpful for me. Thanks!
I need to create a VF Page for Account for creating, viewing and editing records. What is the best approach to handle the fields for opening them for edit and view only mode? Can we use the same VF page to handle all the scenarios? How to code controller logic to handle multiple scnearios(save, edit and view)?
public with sharing class SendNamerFinacialSdlGroup{
i have the method where i will check the lead (lead records related to group members) owners and status is not changed with in 24 hoursthen  i will update the checkbox__x to true.

Currently i have written the code until fetching the leads related to particulr public group of test_Team.Please suggest me how to check the existed old status with new lead status in apex class to process furthur.
 public static void updateNamercheckbox(List<Lead> allleadlist){
       set<id> useridset=new set<id>();
       set<id> leadid=new set<id>();
       
       for(Lead led:allleadlist){
       leadid.add(led.ownerId);
       }
        List<Group> pbgrpid = [select id from Group where type='Regular' AND DeveloperName='test_Team'];
        List<GroupMember> userids = [select UserOrGroupId,GroupId  from GroupMember where GroupId IN:pbgrpid];
          for(GroupMember gmid:userids){
            useridset.add(gmid.UserOrGroupId);
            }
          system.debug('useridset' +leadid);
    
}
}
User-added image


Hi
I have a below requirement,
I have created an object for calculating mileage vs cost for bike
I have the below fields in my object:
 Object Name:
API NameMileage_vs_Cost__c
Bill AmountBill_Amount__c
Current ReadingCurrent_Reading__c
DateDate__c
Past ReadingPast_Reading__c
PetrolUserName__c
Petrol User is a master object for( Mileage_Vs_ Cost__c) object
Example : For the first time when I save my record, current reading is zero fueled on 3/21/2016,
I will be travelling whole month and next time when I am ready to fuel the petrol , I will be entering some 1000 kms as current reading and when I do this process I want the past reading(i.e; previous month's current reading which is 0(zero) when I filled fuel on 3/21/2016) to  get populated in Past_reading__c filed of my record….
So that I can calculate mileage = (Current reading - past reading) and based on this further developments I can do on the page; can any one help me in this requirement I feel grateful and I am trying it using List and triggers and am failing…
Can any one help me out.The code coverage is getting low.In the code i have a String.value of(),how to call this in a test class.Any help very much appreciated.
Trigger :
trigger UpdateRenewableFields on Contract(after insert) 
{
    Set<Id> oliIds = new Set<Id>(); 
    Map<string, Contract> contractMap = new Map<string, Contract>();
    
    List<OpportunityLineItem> oliIdsToUpdate = new List<OpportunityLineItem>();
    
    for(Contract c: Trigger.new)
    {
        if(c.Opportunity_Product_Id__c != null && c.Opportunity_Product_Id__c != '')
        {
            oliIds.add(c.Opportunity_Product_Id__c); 
            if(c.Parent_Opportunity_Product_Id__c != null && c.Parent_Opportunity_Product_Id__c != '')
            {       
                contractMap.put(c.Parent_Opportunity_Product_Id__c , c);
            }
        }
    }
    if(oliIds.size() > 0)
    {
        //Get Parent OLI Ids//
        List<OpportunityLineItem> parentOliList = [Select Id,Parent_Opportunity_Product_Id__c, Contract__c from OpportunityLineItem where Id in: oliIds];
        Set<Id> parentOlis = new Set<Id>();
        Map<Id, OpportunityLineItem> oliMap = new Map<Id, OpportunityLineItem>();
        for(OpportunityLineItem oli:parentOliList)
        {   
            oliMap.put(oli.id, oli);///Map use to update OLI
            parentOlis.add(oli.Parent_Opportunity_Product_Id__c);
        }
        
        List<Contract> parentContractList = [Select Id,Renewal_Contracts_Numbers__c,Opportunity_Name__c,Opportunity_Product_Id__c,  Renewal_Status__c,Renewal_Amount__c,Renewal_ARR__c from Contract where Opportunity_Product_Id__c in: parentOlis];
        
        List<Contract> contractsToUpdate = new List<Contract>();
        
        for(Contract parent: parentContractList)
        {
            if(parent.Opportunity_Product_Id__c != null && parent.Opportunity_Product_Id__c != '' && contractMap.containsKey(String.valueOf(parent.Opportunity_Product_Id__c)))
            {
                Contract child = contractMap.get(String.valueOf(parent.Opportunity_Product_Id__c));
                //parent.Renewal_Contract__c = true ;
                parent.Renewal_Contracts_Numbers__c = child.Id ;
                parent.Renewal_Status__c = 'Renewed';
                parent.Renewal_Amount__c = child.Subtotal_Price__c ;
                parent.Renewal_ARR__c = child.Annual_Recurring_Revenue__c ;
                
                if(parent.Multi_year_Sub_extension_contract__c)
                {
                    parent.Actual_renewal_date__c = child.Actual_renewal_date__c;
                }
                contractsToUpdate.add(parent);
            }
        }
        System.debug('contractsToUpdate::' + contractsToUpdate);
        
        ///Updating Opportunity Line Item with Contract Number////
        for(Contract c: Trigger.new)
        {
            if(oliMap.containsKey(c.Opportunity_Product_Id__c))
            {
                OpportunityLineItem oli = oliMap.get(c.Opportunity_Product_Id__c);
                oli.Contract__c = c.Id;
                oliIdsToUpdate.add(oli);
            }
        }
        /////////////////////////////////////////////////////////
        try
        {
            if(contractsToUpdate.size() > 0)
            {
                update contractsToUpdate;
            }
            if(oliIdsToUpdate.size() > 0)
            {
                update oliIdsToUpdate; 
            }
        }
        catch(Exception e)
        {
            System.debug('ERROR::' + e.getMessage());
        }
    }
}
Test Class :
@IsTest
public class TestUpdateRenewableFields{
static testmethod void testUpdateRenewable(){
Account acc10 = new Account(Name='Testing SubscriptionClone', BillingStreet='Banjara hills', BillingCity='Hyd', BillingState='TS',
                                    BillingPostalCode = '500084', BillingCountry = 'India', Phone = '100', Industry = 'Banking',
                                    Type = 'Paid', Customer_Type__c = 'Customer', Customer_List__c = true,PPAS__c = false,
                                    PPCD__c = false,PPSP__c = false, PGSQL__c = false,PPAS_Developer_Sub__c = false,      
                                    PPSP_Developer_Sub__c = false, PGSQL_Developer_Sub__c = false,RDBA__c = false,  
                                    Services__c = false,Training__c = false,SteelEye__c = false,Jump_Start_Subscription__c = false    );  
        insert acc10 ;
        
        
        contact cc10 = new contact(FirstName ='Test Contact Subscription', LastName ='Opptyclone', Role__c='Subscription Administrator',AccountId=acc10.Id);
        insert cc10;
        
        Opportunity opty10 = new Opportunity(Name = 'Test SubscriptionOppty', StageName ='Proposal/Price Quote', Probability =60, 
                                            CloseDate = System.Today(), Type = 'Existing Customer', Assigned_Sales_Engineer__c = null, 
                                            Update_Complete__c = true, Partner__c = 'None', Anchor__c='Non Anchor', AccountId = acc10.Id,
                                            Payment_Type__c = 'Order Form', LeadSource = 'Subscription Renewal');
        insert opty10;
        
        
        
        
        list<OpportunityContactRole> opptyConRolelist15 =  new list<OpportunityContactRole>{
            new OpportunityContactRole(ContactId = cc10.Id, OpportunityId = opty10.Id, IsPrimary = false, Role = 'Subscription Administrator')
        };   
        insert opptyConRolelist15;
        
        product2 p2 = new product2(Name ='Postgres Plus Enterprise Edition Unicores', Product_Name1__C='Product - Subscription', Product_Group__c='PPAS',
                                    IsActive = true, Description='Postgres Plus Enterprise Edition Unicores', ARR_Impact1__c = 'Yes');
        insert p2;
        
        PricebookEntry pbey = new PricebookEntry(Product2ID=p2.id, Pricebook2ID= test.getStandardPricebookId(), UnitPrice=50, isActive=true);
        insert pbey;
        
        Opportunitylineitem ooli10 = new Opportunitylineitem(OpportunityId = opty10.Id, PricebookEntryId = pbey.Id, Quantity =4, 
                                    Start_Date__c = System.today(), End_Date__c =  System.today() + 100, Type_of_Contract__c='None',
                                    Term__c =12, Type_Of_Product__c='Single Year Subscription', Type_of_ARR__c= 'New Addition ARR',
                                    TotalPrice=1750, No_ARR__c = false, In_Year_Billing__c = 10);
        insert ooli10;
        
        Opportunitylineitem ooli15 = new Opportunitylineitem(OpportunityId = opty10.Id, PricebookEntryId = pbey.Id, Quantity =4, 
                                    Start_Date__c = System.today(), End_Date__c =  System.today() + 100, Type_of_Contract__c='None',
                                    Term__c =12, Type_Of_Product__c='Single Year Subscription', Type_of_ARR__c= 'New Addition ARR',
                                    TotalPrice=1750, No_ARR__c = false, In_Year_Billing__c = 10, Parent_Opportunity_Product_Id__c=ooli10.Id);
        insert ooli15;
        
       // list<Contract> contrlist = new list<Contract>{
          Contract contrlist= new Contract(CurrencyIsoCode='USD', Annual_Contract_Value__c =5000, Type_Of_Product__c='Single Year Subscription',
                                        Notes__c='Contract is getting created', Opportunity_Product_Id__c= ooli10.Id, Contracts_In_Year_Billing__c=1500,
                                       AccountId=acc10.Id);
                                       
         
        insert contrlist;
        
        Contract contr1 = new Contract(CurrencyIsoCode='USD', Annual_Contract_Value__c =5000, Type_Of_Product__c='Single Year Subscription',
                                        Notes__c='Contract is getting created', Opportunity_Product_Id__c= ooli10.Id, Contracts_In_Year_Billing__c=1500,
                                       AccountId=acc10.Id);
          
          insert contr1;                          
         Test.StartTest();
        contrlist.Renewal_Contracts_Numbers__c=contr1.id;
        contrlist.Renewal_ARR__c=contr1.Annual_Recurring_Revenue__c;
        contrlist.Renewal_Amount__c=contr1.Subtotal_Price__c;
        contrlist.Renewal_Status__c='Renewed';
        update contr1;
        Test.StopTest();
        
        }
        }
The lines which are not getting covered :
{
            if(parent.Opportunity_Product_Id__c != null && parent.Opportunity_Product_Id__c != '' && contractMap.containsKey(String.valueOf(parent.Opportunity_Product_Id__c)))
            {
                Contract child = contractMap.get(String.valueOf(parent.Opportunity_Product_Id__c));
                //parent.Renewal_Contract__c = true ;
                parent.Renewal_Contracts_Numbers__c = child.Id ;
                parent.Renewal_Status__c = 'Renewed';
                parent.Renewal_Amount__c = child.Subtotal_Price__c ;
                parent.Renewal_ARR__c = child.Annual_Recurring_Revenue__c ;
                
                if(parent.Multi_year_Sub_extension_contract__c)
                {
                    parent.Actual_renewal_date__c = child.Actual_renewal_date__c;
                }
                contractsToUpdate.add(parent);
            }
        }
Any help very much appreciated.


 

I like to place my Report on FTP folder automatically on weekly basis and my report wont exceed 10 MB size, i tried dataloader:io but it didnt help me to schedule on weekly basis, in dataloader i can schedule daily only for free version.My requirement is to place only one report otherwise i go for paid version.
Please suggest me if you have any free tool and some feasible solution.
thanks
soma

I have deployed a trigger to live but it seems to not populate the service Contract but in sandbox it does.
The name of the fields are the same. The trigger is
I have tested the below on our test system and it works correctly. The fields are the same in Live and Sandbox but the trigger will not populate the service contract field on a case.
I have tried removing the recordtype, using specific account but no luck on Live.
trigger UpdateServiceContract on Case (before insert,before update, after update) {
if (trigger.isBefore && trigger.isInsert) {
for (Case c : trigger.new) {
if (c.RecordTypeID == '012D0000000NWyPIAW')
if (c.service_contract__c == NULL){
try{
//c.Service_Contract__c = [select Id from ServiceContract where AccountId ='810D0000000Cfza' and Primary_Service_Contract__c = True].id;
c.Service_Contract__c = [select Id from ServiceContract where AccountId = :c.AccountId and Primary_Service_Contract__c = True limit 1].id;
}catch(QueryException e) {
//No records found. Maybe you should set it to Null
}
}
}
}
}

Is there a trigger log
 

 

Hi All I have a futre class and I have written a test class for the same which is passing but the parent class is just not covering any percent. Can some one hellp. Below is class and the test class.

Class
global class ABfutureclass {
   
  
    @future
    public static void createABdetails(){
          string timePSetName=Label.Time;
       PermissionSet timePSet =[SELECT Id,IsOwnedByProfile,Label FROM PermissionSet where Name=:timePSetName limit 1];
        Id myID2 = userinfo.getUserId();
        string permissionsetid = timePSet.id; 
        List<PermissionSetAssignment> lstPsa = [select id from PermissionsetAssignment where PermissionSetId =: permissionsetid AND AssigneeId =:myID2];
    
        if(lstPsa.size() == 0)
        {
            PermissionSetAssignment psa1 = new PermissionsetAssignment(PermissionSetId= permissionsetid, AssigneeId = myID2 );
            database.insert(psa1);
        }
    }

}



Test Class

@isTest
public class ABfutureclasstest {
    
    public static testMethod void createABdetails(){
        test.startTest();
        Profile Profile1 = [SELECT Id, Name FROM Profile WHERE Name = 'Basic Profile'];
       
     
      User u = [SELECT Id FROM User WHERE ProfileId =:Profile1.Id AND isActive = true LIMIT 1];
        PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name =: Label.Time];
        system.runAs(u){
   PermissionSetAssignment psa = new PermissionSetAssignment();
        psa.AssigneeId = u.Id;
        psa.PermissionSetId = ps.Id;
        insert psa;
        }
        test.stopTest();
    }

}
Hey all,

I'm creating a workflow that I'd like to trigger when a Billing Contact is updated - not when one is added for the first time and not when it is changed to a blank text value.  I had the following formula, but it's triggering when it changes from blank to a name and I just want it to trigger when it changes from one name to another name.  Let me know if I can provide any more information, thanks!

AND(ISCHANGED(Billing_Contact__c )


Hi
VFPAGE
<apex:inputFile filename="{!fileName}"   value="{!resume}"/>
CONTROLLER
public String fileName {get; set;}
public Blob resume {get; set;}
 private Empolyee_Details__c empDetail;

  try{
        if(resume!=null){
        Attachment attach=new Attachment();
        attach.Body=resume;
        attach.Name=filename;
        attach.ParentID=empDetail.id;
        upsert(attach);
        
        
        }
           The above one is the FILE ATTATCHMENT CODE .In that code i didnt get any errors but file was not uploading .please tell me any issues are there for above code.

Thansk&Regards
RangaReddy

Hi,

I've a field for Phone number of type String. And the format of it would be 111-222-3333. I want to remove the '-' from it and it should look like 1112223333. Please suggest me a validation rule or formula to achieve this.

Thanks,
vasavi 

I have to create a multipage word document, which have company logo in header and page number in footer.


For a doc, header is same for each page. But the company logo is dynamic, depends on for which company i have to create the document.


The document is also rich formatted, means contains several tables etc.


Two approaches i have used.

a) Create a VF page and specify the contentType as 'application/msword'.

b) Use word template with mail merge feature.


a) Create a VF page and specify the contentType as 'application/msword'.
-----------------------------------------------------------------------------------------------------

a large single page document is created (I am using word 2010), instead of a multi page document. when i opened that in open office it is a multi page documnet. but header is appearing only on first page and footer on last page.

I have found that it is too difficult to add styling in this approach, because word is not supporting page's css. Main issue

is with headers and footers.


b) Use word template with mail merge feature.
------------------------------------------------------------------

standard Mail merge is not supported on firefox. salesforce mail merge is not worked with Word 2010 also.

word template created with word 2007 is only supported. but with that also i am not successful to insert image in

merge_field.


create a textfield with absolute url of the image. than create a merge field on the template for that. but the url is placed

in the generated word document using mail merge.

I have a second approach for that. Use 'INCLUDEPICTURE'  as follows

{INCLUDEPICTURE "<<merge_field>>"}, but it file not found error.

when used {INCLUDEPICTURE "url"} it succedded.
several other variations used with {INCLUDEPICTURE "<<merge_field>>"}, but no success.

I am totally confused, which approach i must follow to achieve the expected.

Thanks