• Martin Chalot 15
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hi,
I create a site for guest user. The site can display different stuff depending on the URL i'm reading. Depending on the URL I display one or another component. 
For the first component there is no problem, I click save the action occurs and it some variable are changing and it display either an error or success message (same page)
But on my other component when I click on the action button it always get redirected on the unauthorization page... The action does absolutely nothing, it's a void function with no code inside. Can you tell me what's wrong with the following controller :
public class surveyController {
    public Id oppId {get;set;}
    public Id surId {get;set;}
    public Id accId {get;set;}
    public Id conId {get;set;}
    public Id prestaId {get;set;}
    
    public boolean success {get;set;}
    public boolean failure {get;set;}
    
    public Survey__c survey {get;set;}
    
    
    public String test {get;set;}
    
    public surveyController() {
        
        this.success = false;
        this.failure = false;

        this.oppId = ApexPages.currentPage().getParameters().get('o');
        this.surId = ApexPages.currentPage().getParameters().get('s');
        this.accId = ApexPages.currentPage().getParameters().get('a');
        this.conId = ApexPages.currentPage().getParameters().get('c');
        this.prestaId = ApexPages.currentPage().getParameters().get('ps');
        
        if(this.oppId != null && this.surId != null && this.accId != null) {
            this.survey = [SELECT Id, Name, active__c,Affaire__c,Client__c,Moyenne__c,
                           Prestataire__c,Prestataire_Selectionne__c,Sum_Coef__c,Sum_Reponse__c,
                           (SELECT Id, Libelle__c, Possible_answers__c, RecordType.Name, Reponse__c,
                            ValueReponse__c,RealValue__c,Order__c,Survey__c,
                            Notable__c,Coef__c
                            FROM Questions__r ORDER BY Order__c ASC) 
                           FROM Survey__c WHERE active__c = true AND RecordType.Name = 'Template' AND Id = :this.surId];
            
            
            System.debug(this.survey.Questions__r);
            
        }
    }
    
    
    public List<SelectOption> getRadioOption() {
        
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('1','1')); 
       	options.add(new SelectOption('2','2')); 
        options.add(new SelectOption('3','3')); 
        options.add(new SelectOption('4','4')); 
        options.add(new SelectOption('5','5')); 
        
        return options; 
    
    }
    
    public List<SelectOption> getPicklistOption() {
        
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('1','Insatisfaisant')); 
       	options.add(new SelectOption('2','Peu satisfaisant')); 
        options.add(new SelectOption('3','Neutre')); 
        options.add(new SelectOption('4','Bien')); 
        options.add(new SelectOption('5','Incroyable')); 
        
        return options; 
    
    }
    
    public void savePerso() {
        
    }
}

And the component, is here :
 
<apex:component controller="surveyController" allowDML="true">
    <apex:attribute name="opportunityId"
                    assignTo="{!oppId}"
                    type="Id" 
                    description="Opportunity"
                    required="true"/>
    
    <apex:attribute name="prestaSelectionne"
                    assignTo="{!prestaId}"
                    type="Id" 
                    description="Id Objet de jonction"
                    required="true"/>
    
    <apex:attribute name="contactId"
                    assignTo="{!conId}"
                    type="Id" 
                    description="Contact"
                    required="true"/>
    
    <apex:attribute name="accountId"
                    assignTo="{!accId}"
                    type="Id" 
                    description="Account prestataire"
                    required="true"/>
    
    <apex:attribute name="surveyId"
                    assignTo="{!surId}"
                    type="Id" 
                    description="Survey"
                    required="true"/>
    
    
    
    
    
    <apex:outputPanel rendered="{!success}">
        Bravo les informations ont été modifiées
    </apex:outputPanel>
    <apex:outputPanel rendered="{!failure}">
        Une erreur est survenue
    </apex:outputPanel>
    
    <apex:outputPanel rendered="{!success == false && failure == false && survey!=null}">
        <h1>Survey Name : {!survey.Name}</h1>
        
        <apex:form >
            <apex:repeat value="{!survey.Questions__r}" var="q">
                <h2>{!q.Libelle__c}</h2>
                
                <apex:outputPanel rendered="{!q.RecordType.Name == 'Checkbox'}">
                    <apex:selectRadio value="{!q.Reponse__c}">
                        <apex:selectOptions value="{!radioOption}"/>
                    </apex:selectRadio>
                </apex:outputPanel>
                
                <apex:outputPanel rendered="{!q.RecordType.Name == 'Texte Libre'}">
                    <apex:inputTextarea value="{!q.Reponse__c}"/>
                </apex:outputPanel>
                
                <apex:outputPanel rendered="{!q.RecordType.Name == 'Picklist'}">
                    <apex:selectList value="{!q.Reponse__c}" multiselect="false">
                        <apex:selectOptions value="{!picklistOption}"/>
                    </apex:selectList>
                </apex:outputPanel>
                <br/>
            </apex:repeat>
            <br/><br/>
            <apex:commandButton action="savePerso" value="Envoyer le questionnaire"/>
        </apex:form>
        
    </apex:outputPanel>
