• Angel30
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 5
    Replies
Hi All,

 I am trying to display loading image using action status when we navigate from one vf page to another.
 We are using custom label "loading message" and use this in our vf page. We have provided different translations for the message as well in Spanish.
when i navigate from one vf page to another vf page it doesnt show the translated value of the loading image.

Below is a snippet

<apex:outputPanel styleClass="popupVidBackground">
                <apex:form id="intro">  
                <apex:actionStatus id="loading" >
                        <apex:facet name="start">
                                <c:LoadingStatusComponent BackColor="#ffffff"
                                                       borderColor="#6B6B6B"
                                                       borderSize="1"
                                                       height="50px"
                                                       width="120px"
                                                       margintop="-25px"
                                                       marginleft="-60px"
                                                       ImageUrl="{!$Resource.saving}"
                                                       Message="{!$Label.LoadingMessage}"/>
                        </apex:facet>
                    </apex:actionStatus>
                    <apex:actionfunction name="loading" status="loading" rerender="intro"/>
                    <body>
                        <p align="center" style="padding-top: 10px; margin: 40px;">                            
                            {!loadIntro}
                        </p>
                    </body> 
                </apex:form>
                </apex:outputPanel>
  <script>
      window.onload = loading();
  </script>              


When i navigate from one vf page to another vf page i can see the message as loading but the translated version of loading is not coming.

Kindly help
Hi,
I  have a controller class A which has two methods ,first method which fetches ContactID and 2nd  method fetches the Module Id.
I am creating a page whose controller class B will fetch values from Methods of Class A.
Question-1 : How to call methods of controller A in controller B.
Should we write this in the constructor of the new controller B or a separate method inside it to call the Controller class A methods.


Once i fetch the values , i need to create a record in a junction object which will associate contactId and Module Id(which is fetched from the methods). Here id the Module is 1,2 only then create record in junction object else not required.How shall we put this logic.

Kindly help as i am new to this.
 
Hi Team,
I am new to VF and sites.
we have a site login used by the end users.
When the user logs in from the site ,it should fetch the parameters (contactid of the user and the module) from the URL and based on this it should create a record in another object.
Could you please help me in giving a frame how should it be created using custom controllers.

Thankyou
Hi All,

There is a case where we need to create a generic vf component in order to show spinner.
The VF Component will be used as spinner in VF Page when certain actions takes some time. The Spinner will be displayed to user till the back end actions complete.
It would be great if anybody can help on this.
  • September 17, 2018
  • Like
  • 0
Hi All,

I know this is not the very correct forum to have a question on Servicemax product.
However , i would like to know if anybody can suggest me how should we start learning about servicemax.
I have the pdf link however its a vast one and initial flow of servicemax process is something i feel is missing.
Could anybody tell me a way on how should we start this step by step.

Any help will be appreciated and apologies for getting this here!!


Thanks in advance!
Hi All,

I have a scenario where I need to have an account to havev only one opportunity created per day.
Can anybody provide me with the best configuration solution for this.
Hi All,

I am reading through the vf guide however i am not able to visualize the difference between the get;set methods.
i understand that get method will basically fetch data from controller and display in vf page and setter methods are used to pass the values from page to the controller.

i see that there are different ways of writing this.1 is to put logic for each getter and setter method and another method is to just put {get; set;}
Can anybody tell me the difference and how it works .

Thanks a lot!! 
Hi All,

I was reading through the apex guide and i came across the statement which actually i didnt understand.
Could you please explain me that.

"The @isTest annotation can take multiple modifiers within parentheses and separated by blanks."

What does is mean here .An example /scenario would actually help.

Thanks a lot in advance!

Deepshikha
I have a requirement to count the number of opportunity line items and populate it to the account.
I was thinking to use Aggregate queries,but is it poosible to do it using this.
I am in process of creating this however i am stuck:

public with sharing class opportunityTriggerHandlerClass {
    public static void countofOliItemsMethod(List<OpportunityLineItem> oliList){
        Set<Id> oppIdSet = new Set<Id>();
        Set<Id> accIdSet = new Set<Id>();
        for(OpportunityLineItem oli: oliList){
            oppIdSet.add(oli.OpportunityId);
        }
        for(Opportunity oppty : [SELECT ID,AccountId FROM Opportunity WHERE Id IN: oppIdSet]){
             accIdSet.add(oppty.AccountId) ;
        }
        List<AggregateResult> aggr = [SELECT OpportunityId,Opportunity.AccountId,Opportunity.Account.Name,count(Id)oli FROM               

                                                          OpportunityLineItem 
                                                          WHERE Opportunity.AccountId IN:accIdSet GROUP BY Opportunity.AccountId] ;
    }
}

I face an error that "Field must be grouped or aggregated: OpportunityId".

Can anybody tell me how should we approach here.

