• Adi85
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 10
    Replies

Hi All,

 

I have written a sample webservice and i want to handle the excepions in my webservice. I have writen my code in betweern try-catch and catching the exceptions (if Any).

 

But i have seen "Fault String" tags in enterprise wsdl file which am not able to see in my custon wsdl file. So can anyone please let me know how to handle exception or errors in custom wsdl file (other than try-catch).

 

Here is the sample code which i have written.

 

global class OrderProcessingService {
    global class Messages{
        webservice String SuccessMessage;
        webservice String ErrorMessage;
        webservice String StatusCode;
        webservice String Identifier;
        webservice Integer LineNumber;
        webservice String StackTrace;
        webservice String ExceptionType;
    }
    global class insertRecordService{
        webservice String firstName;
        webservice String lastname;
        webservice String country;
    }
    webservice static Messages insertRecord(insertRecordService irsObj){
        Messages messageObj=new Messages();
        try{
            SampleObject001__c obj=new SampleObject001__c();
            //obj.First_Name__c=irsObj.firstName;
            //obj.Last_Name__c=irsObj.lastname;
            //obj.Country__c=irsObj.country;
            //insert obj;
            Database.Saveresult saveObj=Database.insert(obj);
            if(saveObj.isSuccess()){
                messageObj.SuccessMessage='Inserted Successfully';
            }
        }catch(System.DmlException e){
                messageObj.Identifier='-----In Side Catch------';
                messageObj.ErrorMessage=e.getMessage();
                messageObj.LineNumber=e.getLineNumber();
                messageObj.StackTrace=e.getStackTraceString();
                messageObj.ExceptionType=e.getTypeName();
              }
              catch(System.NullPointerException e){
                  messageObj.Identifier='-----In Side Catch---NullPointerException---';
                messageObj.ErrorMessage=e.getMessage();
              }
            return messageObj;
    }
}

 

Note :  Inorder to get the exception i have commented some lines.

 

Please provide me some info regarding this.

 

Thanks and Regards,

 

Adi.

  • June 13, 2011
  • Like
  • 0

Hi All,

 

Am trying to get a tree view in my VF page using JQuery tree view plugin. But the tree is coming a by default extracted manner nad not able to collapse it and throwing the exception like "Object does not support this property or method". Here is my code.

 

VF page:

--------------

 

<apex:page controller="treeViewController">
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.cookie.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.treeview.js')}" type="text/javascript"></script>
<script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/lib/jquery.js')}" type="text/javascript"></script>
<script type="text/javascript">
        $(function() {
            $("#tree").treeview({
                collapsed: false,
                animated: "medium",
                control:"#sidetreecontrol",
                persist: "location"
            });
        })
</script>
<br/> <br/> <br/>
<!-- Tree -->
<div class="treeheader" style="height:0px;">&nbsp;</div>
<div id="sidetreecontrol"><a href="?#"><font style="color:blue;">Collapse All</font></a> | <a href="?#"><font style="color:blue;">Expand All</font></a></div>
<ul id="tree">
    <apex:repeat value="{!mainnodes}" var="parent">
        <li><strong><apex:outputtext style="color:blue;" escape="false" value="{!parent.gparent.Name}"/></strong>
             <ul>
                 <apex:repeat value="{!parent.parent}" var="child">
                    <li><span class="formattextcon"><apex:outputtext style="color:green;" escape="false" value="{!child.LastName}"/></span>
                        <ul>
                            <apex:repeat value="{!child.Cases}" var="gchildren">
                               <li> <span class="formattextcon"> <apex:outputtext escape="false" style="color:red;" value="{!gchildren.CaseNumber}"/> <b>||</b> &nbsp;<apex:outputtext escape="false" value="{!gchildren.Subject}"/> </span> </li>
                            </apex:repeat>
                        </ul>       
                    </li>
                 </apex:repeat>  
             </ul>  
        </li>
    </apex:repeat>
</ul>
<!-- End of Tree -->
</apex:page>

 

-------------------

controller:

----------------------

 

 

