• AlbertoSM
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 4
    Replies
Hi everyone,

I have this input type button but I want to display an Image depending on the language of the visualforce.
 
<input type="button" image="{!If(URLFOR($Resource.IKEA_Boton_Enviar_CasCat))}" style="cursor:pointer;border-radius: 10px;" data-role="none" onclick="submitForm()"/>



I have 4 images depending on the language: 
Image1 for Spanish
Image2 for Euskera
Image3 for Catalan
Image4 for english

I don't know how to do it. I've seen multiple times this way to do it, but it's not working:
<input type="button" image="{!If(idioma == 'es', URLFOR($Resource.Image1), URLFOR($Resource.Image2))}" style="cursor:pointer;border-radius: 10px;" data-role="none" onclick="submitForm()"/>



Thanks in advance and for your time
Cheers!
​Alberto
Hi everyone,

I have this visualforce where I introduce a Postal Code here:
<apex:inputText id="idPostalCodeIntroduced" value="{!PostalCodeIntroduced}" style="height: 22px; width: 100%;"/>
and just the stores that have postal code are shown in this line (postal code and store have a master detail relationship)
<apex:selectList value="{!storeChoosen}" multiselect="false" size="1" id="idstoreChoosen"  style="height: 22px; width: 100%;">
                                            <apex:selectOptions value="{!relatedStore}"/>
                                        </apex:selectList>
Also I have this line:
window.location.href="/apex/IK_VF_Formulario?PostalCode="+PostalCodeIntroduced+" en Store&Language=es";

And the corresponding controller:
public with sharing class myController {
    public String PostalCodeIntroduced {get; set;}
    public myController(){
          PostalCodeIntroduced = ApexPages.currentPage().getParameters().get('PostalCode');
    }
 
    public List<SelectOption> getRelatedStore(){
        List<CP__c> lstRelatedStores = [SELECT Store__c, Name, Store__r.Name 
                                                          FROM CP__c WHERE Name =: PostalCodeIntroduced ];
        List<SelectOption> RelatedStores= new List<SelectOption>();
        RelatedStores.add(new SelectOption('', '--None--'));
            for(CP__c tiCP: lstRelatedStores ){
                RelatedStores.add(new SelectOption(tiCP.Store__r.Name, tiCP.Store__r.Name));
            }    
                 
       return RelatedStores;
    }
}
The issue comes when the value I put in visualforce is not passing to the controller. But the weird thing is, if I put by hand (in the code) the PostalCode (example 90001) in order to show the related stores to this one, it works!!!! 
Example: 
List<CP__c> lstRelatedStores = [SELECT Store__c, Name, Store__r.Name 
                                                          FROM CP__c WHERE Name =: 90001 ];
Name is the numbers you put in the postal code, for the moment no problem with that


Hope it is clear for you guys
Thanks a lot in advance
Cheers!
Alberto



 
Hi everyone,

Two custom objects. They are related as Master Detail:
Store__c and Postal_Code__c. 

I have a visualforce that, depending of the Postal_Code__c you introduce, shows the store that corresponds to that postal code.

Can anyone tell me how to write the function in the controller and the corresponding query?

Thanks a lot for your time!
Cheers
Alberto

 
Hi Everyone

I need to relate two standard objects (Lead and Event) for whatever reason. Everytime a record is changed in Lead, it has to change in Event. But in both ways, I mean, from Lead to Event and from Event to Lead.

it is simple by doing it in one way , I have a trigger (working fine) that update a Event record everytime a record is changed in Lead. But, and here comes the question, how do I do the update in both directions?

I thought doing it with another trigger but it would be an infinite loop. Once the trigger on Lead updates the record in Event, the trigger on event would fire and so on...

Anyone can help me?

Thanks in advance for your time
Cheers!!
Alberto
Hi everyone

I'm witting one of my first Visualforces.This one:
<apex:page Controller="ScenariosController">
    <apex:pageMessages ></apex:pageMessages>
    <apex:pageBlock >
    
        <apex:pageBlockTable value="{!}" var="item" >
    
             <apex:column value="{!item.Scenario__c}"                 style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}"/>
            <apex:column value="{!item.PCK_Tower_Height__c}"         style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}" />
            <apex:column value="{!item.NUM_Quantity__c}"             style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}" />
            <apex:column value="{!item.CHK_Scenario_Principal__c}"   style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}"/>
            <!-- background-color:{!If(opp.StageName =='Negotiation/Review','#7CFC00',If(opp.StageName =='Closed Won','#DEB887','#DC143C'))}; -->
    
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