Thanks in advance!
Hi All,
I am trying to learn apex.I was writing a scenario which verifies and prevents creation of account with the same name. i wrote the below code:

public static void preventduplicateAccountsMethod(List<Account> accList){
        System.debug('accList' +accList);
        Set<String> accNewSet = new Set<String>();
        for(Account acc : accList){
            accNewList.add(acc.Name) ;
            accNewSet.add(acc.Name) ;
            System.debug('accNewList' + accNewList);
            
        }
        List<Account> accDupeList = new List<Account>([SELECT Id,Name from Account where Name IN : accNewSet]) ;
        System.debug('accDupeList' + accDupeList);
        if(accDupeList.size() >0){
            for(Account acc : accList){
                acc.addError('cannot create account with same name') ;
            }
        }
     }//end of method


This works fine.But when i try uploading few accounts from the csv into the system i get error for all the records which is wrong.I assume that it should throw error only for the record which is a duplicate and not for all.
Could  you please help me in this.
Hi,
I  have a controller class A which has two methods ,first method which fetches ContactID and 2nd  method fetches the Module Id.
I am creating a page whose controller class B will fetch values from Methods of Class A.
Question-1 : How to call methods of controller A in controller B.
Should we write this in the constructor of the new controller B or a separate method inside it to call the Controller class A methods.


Once i fetch the values , i need to create a record in a junction object which will associate contactId and Module Id(which is fetched from the methods). Here id the Module is 1,2 only then create record in junction object else not required.How shall we put this logic.

Kindly help as i am new to this.
 
Hi All,

There is a case where we need to create a generic vf component in order to show spinner.
The VF Component will be used as spinner in VF Page when certain actions takes some time. The Spinner will be displayed to user till the back end actions complete.
It would be great if anybody can help on this.
  • September 17, 2018
  • Like
  • 0
@RemoteAction
    public static List<Lawson_Division__c> getData(String sObjVal,String labelField,String valueField,String param){
        param = String.escapeSingleQuotes(param);
        Id usrId = UserInfo.getUserid();
        String buvalues = [select Muni_Business_Unit_ID__c from user where id=:usrId].Muni_Business_Unit_ID__c;
        if(buValues == null){
           return null; 
        }
        if(buValues != null &&  buValues.EqualsignoreCase('All')){
           return Database.query('SELECT '+valueField+','+labelField+',Business_Unit_Number__c,Area__c,Region__c,BU_Description__c FROM '+sObjVal+' WHERE '+labelField+' LIKE \''+param+'%\''); 
        }
        List<String> buIds = buValues.split(',');
        return Database.query('SELECT '+valueField+','+labelField+',Business_Unit_Number__c,Area__c,Region__c,BU_Description__c FROM '+sObjVal+' WHERE '+labelField+' LIKE \''+param+'%\' and business_unit_number__c in :buIds');
    }
   
here is my class


global class BT_Invoicing_New_Override_Crtl {

    public ApexPages.StandardController stdCon;
    public BT_Invoicing__c btinvoice{get;set;}
    public Static Integer BtjoblstSize;
    public Double Local_DFE_Quantity;
    public Double Local_Invoice_Cost_excl_vat;
    public String recordId;
    BT_Invoicing__c btinvoiceRecord;
    Public Static String btEstimateNumber;

    public BT_Invoicing_New_Override_Crtl(ApexPages.StandardController controller) 
    {
        stdCon= controller;
        btinvoice= (BT_Invoicing__c)stdCon.getRecord();
        recordId=ApexPages.currentPage().getParameters().get('id');
    } 
   
    public PageReference Save(){
    try{

        btinvoiceRecord= (BT_Invoicing__c)stdCon.getRecord();
       
        
            if(btinvoiceRecord.Invoice_Cost_excl_vat__c==null)
            Local_Invoice_Cost_excl_vat=0;
         else
            Local_Invoice_Cost_excl_vat=btinvoiceRecord.Invoice_Cost_excl_vat__c;
            
          if(btinvoiceRecord.DFE_Quantity__c==null)
             Local_DFE_Quantity=0;
          else
              Local_DFE_Quantity=btinvoiceRecord.DFE_Quantity__c;
            
     if(btinvoiceRecord.Pay__c=='Yes'&& ( Local_Invoice_Cost_excl_vat- Local_DFE_Quantity > 0)
                                         && btinvoiceRecord.Reject_Invoice__c==false && btinvoiceRecord.Invoice_In_Query__c==false)
          btinvoiceRecord.Invoice_Status__c='PAID-DFE';
     else if(btinvoiceRecord.Pay__c=='Yes'&& (Local_Invoice_Cost_excl_vat- Local_DFE_Quantity==0) 
                                         && btinvoiceRecord.Reject_Invoice__c==false && btinvoiceRecord.Invoice_In_Query__c==false)
          btinvoiceRecord.Invoice_Status__c='Paid';
     else if(btinvoiceRecord.Pay__c=='No' && btinvoiceRecord.Reject_Invoice__c==false && btinvoiceRecord.Invoice_In_Query__c==false)
          btinvoiceRecord.Invoice_Status__c='Active';
        
     
        
        upsert btinvoicerecord;
                
        PageReference pageref = new Pagereference('/'+btinvoicerecord.id);
        pageref.setRedirect(true);
        return pageref;
        
        return null;
      }
    catch(Exception ex){
        ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,ex.getDMLMessage(0));
        ApexPages.addMessage(msg);
        return null;
    }    
  }
  
  public PageReference SaveandNew(){
    try{
        stdCon.Save();  
        return new PageReference('/'+stdCon.getRecord().getSObjectType().getDescribe().getKeyPrefix()+'/e?');
         
      }
    catch(Exception ex){
        ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,ex.getDMLMessage(0));
        ApexPages.addMessage(msg);
        return null;
    }    
  
  }
  
  @RemoteAction
 Public Static Integer GetEstimateListsize(String btestimateno)
  {
         List<BT_Job__c> Btjoblst=[Select Id,Name,Estimate_No__c From BT_Job__c Where  Estimate_No__c=:btestimateno];
         BtjoblstSize=Btjoblst.size();
         System.debug('BtjoblstSize='+BtjoblstSize);
         return BtjoblstSize;
  }
  
   
}