public class treeViewController {

 

/* Wrapper class to contain the nodes and their children */

public class cNodes

{

 

 public List<Contact> parent {get; set;}

 Public Account gparent {get;set;}

 

 public cNodes(Account  gp, List<Contact> p)

 {

     parent = p;

     gparent = gp;

 }

}

/* end of Wrapper class */ 

 

Public List<cNodes> hierarchy;

 

Public List<cNodes> getmainnodes()

{

    hierarchy = new List<cNodes>();

    List<Account> tempparent = [Select Id,Name from Account];

    for (Integer i =0; i< tempparent.size() ; i++)

    {

        List<Contact> tempchildren = [Select Id,FirstName,LastName,(Select Id,CaseNumber,Subject from Cases) from Contact where AccountId = :tempparent[i].Id];

        hierarchy.add(new cNodes(tempparent[i],tempchildren));

     }   

    return hierarchy;

}   

}

 

 

 

Please suggest me how i can overcome this issue. i think the problem is with the line  "$(function() {" because SFDC also uses the same type of patterns to use javascript resources. 

 

In one of my samples i used like 

 

var j$ = jQuery.noConflict();

j$(function() {

//my code

}

 

But here if am trying to use the same sysntax it is not recognizing the method "treeview". Sp please help me to resolve this issue.

 

Thank you in advance.

 

Regards,

 

Aditya.p.

<apex:page controller="treeViewController"><script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.js')}" type="text/javascript"></script><script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.cookie.js')}" type="text/javascript"></script><script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/jquery.treeview.js')}" type="text/javascript"></script><script src="{!URLFOR($Resource.Jtreeview,'Jquerytreeview/lib/jquery.js')}" type="text/javascript"></script><script type="text/javascript">        $(function() {            $("#tree").treeview({                collapsed: false,                animated: "medium",                control:"#sidetreecontrol",                persist: "location"            });        })</script><br/> <br/> <br/><!-- Tree --><div class="treeheader" style="height:0px;">&nbsp;</div><div id="sidetreecontrol"><a href="?#"><font style="color:blue;">Collapse All</font></a> | <a href="?#"><font style="color:blue;">Expand All</font></a></div><ul id="tree">    <apex:repeat value="{!mainnodes}" var="parent">        <li><strong><apex:outputtext style="color:blue;" escape="false" value="{!parent.gparent.Name}"/></strong>             <ul>                 <apex:repeat value="{!parent.parent}" var="child">                    <li><span class="formattextcon"><apex:outputtext style="color:green;" escape="false" value="{!child.LastName}"/></span>                        <ul>                            <apex:repeat value="{!child.Cases}" var="gchildren">                               <li> <span class="formattextcon"> <apex:outputtext escape="false" style="color:red;" value="{!gchildren.CaseNumber}"/> <b>||</b> &nbsp;<apex:outputtext escape="false" value="{!gchildren.Subject}"/> </span> </li>                            </apex:repeat>                        </ul>                           </li>                 </apex:repeat>               </ul>          </li>    </apex:repeat></ul><!-- End of Tree --></apex:page>

  • May 12, 2011
  • Like
  • 0

Hi all,

 

am new to visual force and am trying to get values from my visual force page for further processing but am getting null values in my controller .

 

Can any one let me know what is the problem??

 

Here is my code snippet.

 

VF page :

------------

 

 

<apex:page controller="paginationController">
<apex:form >
    <apex:pageBlock mode="edit" title="Search">
    <script>
    function scriptSearch(){
        //alert(document.getElementById("firstName").value);
        //alert(document.getElementById("lastName").value);
        //alert(document.getElementById("country").options[document.getElementById("country").selectedIndex].value);
        searchCall(document.getElementById("firstName").value,document.getElementById("lastName").value,document.getElementById("country").options[document.getElementById("country").selectedIndex].value);
    }
    </script>
    <apex:actionFunction name="searchCall" action="{!searchFunctionality}">
    <apex:param name="firstname" value="" />
    <apex:param name="lastname" value="" />
    <apex:param name="country" value="" />
    </apex:actionFunction>
        <table>
            <tr>
                <td>First Name : <input type="text" id="firstName"/></td>
                <td>Last Name: <input type="text" id="lastName"/></td>
                <td>
                Country : <select id="country">
                <option value=""></option>
                <apex:repeat value="{!countries}" var="country">
                <option value="{!country}">{!country}</option>
                </apex:repeat>
                </select>
                </td>
                <td><apex:commandButton onclick="scriptSearch();" value="Search"/></td>
            </tr>
       </table>
    </apex:pageBlock>
    
    <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!queryString}" />           
  </apex:pageBlock> 
  
