• ranveer singh 8
  • NEWBIE
  • 20 Points
  • Member since 2014

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

below is the code in which if we change the value of picklist the details of the selected record has to be shown below and initiallling the detail block should be hidden and on every change of picklist value the detail block should be refreshed

<apex:page controller="sc">
<apex:form >
  Select country:  <apex:selectList size="1" value="{!accid}" >
                      <apex:selectOptions value="{!option}" ></apex:selectOptions> 
                      <apex:actionSupport event="onchange"  action="{!find}" rerender="pb"/> 
                 </apex:selectList><br/><br/>
                 <apex:messages />
                 
                 <apex:outputPanel id="pb" rendered="{!booblock}" >
                 <apex:pageblock title="Detail secton"  >
                 
                 <apex:pageBlockSection id="pbs">
                 <apex:pageBlockTable value="{!acc}" var="a" id="pbt">
                 <apex:column value="{!a.name}"/>
                 <apex:column value="{!a.phone}"/>
                 <apex:column value="{!a.billingcity}"/>
                 </apex:pageBlockTable>
                 </apex:pageBlockSection>
                 </apex:pageblock>
                 </apex:outputPanel>
</apex:form>
</apex:page>

*********************************************

public with sharing class sc {

public boolean booblock{set;get;}
public string accid {set;get;}
public list<selectoption> option {set;get;}
public list<account> acclist = [select id,name from account limit 999];
public account acc{set;get;}

    public sc() {

option = new list<selectoption>();
 option.add(new selectoption('None','None'));
 
for(account ac : acclist){
option.add(new selectoption(ac.id,ac.name));

    }
    }

public void find(){


try{
acc = [select id,name,phone,billingcity from account where id =:accid];
booblock = true;
}
catch(exception e){
system.debug('exception type is'+e.gettypename());
system.debug('exception message is'+e.getMessage());
ApexPages.addMessages(e);
/*ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));*/
}
}
}

But in the above code if i remove the "rendered="{!booblock}" " component it is working fine ...but here my requirement is detail component should be shown only when picklist value is changed any help would be appriciated
Hi guys i have an webservice method i want thr return type to be page reference as i mentioned in code but i am not able to save it  i am getting error as Error: Invalid return type: System.PageReference at line 2 column 37 .how do i need to achieve this guys any help would be appriciated

global class MyWebService {
    webService static pagereference makeContact(String lastName) {
        Contact c = new Contact(lastName = lastName);
        insert c;
        
        pagereference pga = new pagereference('https://ap1.salesforce.com/?id='+c.id);
        return pga;
    }
}
 
Hi guys,

Below is the code for making a callout to the webservice apex class

public class accountmanagerintegration{

 public string i;
public accountmanagerintegration(string a){
this.i=a;

httprequest req = new httprequest();
string endpoint = 'https://ap1.salesforce.com/services/apexrest/Accounts/'+i+'/contacts';
req.setendpoint(endpoint);
Req.setHeader('Authorization', 'Bearer 00D90000000w2Jp!AQEAQF9ngGD6kRrKjH6Qzg21GWkHWpU4naYXdUi6pdFk3bhCdHhidUpU_oNNp1QD2ZSXTj4ekRRVzTMxSKVXT5Qsr4yN.aWr'); 
Req.setheader('X-PrettyPrint','1'); 
req.setmethod('GET');

http p = new http();
httpresponse res = new httpresponse();
res = p.send(req);

system.debug('----status---'+res.getstatus());
system.debug('----status code---'+res.getstatuscode());
system.debug('----body---'+res.getbody());
}
}


And the webservice class is

@RestResource(urlMapping='/Accounts/*/contacts')
global class AccountManager {
   
 
@HttpGet
global static list<list<sobject>> getAccount(){
       
// To obtain the url
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;
      
String restrequestURL = URL.getSalesforceBaseUrl().toExternalForm();        
restrequestURL=restrequestURL+'/services/apexrest'+RestContext.request.requestURI;

for(String s:RestContext.request.params.keyset()){
    restrequestURL=restrequestURL+s+'='+RestContext.request.params.get(s)+'&';
}

restrequestURL=restrequestURL.removeEnd('&');
system.debug('*******'+restrequestURL);
        
string id1 = restrequestURL.mid(54,15);
system.debug('--------id1 to process records------'+id1);
        
list<list<sobject>> accres = [FIND 'go*' IN ALL FIELDS RETURNING Account(id,name where id =: +id1),contact(id,lastname where accountid =: +id1)];
system.debug('------output-----'+accres);
return accres;
 }

}

here i am expecting list<list<sobject>> as out put instead i am getting two empty lists as output ,even i have made sure thatthe value which is passed to id1 is existing id in the org ...can anybody help me on this
Hi guys,  i have a sting str = (majestic badger, fluffy bunny, scary bear, chicken) ,now i want to split it in such a way that if  i use
 index0 ,majestic badger  should be output