</apex:component>

Can you help me ?

Here the visualforce page that display the compoenent if needed :
 
<apex:page controller="siteController" showChat="false" showHeader="false"  
           showQuickActionVfHeader="false" sidebar="false" standardStylesheets="{!standardStylesheet}">
    
    <c:AccountComponent myaccountId="{!accountId}" rendered="{!callIsCorrect && pageCalled == 'account'}"/>
   
    
    <apex:outputPanel rendered="{!callIsCorrect && pageCalled == 'survey'}">
        <c:surveyComponent opportunityId="{!opportunityId}" 
                           accountId="{!accountId}" 
                           surveyId="{!surveyId}"
                           contactId="{!clientId}"
                           prestaSelectionne="{!prestaId}"/>
    </apex:outputPanel>
    
    <apex:outputPanel rendered="{!callIsCorrect == false}">
    	Votre URL n'est pas correcte.
    </apex:outputPanel>
    
</apex:page>




public class siteController {
    
    public boolean callIsCorrect {get;set;}
    public String pageCalled {get;set;}
    public boolean standardStylesheet {get;set;}
    /*
     * Parameter for survey
     */
    public Id opportunityId {get;set;}
    public Id accountId {get;set;}
    public Id surveyId {get;set;}
    public Id clientId {get;set;}
    public Id prestaId {get;set;}
    /*
     * Parameter for account
     *
		public Id accountId {get;set;}*/
    
    
    public siteController() {
        this.callIsCorrect = false;
        this.standardStylesheet = false;
        
        this.pageCalled = ApexPages.currentPage().getParameters().get('p');
        
        
        if(this.pageCalled == 'account') {
     		this.standardStylesheet = true;
            this.accountId = ApexPages.currentPage().getParameters().get('a');
            
            if(this.accountId != null) {
                this.callIsCorrect = true;
            }
            
            
        } else if(this.pageCalled == 'survey') {
   
            this.opportunityId = ApexPages.currentPage().getParameters().get('o');
            this.surveyId = ApexPages.currentPage().getParameters().get('s');
            this.accountId = ApexPages.currentPage().getParameters().get('a');
            this.clientId = ApexPages.currentPage().getParameters().get('c');
            this.prestaId = ApexPages.currentPage().getParameters().get('ps');
            if(this.opportunityId != null && this.surveyId != null && this.accountId != null && this.prestaId != null && this.clientId != null) {
               	this.callIsCorrect = true;
            }
        }
    }
}


Thanks,
Regards,
Martin
Hello,
I'm trying to understand how can I test multiple webservice callout from a single transation. My transaction work like this :
- Step 1 : I call Web Service A. I get an ID from this Webservice
- Step 2 : From the Id I got from the webservice I call Webservice B
- Then I make some operations...

So far the only way to distinguish where the webservice is from is by making a condition on the endpoint :
global class ExpertiseMock implements HttpCalloutMock {
	global HTTPResponse respond(HTTPRequest req) {
        
        String content = null;
        String endpoint = req.getEndpoint();
        
        HttpResponse res = new HttpResponse();
        if(endpoint.startsWith('**********************************')) {
            res.setBody(ReponseA);
        } else {
            res.setBody(ReponseB);
        }
        
        res.setHeader('Content-Type', 'application/json');
        
        res.setStatusCode(200);
        return res;
    }
}

But I think it's not very clean. Is there another way ?

Thanks,

Regards,

Martin

Hi,
I'm trying to write my text inside one block.
Example, I have this :
<div> 
AAA 
BBB 
CCC 
DDD
</div>
And I want the visualforce page to render it this way :
AAA      CCC
BBB      DDD
The text "AAA BBB CCC DDD" would be a long area field. And I need to display it on two columns when rendering as PDF.

