• Deep067
  • NEWBIE
  • 0 Points
  • Member since 2013

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

We have a custom field "Priority" of type Picklist in contact object.
If we execute query using Ajax  using sforce.connection.query in the VF page using special character then it gives an error in the case of picklist field

I give an example
Paste the following code in your org
For that first create a custom fild name Priority  of type Picklist Type in your Contact object having value "one", "two" ,"Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx"
now create a contact in which Priority field having value "Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx"
Page
-------
<apex:page standardController="contact" extensions="testclass" id="pg">
    <script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script>
    <script src="/soap/ajax/16.0/apex.js" type="text/javascript"></script>    
    <apex:form id="frm">
        <p><b>text1</b></p><input type="text"  id="box"/>
        <input type="button" value="ClickMe" id="box12" onclick="callfun()"  />
        <apex:outputPanel id="inputhiddenfld2">
                <p><b>text2</b></p>
                <apex:inputText value="{!passdata}" id="hid2" />
        </apex:outputPanel>
        <script>
            sforce.connection.sessionId  = "{!$Api.Session_ID}";
            var check = '';
            function callfun()
            {
                try
                {
                    check = document.getElementById('box').value;
                    callname(check);
                }
                catch(err)
                {
                    alert(err);
                }
            }
            
            function calloncom()
            {
                try{       
                        var check1 = document.getElementById('pg:frm:hid2').value;
                        var query = "Select Id, LastName, FirstName From Contact where Contact.Priority__c like \'" +check1+"%\'";  //query2
                        var forerror = sforce.connection.query(query);
                        alert('forerror     '+forerror);
                    }
                catch(err)
                    {
                        alert('err   '+err);
                    }
            }
        </script>
        <apex:actionFunction name="callname" action="{!cont}" reRender="inputhiddenfld2,hid2" oncomplete="calloncom()">
            <apex:param name="passvalue" value="" assignTo="{!passvaluecont}"/>
        </apex:actionFunction>
    </apex:form>  
</apex:page>



class
-------

public with sharing class testclass
{
    public string passvaluecont{get; set;}
    public string passdata{get; set;}
    public testclass(ApexPages.StandardController controller)
    {
    }
    public void cont()
    {
        system.debug('-----------passvaluecont------------------'+passvaluecont);
        passdata = String.escapeSingleQuotes(passvaluecont.trim());
    }
}

Now Enter value "Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx" in the text box named as "text1" and then click on button "ClickME"
it give an error, in normal case(without special character) it working fine
I just want to know how we handel the special character so that this query execute properly using Picklist having like operator
if any thing is not clear then please contact me on
Email- abhishek0674@gmail.com

We have a custom field "Priority" of type Picklist in contact object.
If we execute query using Ajax  using sforce.connection.query in the VF page using special character then it gives an error in the case of picklist field

I give an example
Paste the following code in your org
For that first create a custom fild name Priority  of type Picklist Type in your Contact object having value "one", "two" ,"Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx"
now create a contact in which Priority field having value "Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx"
Page
-------
<apex:page standardController="contact" extensions="testclass" id="pg">
    <script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script>
    <script src="/soap/ajax/16.0/apex.js" type="text/javascript"></script>    
    <apex:form id="frm">
        <p><b>text1</b></p><input type="text"  id="box"/>
        <input type="button" value="ClickMe" id="box12" onclick="callfun()"  />
        <apex:outputPanel id="inputhiddenfld2">
                <p><b>text2</b></p>
                <apex:inputText value="{!passdata}" id="hid2" />
        </apex:outputPanel>
        <script>
            sforce.connection.sessionId  = "{!$Api.Session_ID}";
            var check = '';
            function callfun()
            {
                try
                {
                    check = document.getElementById('box').value;
                    callname(check);
                }
                catch(err)
                {
                    alert(err);
                }
            }
            
            function calloncom()
            {
                try{       
                        var check1 = document.getElementById('pg:frm:hid2').value;
                        var query = "Select Id, LastName, FirstName From Contact where Contact.Priority__c like \'" +check1+"%\'";  //query2
                        var forerror = sforce.connection.query(query);
                        alert('forerror     '+forerror);
                    }
                catch(err)
                    {
                        alert('err   '+err);
                    }
            }
        </script>
        <apex:actionFunction name="callname" action="{!cont}" reRender="inputhiddenfld2,hid2" oncomplete="calloncom()">
            <apex:param name="passvalue" value="" assignTo="{!passvaluecont}"/>
        </apex:actionFunction>
    </apex:form>  
</apex:page>



class
-------

public with sharing class testclass
{
    public string passvaluecont{get; set;}
    public string passdata{get; set;}
    public testclass(ApexPages.StandardController controller)
    {
    }
    public void cont()
    {
        system.debug('-----------passvaluecont------------------'+passvaluecont);
        passdata = String.escapeSingleQuotes(passvaluecont.trim());
    }
}

Now Enter value "Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx" in the text box named as "text1" and then click on button "ClickME"
it give an error, in normal case it working fine(without special character)
I just want to know how we handel the special character so that this query execute properly using Picklist having like operator
if any thing is not clear then please contact me on
Email- abhishek0674@gmail.com

We have a custom field "check" of type Picklist.
If we execute query using ajax and using sforce.connection.query in the VF page using special character like