And this controller:
 
public class ScenariosController{
      
    List<Quote_line__c> quoteLineList;
    
    //Populate a list with all the quote Lines != NULL ordered by NUM_Scenario__c DESC
    public List<Quote_line__c> getQuoteLineItems(){
       Id budgetId= ApexPages.currentPage().getParameters().get('Id');
       if (budgetId!= NULL){
           List<Quote_line__c> quoteLineList = new List<Quote_line__c>();
           quoteLineList = [SELECT id,name,lkp_product__r.family__c, lkp_product__r.Nominal_Power_MW__c, CHK_Included__c,
                                        NUM_Cost__c,LKP_Configurator__c,Sum_mandatory_fields_for_budReq_unfill__C,Date_from__c,Date_to__c,
                                        TXT_Tower_First_Value__c, NUM_Quantity__c,LKP_Product__c,MD_quote__c, NUM_Scenario__c, CHK_Scenario_Principal__c
                             FROM quote_line__c 
                             WHERE NUM_Scenario__c != NULL
                             ORDER BY NUM_Scenario__c
                             DESC];
                           }
        return quoteLineList;
    }
}



I don't know how to continue. What I know is, I have to define the get method to pass data from the controller to the Visualforce but no idea about where and how to put it.

Thanks in advance for your time!
Cheers!
Alberto
Hi everyone,

I have to test this class:

List<Account> oldAccounts   = Trigger.old;
        for(Account check : oldAccounts){
            if(check.Account_ID__c!=null){
                check.addError('Accounts that have SAP Account ID can not be deleted');
            }
        }

I know that in theese cases one has to use try/catch methods to solve the test.
But I've been trying for hours and I don't know how to solve it.

I post what I did so far, it covers everything except last line ('addError'):

@isTest
public class TriggerAccountDeleteTest {
      public class MyException extends Exception {}
       static testMethod void metodoDeletAccount(){
        
             //Create an Account with his required fields
             Account accountPrueba = new Account();
                accountPrueba.Name = 'Siemens2';
                accountPrueba.Account_Country__c = 'a014E000005XNKh';
                accountPrueba.Language__c = 'a064E0000060Wnr'; 
                accountPrueba.Department__c = 'Services';
            
            //Insert it
            insert accountPrueba ;
           
            //Test.startTest();  
                try{
                    delete accountPrueba;
                    Account deletedAccount = [SELECT Id, IsDeleted FROM Account WHERE Id = :accountPrueba.Id ALL ROWS];
                    System.assertEquals(deletedAccount.IsDeleted, true);
        
                    }
                 catch(Exception e){
                    Boolean b = null;
                    accountPrueba2.Account_ID__c = String.valueOf(b);
                    System.assert(e.getMessage().contains('Accounts that have SAP Account ID can not be deleted'));
                 }
               Test.stopTest();   
        
    }
}
Thank you for your time
Cheers,
Alberto
Hi everyone,

I have this visualforce where I introduce a Postal Code here:
<apex:inputText id="idPostalCodeIntroduced" value="{!PostalCodeIntroduced}" style="height: 22px; width: 100%;"/>
and just the stores that have postal code are shown in this line (postal code and store have a master detail relationship)
<apex:selectList value="{!storeChoosen}" multiselect="false" size="1" id="idstoreChoosen"  style="height: 22px; width: 100%;">
                                            <apex:selectOptions value="{!relatedStore}"/>
                                        </apex:selectList>
Also I have this line:
window.location.href="/apex/IK_VF_Formulario?PostalCode="+PostalCodeIntroduced+" en Store&Language=es";

And the corresponding controller:
public with sharing class myController {
    public String PostalCodeIntroduced {get; set;}
    public myController(){
          PostalCodeIntroduced = ApexPages.currentPage().getParameters().get('PostalCode');
    }
 
    public List<SelectOption> getRelatedStore(){
        List<CP__c> lstRelatedStores = [SELECT Store__c, Name, Store__r.Name 
                                                          FROM CP__c WHERE Name =: PostalCodeIntroduced ];
        List<SelectOption> RelatedStores= new List<SelectOption>();
        RelatedStores.add(new SelectOption('', '--None--'));
            for(CP__c tiCP: lstRelatedStores ){
                RelatedStores.add(new SelectOption(tiCP.Store__r.Name, tiCP.Store__r.Name));
            }    
                 
       return RelatedStores;
    }
}
The issue comes when the value I put in visualforce is not passing to the controller. But the weird thing is, if I put by hand (in the code) the PostalCode (example 90001) in order to show the related stores to this one, it works!!!! 
Example: 
List<CP__c> lstRelatedStores = [SELECT Store__c, Name, Store__r.Name 
                                                          FROM CP__c WHERE Name =: 90001 ];