I've tried to use the CSS (column-count, column-width) but nothing seems to be working. He doesn't understand this specific CSS. I tried on a basic HTML page and the render is as I want it so I'm guessing it's coming from restricted CSS rules about VF pages.
 
Can you help me ?

Thanks,
Best regards,
Martin
Hi,
I create a site for guest user. The site can display different stuff depending on the URL i'm reading. Depending on the URL I display one or another component. 
For the first component there is no problem, I click save the action occurs and it some variable are changing and it display either an error or success message (same page)
But on my other component when I click on the action button it always get redirected on the unauthorization page... The action does absolutely nothing, it's a void function with no code inside. Can you tell me what's wrong with the following controller :
public class surveyController {
    public Id oppId {get;set;}
    public Id surId {get;set;}
    public Id accId {get;set;}
    public Id conId {get;set;}
    public Id prestaId {get;set;}
    
    public boolean success {get;set;}
    public boolean failure {get;set;}
    
    public Survey__c survey {get;set;}
    
    
    public String test {get;set;}
    
    public surveyController() {
        
        this.success = false;
        this.failure = false;

        this.oppId = ApexPages.currentPage().getParameters().get('o');
        this.surId = ApexPages.currentPage().getParameters().get('s');
        this.accId = ApexPages.currentPage().getParameters().get('a');
        this.conId = ApexPages.currentPage().getParameters().get('c');
        this.prestaId = ApexPages.currentPage().getParameters().get('ps');
        
        if(this.oppId != null && this.surId != null && this.accId != null) {
            this.survey = [SELECT Id, Name, active__c,Affaire__c,Client__c,Moyenne__c,
                           Prestataire__c,Prestataire_Selectionne__c,Sum_Coef__c,Sum_Reponse__c,
                           (SELECT Id, Libelle__c, Possible_answers__c, RecordType.Name, Reponse__c,
                            ValueReponse__c,RealValue__c,Order__c,Survey__c,
                            Notable__c,Coef__c
                            FROM Questions__r ORDER BY Order__c ASC) 
                           FROM Survey__c WHERE active__c = true AND RecordType.Name = 'Template' AND Id = :this.surId];
            
            
            System.debug(this.survey.Questions__r);
            
        }
    }
    
    
    public List<SelectOption> getRadioOption() {
        
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('1','1')); 
       	options.add(new SelectOption('2','2')); 
        options.add(new SelectOption('3','3')); 
        options.add(new SelectOption('4','4')); 
        options.add(new SelectOption('5','5')); 
        
        return options; 
    
    }
    
    public List<SelectOption> getPicklistOption() {
        
        List<SelectOption> options = new List<SelectOption>(); 
        options.add(new SelectOption('1','Insatisfaisant')); 
       	options.add(new SelectOption('2','Peu satisfaisant')); 
        options.add(new SelectOption('3','Neutre')); 
        options.add(new SelectOption('4','Bien')); 
        options.add(new SelectOption('5','Incroyable')); 
        
        return options; 
    
    }
    
    public void savePerso() {
        
    }
}

And the component, is here :
 