var query = Select Id, LastName, FirstName From Contact where Contact.check__c like 'sdds!&*()_+{}|:<>?/.;][%';
var result = sforce.connection.query(query);

it give an error faultstring (give an error due to parentheses, curly braces, and square braces) other wise it is working fine
In controller it is also working fine with any special character
if we use any other field in place of "check__c" (or we can say other then picklist) then it is working fine for all the special character
can any one tell me how to execute this query properly for picklist type field(or how to handel parentheses, curly braces, and square braces for sforce.connection.query in the VF page)

We have a custom field "check" of type Picklist.
If we execute query using ajax and using sforce.connection.query in the VF page using special character like

var query = Select Id, LastName, FirstName From Contact where Contact.check__c like 'sdds!&*()_+{}|:<>?/.;][%';
var result = sforce.connection.query(query);

it give an error faultstring (give an error due to parentheses, curly braces, and square braces) other wise it is working fine
In controller it is also working fine with any special character 
if we use any other field in place of "check__c" (or we can say other then picklist) then it is working fine for all the special character
can any one tell me how to execute this query properly for picklist type field(or how to handel parentheses, curly braces, and square braces for sforce.connection.query in the VF page)

Hi all

 

    I just want to create the profile using meta data api, but there are some hurdels 

 

I am able to create custom object using metadata api the sample code for that is

 

public static void createObject()
{
MetadataService.MetadataPort service = createService();
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Test__c';
customObject.label = 'Test';
customObject.pluralLabel = 'Tests';
MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { customObject });
}

 

In the similar manner i want to create profile using meta data api, if any one has anty idea then please give me the code

Hi all

 

    I just want to create the profile using meta data api, but there are some hurdels 

 

I am able to create custom object using metadata api the sample code for that is

 

public static void createObject()
{
MetadataService.MetadataPort service = createService();
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Test__c';
customObject.label = 'Test';
customObject.pluralLabel = 'Tests';
MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { customObject });
}

 

In the similar manner i want to create profile using meta data api, if any one has anty idea then please give me the code

We have a custom field "Priority" of type Picklist in contact object.
If we execute query using Ajax  using sforce.connection.query in the VF page using special character then it gives an error in the case of picklist field

I give an example
Paste the following code in your org
For that first create a custom fild name Priority  of type Picklist Type in your Contact object having value "one", "two" ,"Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx"
now create a contact in which Priority field having value "Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx"
Page
-------
<apex:page standardController="contact" extensions="testclass" id="pg">
    <script src="/soap/ajax/16.0/connection.js" type="text/javascript"></script>
    <script src="/soap/ajax/16.0/apex.js" type="text/javascript"></script>    
    <apex:form id="frm">
        <p><b>text1</b></p><input type="text"  id="box"/>
        <input type="button" value="ClickMe" id="box12" onclick="callfun()"  />
        <apex:outputPanel id="inputhiddenfld2">
                <p><b>text2</b></p>
                <apex:inputText value="{!passdata}" id="hid2" />
        </apex:outputPanel>
        <script>
            sforce.connection.sessionId  = "{!$Api.Session_ID}";
            var check = '';
            function callfun()
            {
                try
                {
                    check = document.getElementById('box').value;
                    callname(check);
                }
                catch(err)
                {
                    alert(err);
                }
            }
            
            function calloncom()
            {
                try{       
                        var check1 = document.getElementById('pg:frm:hid2').value;
                        var query = "Select Id, LastName, FirstName From Contact where Contact.Priority__c like \'" +check1+"%\'";  //query2
                        var forerror = sforce.connection.query(query);
                        alert('forerror     '+forerror);
                    }
                catch(err)
                    {
                        alert('err   '+err);
                    }
            }
        </script>
        <apex:actionFunction name="callname" action="{!cont}" reRender="inputhiddenfld2,hid2" oncomplete="calloncom()">
            <apex:param name="passvalue" value="" assignTo="{!passvaluecont}"/>
        </apex:actionFunction>
    </apex:form>  
</apex:page>



class
-------

public with sharing class testclass
{
    public string passvaluecont{get; set;}
    public string passdata{get; set;}
    public testclass(ApexPages.StandardController controller)
    {
    }
    public void cont()
    {
        system.debug('-----------passvaluecont------------------'+passvaluecont);
        passdata = String.escapeSingleQuotes(passvaluecont.trim());
    }
}

Now Enter value "Folder~`!@#$%^$-&*()_+{}|":<>?/.,;'\][fsdsvghchx" in the text box named as "text1" and then click on button "ClickME"
it give an error, in normal case(without special character) it working fine
I just want to know how we handel the special character so that this query execute properly using Picklist having like operator
if any thing is not clear then please contact me on
Email- abhishek0674@gmail.com

We have a custom field "check" of type Picklist.
If we execute query using ajax and using sforce.connection.query in the VF page using special character like

var query = Select Id, LastName, FirstName From Contact where Contact.check__c like 'sdds!&*()_+{}|:<>?/.;][%';
var result = sforce.connection.query(query);

it give an error faultstring (give an error due to parentheses, curly braces, and square braces) other wise it is working fine
In controller it is also working fine with any special character
if we use any other field in place of "check__c" (or we can say other then picklist) then it is working fine for all the special character
can any one tell me how to execute this query properly for picklist type field(or how to handel parentheses, curly braces, and square braces for sforce.connection.query in the VF page)