</apex:form>
</apex:page>

 

 

Controler :

------------

 

 

public class paginationController {

 

public string queryString{get;set;}

 

public List<SampleObject001__c> userDetails{get;set;}

 

public paginationController(){

 queryString='Select First_Name__c,Last_Name__c,Country__c From SampleObject001__c';

 executeQuery();

}

public List<String> countries {

    get {

      if (countries == null) {

 

        countries = new List<String>();

        Schema.DescribeFieldResult field = SampleObject001__c.Country__c.getDescribe();

 

        for (Schema.PicklistEntry f : field.getPicklistValues())

          countries.add(f.getLabel());

 

      }

      return countries;          

    }

    set;

  }

 

 public PageReference searchFunctionality(){

 

  String firstName = Apexpages.currentPage().getParameters().get('firstname');

    String lastName = Apexpages.currentPage().getParameters().get('lastname');

    String country = Apexpages.currentPage().getParameters().get('country');

 

    system.debug('-----firstName-------'+firstName);

    system.debug('-----lastName-------'+lastName);

    system.debug('-----country-------'+country);

 

    if(firstName!=null && !firstName.equals('')){

     queryString+='and First_Name__c LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';

    }

    if(lastName!=null && !lastName.equals('')){

     queryString+='and Last_Name__c LIKE \''+String.escapeSingleQuotes(lastName)+'%\'';

    }

    if(country!=null && !country.equals('')){

     queryString += ' and Country__c includes (\''+country+'\')';

    }

 

    executeQuery();

  return null;

 }

 

 public void executeQuery(){

  try{

  system.debug('-----QUERY-------'+queryString);

  userDetails= Database.query(queryString);

  }catch(Exception e){

 

  }

 }

}

 

 

 

please help me to resolve this issue.

 

  • April 22, 2011
  • Like
  • 0

Hi All,

 

I have developed a sample java web application and deployed in google app engine. I want to execute that application from salesforce.

 

I have developed a webservice which will return a string as response. But am not able to call that service and am getting the error message like "Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html' ". 

 

Can any one help me to resolve this issue or please guide me how i can access my application which is there in google app server.

 

Thank you in advance.

 

Regards,

 

Aditya.

  • April 20, 2011
  • Like
  • 0

I have created a custom object (Template_Information__c)  with rich text custom field (RichTextArea__c). I am reading the rich text in my vf page as follows:

 

<apex:page id="pageid" controller="SelectTemplateController">

 

     <!-- Add the javascript file to intialize the CkEditor -->
     <apex:includescript value="{!URLFOR($Resource.CkEditor, 'ckeditor/ckeditor.js')}" />

     <apex:form id="formid">

    <apex:commandButton action="{!redirectToTemplate}" value="Go to template" reRender="rich"/>


    <apex:inputTextarea id="inputid" value="{!templateInfo.RichTextArea__c}" styleClass="ckeditor" richText="false"/>

      </apex:form>


</apex:page>

 

At the controller side:

 

public with sharing class SelectTemplateController {

public Template_Information__c templateInfo {get; set;}

public SelectTemplateController() {
templateInfo = new Template_Information__c();

}

public Pagereference redirectToTemplate() {


insert templateInfo;
System.debug('OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO templateInfo.Id : ' + templateInfo.Id);
}


}

 


The issue is, the object is saved but when I do a query to fetch the RichTextArea__c it returns null. 

 

From what I have seen, this issue is due to the ckeditor. If I remove the styleClass="ckeditor" from the inputtextarea tag, the entered content is saved properly. 

 