<apex:component controller="surveyController" allowDML="true">
    <apex:attribute name="opportunityId"
                    assignTo="{!oppId}"
                    type="Id" 
                    description="Opportunity"
                    required="true"/>
    
    <apex:attribute name="prestaSelectionne"
                    assignTo="{!prestaId}"
                    type="Id" 
                    description="Id Objet de jonction"
                    required="true"/>
    
    <apex:attribute name="contactId"
                    assignTo="{!conId}"
                    type="Id" 
                    description="Contact"
                    required="true"/>
    
    <apex:attribute name="accountId"
                    assignTo="{!accId}"
                    type="Id" 
                    description="Account prestataire"
                    required="true"/>
    
    <apex:attribute name="surveyId"
                    assignTo="{!surId}"
                    type="Id" 
                    description="Survey"
                    required="true"/>
    
    
    
    
    
    <apex:outputPanel rendered="{!success}">
        Bravo les informations ont été modifiées
    </apex:outputPanel>
    <apex:outputPanel rendered="{!failure}">
        Une erreur est survenue
    </apex:outputPanel>
    
    <apex:outputPanel rendered="{!success == false && failure == false && survey!=null}">
        <h1>Survey Name : {!survey.Name}</h1>
        
        <apex:form >
            <apex:repeat value="{!survey.Questions__r}" var="q">
                <h2>{!q.Libelle__c}</h2>
                
                <apex:outputPanel rendered="{!q.RecordType.Name == 'Checkbox'}">
                    <apex:selectRadio value="{!q.Reponse__c}">
                        <apex:selectOptions value="{!radioOption}"/>
                    </apex:selectRadio>
                </apex:outputPanel>
                
                <apex:outputPanel rendered="{!q.RecordType.Name == 'Texte Libre'}">
                    <apex:inputTextarea value="{!q.Reponse__c}"/>
                </apex:outputPanel>
                
                <apex:outputPanel rendered="{!q.RecordType.Name == 'Picklist'}">
                    <apex:selectList value="{!q.Reponse__c}" multiselect="false">
                        <apex:selectOptions value="{!picklistOption}"/>
                    </apex:selectList>
                </apex:outputPanel>
                <br/>
            </apex:repeat>
            <br/><br/>
            <apex:commandButton action="savePerso" value="Envoyer le questionnaire"/>
        </apex:form>
        
    </apex:outputPanel>
</apex:component>

Can you help me ?

Here the visualforce page that display the compoenent if needed :
 
<apex:page controller="siteController" showChat="false" showHeader="false"  
           showQuickActionVfHeader="false" sidebar="false" standardStylesheets="{!standardStylesheet}">
    
    <c:AccountComponent myaccountId="{!accountId}" rendered="{!callIsCorrect && pageCalled == 'account'}"/>
   
    
    <apex:outputPanel rendered="{!callIsCorrect && pageCalled == 'survey'}">
        <c:surveyComponent opportunityId="{!opportunityId}" 
                           accountId="{!accountId}" 
                           surveyId="{!surveyId}"
                           contactId="{!clientId}"
                           prestaSelectionne="{!prestaId}"/>
    </apex:outputPanel>
    
    <apex:outputPanel rendered="{!callIsCorrect == false}">
    	Votre URL n'est pas correcte.
    </apex:outputPanel>
    
</apex:page>




public class siteController {
    
    public boolean callIsCorrect {get;set;}
    public String pageCalled {get;set;}
    public boolean standardStylesheet {get;set;}
    /*
     * Parameter for survey
     */
    public Id opportunityId {get;set;}
    public Id accountId {get;set;}
    public Id surveyId {get;set;}
    public Id clientId {get;set;}
    public Id prestaId {get;set;}
    /*
     * Parameter for account
     *
		public Id accountId {get;set;}*/
    
    
    public siteController() {
        this.callIsCorrect = false;
        this.standardStylesheet = false;
        
        this.pageCalled = ApexPages.currentPage().getParameters().get('p');
        
        
        if(this.pageCalled == 'account') {
     		this.standardStylesheet = true;
            this.accountId = ApexPages.currentPage().getParameters().get('a');
            
            if(this.accountId != null) {
                this.callIsCorrect = true;
            }
            
            
        } else if(this.pageCalled == 'survey') {
   
            this.opportunityId = ApexPages.currentPage().getParameters().get('o');
            this.surveyId = ApexPages.currentPage().getParameters().get('s');
            this.accountId = ApexPages.currentPage().getParameters().get('a');
            this.clientId = ApexPages.currentPage().getParameters().get('c');
            this.prestaId = ApexPages.currentPage().getParameters().get('ps');
            if(this.opportunityId != null && this.surveyId != null && this.accountId != null && this.prestaId != null && this.clientId != null) {
               	this.callIsCorrect = true;
            }
        }
    }
}


Thanks,
Regards,
Martin
Hi,
I'm trying to write my text inside one block.
Example, I have this :
<div> 
AAA 
BBB 
CCC 
DDD
</div>
And I want the visualforce page to render it this way :
AAA      CCC
BBB      DDD
The text "AAA BBB CCC DDD" would be a long area field. And I need to display it on two columns when rendering as PDF.

I've tried to use the CSS (column-count, column-width) but nothing seems to be working. He doesn't understand this specific CSS. I tried on a basic HTML page and the render is as I want it so I'm guessing it's coming from restricted CSS rules about VF pages.
 
Can you help me ?

Thanks,
Best regards,
Martin