Name is the numbers you put in the postal code, for the moment no problem with that


Hope it is clear for you guys
Thanks a lot in advance
Cheers!
Alberto



 
Hi everyone

I'm witting one of my first Visualforces.This one:
<apex:page Controller="ScenariosController">
    <apex:pageMessages ></apex:pageMessages>
    <apex:pageBlock >
    
        <apex:pageBlockTable value="{!}" var="item" >
    
             <apex:column value="{!item.Scenario__c}"                 style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}"/>
            <apex:column value="{!item.PCK_Tower_Height__c}"         style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}" />
            <apex:column value="{!item.NUM_Quantity__c}"             style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}" />
            <apex:column value="{!item.CHK_Scenario_Principal__c}"   style="background-color:{!If(item.CHK_Scenario_Principal__c ==True,'#beecf4', '')}"/>
            <!-- background-color:{!If(opp.StageName =='Negotiation/Review','#7CFC00',If(opp.StageName =='Closed Won','#DEB887','#DC143C'))}; -->
    
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


And this controller:
 
public class ScenariosController{
      
    List<Quote_line__c> quoteLineList;
    
    //Populate a list with all the quote Lines != NULL ordered by NUM_Scenario__c DESC
    public List<Quote_line__c> getQuoteLineItems(){
       Id budgetId= ApexPages.currentPage().getParameters().get('Id');
       if (budgetId!= NULL){
           List<Quote_line__c> quoteLineList = new List<Quote_line__c>();
           quoteLineList = [SELECT id,name,lkp_product__r.family__c, lkp_product__r.Nominal_Power_MW__c, CHK_Included__c,
                                        NUM_Cost__c,LKP_Configurator__c,Sum_mandatory_fields_for_budReq_unfill__C,Date_from__c,Date_to__c,
                                        TXT_Tower_First_Value__c, NUM_Quantity__c,LKP_Product__c,MD_quote__c, NUM_Scenario__c, CHK_Scenario_Principal__c
                             FROM quote_line__c 
                             WHERE NUM_Scenario__c != NULL
                             ORDER BY NUM_Scenario__c
                             DESC];
                           }
        return quoteLineList;
    }
}



I don't know how to continue. What I know is, I have to define the get method to pass data from the controller to the Visualforce but no idea about where and how to put it.

Thanks in advance for your time!
Cheers!
Alberto
Hi everyone,

I have to test this class:

List<Account> oldAccounts   = Trigger.old;
        for(Account check : oldAccounts){
            if(check.Account_ID__c!=null){
                check.addError('Accounts that have SAP Account ID can not be deleted');
            }
        }

I know that in theese cases one has to use try/catch methods to solve the test.
But I've been trying for hours and I don't know how to solve it.

I post what I did so far, it covers everything except last line ('addError'):

@isTest
public class TriggerAccountDeleteTest {
      public class MyException extends Exception {}
       static testMethod void metodoDeletAccount(){
        
             //Create an Account with his required fields
             Account accountPrueba = new Account();
                accountPrueba.Name = 'Siemens2';
                accountPrueba.Account_Country__c = 'a014E000005XNKh';
                accountPrueba.Language__c = 'a064E0000060Wnr'; 
                accountPrueba.Department__c = 'Services';
            
            //Insert it
            insert accountPrueba ;
           
            //Test.startTest();  
                try{
                    delete accountPrueba;
                    Account deletedAccount = [SELECT Id, IsDeleted FROM Account WHERE Id = :accountPrueba.Id ALL ROWS];
                    System.assertEquals(deletedAccount.IsDeleted, true);
        
                    }
                 catch(Exception e){
                    Boolean b = null;
                    accountPrueba2.Account_ID__c = String.valueOf(b);
                    System.assert(e.getMessage().contains('Accounts that have SAP Account ID can not be deleted'));
                 }
               Test.stopTest();   
        
    }
}
Thank you for your time
Cheers,
Alberto