Has anyone worked with the ckeditor before? 

I do not understand whay the content from the editor does not get saved in the rich text custom field.

 

Thanks.

Hi,

I need to call a visual force page on visualforce worklow. Please help us.

Thanks,

Rajan

  • September 13, 2011
  • Like
  • 0

I tried using CASE statements and it doesn't look like SOQL accepts it? I need to sort by 5 specific records being on top IF the vendor type is of a certain selection.

 

I have a SOQL statement here:

 

		try {						
		
    		Set<Id> radiusSet = radiusMap().keySet();  
			
			vendors = (List<Contact>)[SELECT Id, Name, Phone, Email, Primary_County__c, Type__c, Status__c, Overall_Rating__c, RecordTypeId, Designation__c
		        FROM Contact 
        		WHERE Primary_County__c IN :radiusSet 
        		AND Type__c INCLUDES (:vType) 
        		AND (Primary_Specialty__c LIKE :noSpecialty OR Primary_Specialty__c LIKE :specialty)//Used to return Vendors with or without Primay Specialties
        		ORDER BY Overall_Rating__c DESC];
		}
		catch(QueryException q) {
		}
		return vendors;
	}

 I'm trying to modify like this...something like this at least...split the statement depending on the vendorType picklist - then adding sorts specific to if the type == commercial appraiser. 

 

How can i get it to sort for specific results every single time I have commercial appraiser chosen? AND have it ignore(?) the radius WHERE statement?

 

		List<Contact> vendors;
		if(vType!= 'Commercial Appraiser'){
			try {						
			
	    		Set<Id> radiusSet = radiusMap().keySet();  
				vendors = (List<Contact>)[SELECT Id, Name, Phone, Email, Primary_County__c, Type__c, Status__c, Overall_Rating__c, RecordTypeId, Designation__c
					FROM Contact 
	        		WHERE Primary_County__c IN :radiusSet 
	        		AND Type__c INCLUDES (:vType) 
	        		AND (Primary_Specialty__c LIKE :noSpecialty OR Primary_Specialty__c LIKE :specialty)
	        	 	ORDER BY Overall_Rating__c DESC];
			}
			catch(QueryException q) {
			}
			return vendors;
		}
		else if(vType == 'Commercial Appraiser'){
			try {						
			
	    		Set<Id> radiusSet = radiusMap().keySet();  
				vendors = (List<Contact>)[SELECT Id, Name, Phone, Email, Primary_County__c, Type__c, Status__c, Overall_Rating__c, RecordTypeId, Designation__c
					FROM Contact 
	        		WHERE Primary_County__c IN :radiusSet
	        		AND Type__c INCLUDES (:vType) 
	        		AND (Primary_Specialty__c LIKE :noSpecialty OR Primary_Specialty__c LIKE :specialty)
	        		AND (Id = '003A000000PvSHQ')
	        	 	ORDER BY Id = '003A000000PvSHQ', Overall_Rating__c DESC];
			}
			catch(QueryException q) {
			}
			return vendors;
		}
	}

 

  • July 08, 2011
  • Like
  • 0

I have a custom object. I have created a VFP for the same in which i'm inserting some product line items in pageBlockTable using wrapper class and doing some calculations. now at the time i save this record, i want this pageBlockTable to appear in the particular VIEW record also. I know i have to write a VFP and controller for it. 

 

Some one please give me a hint in the form of coing on how to do it.

I am in most urgent.

 

Thanks in advance

Raaj...

Hi all,

 

am new to visual force and am trying to get values from my visual force page for further processing but am getting null values in my controller .

 

Can any one let me know what is the problem??

 

Here is my code snippet.

 

VF page :

------------

 

 