n this is my test class

@istest
public class BT_Invoicing_New_Override_Crtl_Test {
    
     public static testmethod void myTestUnit1(){
      PageReference pageRef = Page.BT_Invoicing_New_Override;
        Test.setCurrentPage(pageRef);
        
        BT_Invoicing__c btInvObj = new BT_Invoicing__c();
        btInvObj.Invoice_Cost_excl_vat__c=55.20;
        btInvObj.DFE_Quantity__c=45.30;
        btInvObj.Pay__c='Yes';
        btInvObj.Reject_Invoice__c=false;
        btInvObj.Invoice_In_Query__c=false;
        
        insert btInvObj;
         
          ApexPages.StandardController sc = new ApexPages.standardController(btInvObj);
       BT_Invoicing_New_Override_Crtl sic = new  BT_Invoicing_New_Override_Crtl(sc);
      sic.Save(); 
     } 
     public static testmethod void myTestUnit2(){
      PageReference pageRef = Page.BT_Invoicing_New_Override;
        Test.setCurrentPage(pageRef);
        
        BT_Invoicing__c btInvObj = new BT_Invoicing__c();
        btInvObj.Invoice_Cost_excl_vat__c=45.30;
        btInvObj.DFE_Quantity__c=45.30;
        btInvObj.Pay__c='Yes';
        btInvObj.Reject_Invoice__c=false;
        btInvObj.Invoice_In_Query__c=false;
        insert btInvObj;
         
         
     
         ApexPages.StandardController sc = new ApexPages.standardController(btInvObj);
       BT_Invoicing_New_Override_Crtl sic = new  BT_Invoicing_New_Override_Crtl(sc);
      sic.Save(); 
     } 
     public static testmethod void myTestUnit3(){
      PageReference pageRef = Page.BT_Invoicing_New_Override;
        Test.setCurrentPage(pageRef);
        
        BT_Invoicing__c btInvObj = new BT_Invoicing__c();
        btInvObj.Invoice_Cost_excl_vat__c=00.00;
        btInvObj.DFE_Quantity__c=00.00;
        btInvObj.Pay__c='No';
        btInvObj.Reject_Invoice__c=false;
        btInvObj.Invoice_In_Query__c=false;
        insert btInvObj;
         
         
    
         ApexPages.StandardController sc = new ApexPages.standardController(btInvObj);
       BT_Invoicing_New_Override_Crtl sic = new  BT_Invoicing_New_Override_Crtl(sc);
      sic.Save(); 
     } 
    public static testmethod void myTestUnit4(){
      
       
        BT_Invoicing__c btInvObj = new BT_Invoicing__c();
        btInvObj.Invoice_Cost_excl_vat__c=10.00;
        btInvObj.DFE_Quantity__c=10.00;
        btInvObj.Pay__c='No';
        btInvObj.Reject_Invoice__c=false;
        btInvObj.Invoice_In_Query__c=false;
        insert btInvObj;
       BT_Invoicing__c btInvObj1=[select id , Invoice_Status__c from  BT_Invoicing__c where id=:btInvObj.id];
       
        PageReference pageRef = Page.BT_Invoicing_New_Override;
        Test.setCurrentPage(pageRef);
        Test.startTest();
      
      ApexPages.StandardController sc = new ApexPages.standardController(btInvObj1);
       BT_Invoicing_New_Override_Crtl sic = new  BT_Invoicing_New_Override_Crtl(sc);
      sic.SaveandNew();
      
        

       }
}

I need to increase the code coverage ,its nt covering remote action method and catch block
please help me out