index1,fluffy bunny should be output
index2, scary bear .....like this how i can this?
I am facing this error wile i am saving the class which implements webservicemock any help much appriciated
Hi guys,

below is the code in which if we change the value of picklist the details of the selected record has to be shown below and initiallling the detail block should be hidden and on every change of picklist value the detail block should be refreshed

<apex:page controller="sc">
<apex:form >
  Select country:  <apex:selectList size="1" value="{!accid}" >
                      <apex:selectOptions value="{!option}" ></apex:selectOptions> 
                      <apex:actionSupport event="onchange"  action="{!find}" rerender="pb"/> 
                 </apex:selectList><br/><br/>
                 <apex:messages />
                 
                 <apex:outputPanel id="pb" rendered="{!booblock}" >
                 <apex:pageblock title="Detail secton"  >
                 
                 <apex:pageBlockSection id="pbs">
                 <apex:pageBlockTable value="{!acc}" var="a" id="pbt">
                 <apex:column value="{!a.name}"/>
                 <apex:column value="{!a.phone}"/>
                 <apex:column value="{!a.billingcity}"/>
                 </apex:pageBlockTable>
                 </apex:pageBlockSection>
                 </apex:pageblock>
                 </apex:outputPanel>
</apex:form>
</apex:page>

*********************************************

public with sharing class sc {

public boolean booblock{set;get;}
public string accid {set;get;}
public list<selectoption> option {set;get;}
public list<account> acclist = [select id,name from account limit 999];
public account acc{set;get;}

    public sc() {

option = new list<selectoption>();
 option.add(new selectoption('None','None'));
 
for(account ac : acclist){
option.add(new selectoption(ac.id,ac.name));

    }
    }

public void find(){


try{
acc = [select id,name,phone,billingcity from account where id =:accid];
booblock = true;
}
catch(exception e){
system.debug('exception type is'+e.gettypename());
system.debug('exception message is'+e.getMessage());
ApexPages.addMessages(e);
/*ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));*/
}
}
}

But in the above code if i remove the "rendered="{!booblock}" " component it is working fine ...but here my requirement is detail component should be shown only when picklist value is changed any help would be appriciated
Hi guys,

Below is the code for making a callout to the webservice apex class

public class accountmanagerintegration{

 public string i;
public accountmanagerintegration(string a){
this.i=a;

httprequest req = new httprequest();
string endpoint = 'https://ap1.salesforce.com/services/apexrest/Accounts/'+i+'/contacts';
req.setendpoint(endpoint);
Req.setHeader('Authorization', 'Bearer 00D90000000w2Jp!AQEAQF9ngGD6kRrKjH6Qzg21GWkHWpU4naYXdUi6pdFk3bhCdHhidUpU_oNNp1QD2ZSXTj4ekRRVzTMxSKVXT5Qsr4yN.aWr'); 
Req.setheader('X-PrettyPrint','1'); 
req.setmethod('GET');

http p = new http();
httpresponse res = new httpresponse();
res = p.send(req);

system.debug('----status---'+res.getstatus());
system.debug('----status code---'+res.getstatuscode());
system.debug('----body---'+res.getbody());
}
}


And the webservice class is

@RestResource(urlMapping='/Accounts/*/contacts')
global class AccountManager {
   
 
@HttpGet
global static list<list<sobject>> getAccount(){
       
// To obtain the url
RestRequest req = RestContext.request;
RestResponse res = Restcontext.response;
      
String restrequestURL = URL.getSalesforceBaseUrl().toExternalForm();        
restrequestURL=restrequestURL+'/services/apexrest'+RestContext.request.requestURI;

for(String s:RestContext.request.params.keyset()){
    restrequestURL=restrequestURL+s+'='+RestContext.request.params.get(s)+'&';
}

restrequestURL=restrequestURL.removeEnd('&');
system.debug('*******'+restrequestURL);
        
string id1 = restrequestURL.mid(54,15);
system.debug('--------id1 to process records------'+id1);
        
list<list<sobject>> accres = [FIND 'go*' IN ALL FIELDS RETURNING Account(id,name where id =: +id1),contact(id,lastname where accountid =: +id1)];
system.debug('------output-----'+accres);
return accres;
 }

}

here i am expecting list<list<sobject>> as out put instead i am getting two empty lists as output ,even i have made sure thatthe value which is passed to id1 is existing id in the org ...can anybody help me on this
Hi guys,  i have a sting str = (majestic badger, fluffy bunny, scary bear, chicken) ,now i want to split it in such a way that if  i use
 index0 ,majestic badger  should be output
index1,fluffy bunny should be output
index2, scary bear .....like this how i can this?
I am facing this error wile i am saving the class which implements webservicemock any help much appriciated
Hi Everyone,

I would like to know can we return Multiple datatypes from single method in apex, Can anyone please help me .

Thanks.