<apex:page controller="paginationController">
<apex:form >
    <apex:pageBlock mode="edit" title="Search">
    <script>
    function scriptSearch(){
        //alert(document.getElementById("firstName").value);
        //alert(document.getElementById("lastName").value);
        //alert(document.getElementById("country").options[document.getElementById("country").selectedIndex].value);
        searchCall(document.getElementById("firstName").value,document.getElementById("lastName").value,document.getElementById("country").options[document.getElementById("country").selectedIndex].value);
    }
    </script>
    <apex:actionFunction name="searchCall" action="{!searchFunctionality}">
    <apex:param name="firstname" value="" />
    <apex:param name="lastname" value="" />
    <apex:param name="country" value="" />
    </apex:actionFunction>
        <table>
            <tr>
                <td>First Name : <input type="text" id="firstName"/></td>
                <td>Last Name: <input type="text" id="lastName"/></td>
                <td>
                Country : <select id="country">
                <option value=""></option>
                <apex:repeat value="{!countries}" var="country">
                <option value="{!country}">{!country}</option>
                </apex:repeat>
                </select>
                </td>
                <td><apex:commandButton onclick="scriptSearch();" value="Search"/></td>
            </tr>
       </table>
    </apex:pageBlock>
    
    <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!queryString}" />           
  </apex:pageBlock> 
  
</apex:form>
</apex:page>

 

 

Controler :

------------

 

 

public class paginationController {

 

public string queryString{get;set;}

 

public List<SampleObject001__c> userDetails{get;set;}

 

public paginationController(){

 queryString='Select First_Name__c,Last_Name__c,Country__c From SampleObject001__c';

 executeQuery();

}

public List<String> countries {

    get {

      if (countries == null) {

 

        countries = new List<String>();

        Schema.DescribeFieldResult field = SampleObject001__c.Country__c.getDescribe();

 

        for (Schema.PicklistEntry f : field.getPicklistValues())

          countries.add(f.getLabel());

 

      }

      return countries;          

    }

    set;

  }

 

 public PageReference searchFunctionality(){

 

  String firstName = Apexpages.currentPage().getParameters().get('firstname');

    String lastName = Apexpages.currentPage().getParameters().get('lastname');

    String country = Apexpages.currentPage().getParameters().get('country');

 

    system.debug('-----firstName-------'+firstName);

    system.debug('-----lastName-------'+lastName);

    system.debug('-----country-------'+country);

 

    if(firstName!=null && !firstName.equals('')){

     queryString+='and First_Name__c LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';

    }

    if(lastName!=null && !lastName.equals('')){

     queryString+='and Last_Name__c LIKE \''+String.escapeSingleQuotes(lastName)+'%\'';

    }

    if(country!=null && !country.equals('')){

     queryString += ' and Country__c includes (\''+country+'\')';

    }

 

    executeQuery();

  return null;

 }

 

 public void executeQuery(){

  try{

  system.debug('-----QUERY-------'+queryString);

  userDetails= Database.query(queryString);

  }catch(Exception e){

 

  }

 }

}

 

 

 

please help me to resolve this issue.

 

  • April 22, 2011
  • Like
  • 0

Hi All,

 

I have developed a sample java web application and deployed in google app engine. I want to execute that application from salesforce.

 

I have developed a webservice which will return a string as response. But am not able to call that service and am getting the error message like "Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html' ". 

 

Can any one help me to resolve this issue or please guide me how i can access my application which is there in google app server.

 

Thank you in advance.

 

Regards,

 

Aditya.

  • April 20, 2011
  • Like
  • 0
Hello, Hope you are doing well. This is Jeff and I represent Elite Innovative Solutions Inc. We currently have an urgent job requirement for our client of position SFDC (Salesforce.com) Technical Developers - 10 openings located at India (Most Prob. Hyderabad), which you may be suited or interested in. Please do send me a copy of your updated resume and the best time and # to jeff@eliteisinc.com Position: SFDC (Salesforce.com) Technical Developers 10 openingsLocation: India (Most Prob. Hyderabad)Type of Contract: FULL TIME Ideal candidate should have 1-2 yrs experience in SFDC , must have experience in APEX , Visual Force  and Salesforce.com Integration.Must have good communication skills.  Thanks & Regards  Jeff Healey Elite Innovative Solutions, Inc. Irving, TX 75038 Office : 408-850-1453Fax:972.782.9215jeff@eliteisinc.comURL:www.eliteisinc.com