• Div403
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 14
    Replies
Hi All,

I am unable to pass the values from input hidden values to javascript function.

In javascript i am not able to get the URL from controller. When i click button, alert box is not displaying.

Please find the below code
VisualForce Page Code
<apex:page controller="ExampleController" action="{!ExampleMethod}">
<script>

function URL()
{
    var URL = document.getElementById('{!$Component.theHiddenInput}').value;

    alert('URL'+URL);
}
</script>
<apex:form >
  <apex:pageMessages />
  <apex:inputHidden value="{!values}" id="theHiddenInput"/>
<apex:commandButton onclick="URL()" value="OK" rerender="e"/>
 </apex:form>
</apex:page>

Apex Code

public with sharing class ExampleController{
Public string values{get; set;}
public ExampleController(){
values = System.currentPageReference().getParameters().get('URL');
System.debug('URL'+values);
}

public pagereference ExampleMethod(){
Public String URL='https://google.co.in';
PageReference Page=new PageReference(URL);
         Page.Redirect(true);
         return Page;
}
}
 
  • February 17, 2015
  • Like
  • 0
Hi All,

I am trying to open google chrome window while clicking on salesforce custom button in Internet Explorer.

I am trying the below javascript code to open chrome browser in internet explorer by clicking on custom button

function openChrome{
var url = 'http://google.co.in';
var chromeCommand = "Chrome --app="+URL+" --allow-outdated-plugins";
var shell = new ActiveXObject("WScript.Shell");
shell.run(chromeCommand);
}

Any help is appreciated!!
  • February 17, 2015
  • Like
  • 1
Hi All,

I am unable to pass the custom field values to the below alert box. My scenario is like when i click on the custom button, i need to pass item_id__c via url to open the visual page. 

var Account = "{!Account.Id}";
var AccountName = "{!Account.Name}";
var ItemName= "{!Account.Item_ID__c}";
if(Account!=null)
{
alert('Account'+ItemName);
window.open('https://www.google.com?item='+ItemName);
}
  • February 04, 2015
  • Like
  • 0
Hi All,

When i click on any row using onrowclick function in apex:pageBlockTable. I am able to select the row using javascript functionality but i am not able to get the selected row data to from vf page to controller/avascript to populate selected row data in alert box.

Can any one help me How to get selected row data in controller? 

Please find the vfpage and controller

Visualforce Page
 
<apex:includeScript value="{!URLFOR($Resource.jquery,'/js/jquery-1.4.2.min.js')}" /> 
<script> $j = jQuery.noConflict(); 
var lastRow; 
var sample = document.getElementById('Name').value; 
var firstname1 = document .getElementById('{!$Component.form.pageBlockContact.Name}').value; 
function highlight(elem)
{ if(lastRow != undefined)
lastRow.style.backgroundColor = 'white';
elem.style.backgroundColor = 'yellow'; lastRow = elem;
alert('DDDD'+firstname1 );
alert('DDDDDDD'+sample); 
} 
</script>
<apex:form id="form"> 
<apex:pageBlock id="pageBlockContact"> 
<apex:pageBlockSection columns="1"> 
<apex:pageBlockTable value="{!list1}" var="item" rules="rows" id="example" onRowClick="clickElem(this);"> 
<apex:column value="{!item.Name}" id="Name" styleclass="name" /> 
</apex:pageBlockTable> 
</apex:pageBlockSection>
<apex:commandButton action="{!ok}" value="ok" /> 
</apex:pageBlock>
</apex:form>
</apex:page>

Controller
 
public class SampleController {

    public PageReference ok() {
        return null;
    
    }
    
    public List<Claims__c> list1 { get; set; }

   
    public SampleController ()
{
   list1 = [select id,name from claims__c];
}

}

Output: Based on above vf page and controller
User-added image
  • January 02, 2015
  • Like
  • 1
Hi All,

I have tried so many functioanlities but am unable to insert the checkbox value in custom object 

Kindly help me out of this

VF Page
<apex:page standardcontroller="TestExample__c" extensions="TestExample">
<apex:form>
<apex:selectCheckboxes title="Reinsurance Verification" value="{!test.TestPage__c}">
             <apex:selectOption value="{!test3}"> </apex:selectOption>
         </apex:selectCheckboxes>
<apex:outputPanel layout="block">
    <apex:commandButton value="Save and Close"   action="{!Save}"/>                           
        </apex:outputPanel>                              
</apex:form>
</apex:page>

controller

public class TestExample{
public TestExample Test{get; set;}
public SelectOption test3 {get;set;}
public TestExample{
test3 = new SelectOption('Apex', 'Apex');
test=new TestExample__c();    
}
public PageReference Save() {
TestExample__c t = new TestExample__c();
t.TestPage__c = Test.TestPage__c;
insert t;
}
}
  • December 31, 2015
  • Like
  • 0
Hi All,

I have created a new apex class and vf page to insert data into a custom object. I am able to insert record in custom object but values are not displaying in record which i have given in vf page.

Kindly help me to solve this

VF Page
<apex:page standardcontroller="Claims__c" extensions="NotesController11">
<apex:form>
<h1 style="font-size:30px"><Center> Reinsurance Verification</center> </h1>
<apex:pageBlock id="Details">
<apex:pageBlockSection columns="2" title="Company Information">
<apex:inputfield value="{!Test.Claim_Numbers__c}"/> 
</apex:pageBlockSection>            
</apex:pageBlock>
<apex:outputPanel layout="block">
<apex:commandButton value="Save and Close" action="{!Save}" immediate="true" /> 
</apex:outputPanel>                          
</apex:form>                               
</apex:page>

Apex Controller

public class NotesController11 {

    public Claims__c Test{get; set;}
    public NotesController11(ApexPages.StandardController controller) {
        test= new Claims__c();
        }

    public PageReference Save() {
 
        Claims__c rv = new Claims__c();
        rv.Claim_Numbers__c= Test.Claim_Numbers__c;
        insert rv;
        PageReference Page = new PageReference('/'+rv.id);
        Page.setRedirect(true);
        return Page;

    }

}

Output:

User-added image
  • December 30, 2015
  • Like
  • 0
Hi All,

Can any one help me to solve the below issue. 

I have created a tabs with the help of visualforce page. Now, i need to show the prompt box when user clicks on any tab to enter the dynamic values in Prompt box.

For Example, if i click on below Account Tab, i need to show the Prompt box. 

Please find the below code snippet of visualforce page

<apex:page>
<apex:tabPanel switchType="client" selectedTab="sample" id="theTabPanel">
<apex:tab label="Accounts" name="account1" id="tabOne">
content for tab one
</apex:tab>
<apex:tab label="Opportunities" name="opportunities2" id="tabTwo">
content for tab two
</apex:tab>
</apex:tabPanel>
</apex:page>

Please find the below screenshot. 

Custom tabs created created based on visualforce page
  • November 21, 2014
  • Like
  • 0
Hi All,

I am able to display set of records in visual force page using JSON.

Please guide me how to add checkboxes to the below code

Apex Class

global class DataTableController {
 
    // Defines shape of JSON response
    global class Response {
        public Integer sEcho;
        public Integer iTotalRecords;
        public Integer iTotalDisplayRecords;
        public SObject[] aaData;
        Response(Integer echo, Integer total, SObject[] sobs) {
            this.sEcho = echo;
            this.iTotalRecords = total;
            this.iTotalDisplayRecords = total;
            this.aaData = sobs;
        }
    }
 
    // DataTable passes JSON definition of what server should do
    private class Params {
     
        Map<String, Object> m = new Map<String, Object>();
         
        Integer echo;
        Integer start;
        Integer length;
        String[] columns;
        Integer[] sortColumns;
        String[] sortDirections;
         
        Params(List<Map<String, Object>> request) {
            for (Map<String, Object> r : request) {
                m.put((String) r.get('name'), r.get('value'));
            }
            echo = integer('sEcho');
            start = integer('iDisplayStart');
            length = integer('iDisplayLength');
            columns = stringArray('mDataProp');
            sortColumns = integerArray('iSortCol');
            sortDirections = stringArray('sSortDir');
        }
         
        String[] stringArray(String prefix) {
            String[] strings = new String[] {};
            for (Object o : array(prefix)) {
                strings.add(o != null ? esc(String.valueOf(o)) :null);
            }
            return strings;
        }
         
        Integer[] integerArray(String prefix) {
            Integer[] integers = new Integer[] {};
            for (Object o : array(prefix)) {
                integers.add(o != null ? Integer.valueOf(o) : null);
            }
            return integers;
        }
 
        Object[] array(String prefix) {
            Object[] objects = new Object[] {};
            for (Integer i = 0; true; i++) {
                Object o = m.get(prefix + '_' + i);
                if (o != null) {
                    objects.add(o);
                } else {
                    break;
                }
            }
            return objects;
        }
         
        Integer integer(String name) {
           Object o = m.get(name);
           if (o instanceof Decimal) {
               return ((Decimal) o).intValue();
           } else if (o instanceof Integer) {
               return (Integer) o;
           } else {
               return null;
           }
        }
         
        // Guard against SOQL injection
        String esc(String s) {
            return s != null ? String.escapeSingleQuotes(s) : null;
        }
    }
     
    @RemoteAction
    global static Response contacts(List<Map<String, Object>> request) {
     
        Params p = new Params(request);
 
        String soql = ''
                + ' select ' + String.join(p.columns, ', ')
                + ' from Contact'
                + ' order by ' + String.join(orderBys(p), ', ')
                + ' limit :length'
                + ' offset :start'
                ;
        System.debug('>>> soql=' + soql);
 
        Integer start = p.start;
        Integer length = p.length;
        return new Response(
                p.echo,
                [select Count() from Contact limit 40000],
                Database.query(soql)
                );
    }
     
    private static String[] orderBys(Params p) {
        Map<String, String> soqlDirections = new Map<String, String>{
                'asc' => 'asc nulls last',
                'desc' => 'desc nulls first'
                };
        String[] orderBys = new String[] {};
        Integer min = Math.min(p.sortColumns.size(), p.sortDirections.size());
        for (Integer i = 0; i < min; i++) {
            orderBys.add(''
                    + p.columns[p.sortColumns[i]]
                    + ' '
                    + soqlDirections.get(p.sortDirections[i])
                    );
        }
        return orderBys;
    }
}

Visula Force Page

<apex:page controller="DataTableController">
 
<link
rel="stylesheet"
type="text/css"
href="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css"
/>
 
<apex:sectionHeader title="DataTables"/>
 
<table id="table" cellpadding="0" cellspacing="0" border="0">
    <thead>
        <th>Name</th>
        <th>Birthdate</th>
        <th>Phone</th>
        <th>Email</th>
        
    </thead>
    <tbody>
    </tbody>
</table>
 
<script
type="text/javascript"
charset="utf8"
src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"
>
</script>
<script
type="text/javascript"
charset="utf8"
src="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"
>
</script>
<script>



var j$ = jQuery.noConflict();
 
var fields = ['Name', 'Birthdate', 'Phone', 'Email'];
 
var aoColumns = [];
for (var i = 0; i < fields.length; i++) {
    aoColumns.push({'mData': fields[i]});
}
 
j$(document).ready(function() {
    j$('#table').dataTable({
        'aoColumns': aoColumns,
        'bProcessing': true,
        'bServerSide': true,
        'bFilter': false,
        'sAjaxSource': 'fakeUrl',
        'fnServerData': function(sSource, aoData, fnCallback) {
            console.log(JSON.stringify(aoData));
            // Call the @RemoteAction JavaScript function
            DataTableController.contacts(aoData, function(result, event) {
                if (event.type != 'exception') {
                    console.log(JSON.stringify(result));
                    for (var i = 0; i < result.aaData.length; i++) {
                        var r = result.aaData[i];
                        for (var j = 0; j < fields.length; j++) {
                            var field = fields[j];
                            if (r[field] == undefined) {
                                // DataTables pops a dialog for undefined values
                                r[field] = null;
                            } else if (field == 'Birthdate') {
                                // Dates transmitted as longs
                                var d = new Date(r[field]);
                                r[field] = ''
                                        + (d.getMonth() + 1)
                                        + '/'
                                        + d.getDate()
                                        + '/'
                                        + d.getFullYear()
                                        ;
                            }
                        }
                    }
                    // Call back into the DataTable function
                    fnCallback(result);
                } else {
                    alert(event.message);
                }
            });
        }
    });
});
 
</script>
 
</apex:page>
  • November 18, 2014
  • Like
  • 0
Hi All,

We made a connection between WCF 4.5 and Salesforce.

In salesforce we have 150000 contact records.We want to fetch all 150000 records in WCFTestClient but we were able to fetch only 55000 records in WCFTestClient, after that we got out of memory exception.

Can any one help us to guide how to solve the above issue?
 
  • November 13, 2014
  • Like
  • 0
trigger DuplicateAccountNameCountryCheck1 on Account (before insert, before update)
{
    For(Account a:Trigger.New)
    {
        List<Account> acc=[SELECT Id, Name FROM Account WHERE Name=:a.Name AND BillingCountry=:a.BillingCountry];
        if(acc.size()>0)
        {
            a.addError('You are not allow to create duplicate Account Name with the same Country');
        } 
    }
}
  • October 31, 2014
  • Like
  • 0
I am recieving the following error message when trying to load records in vf page

"List controllers are not supported in Campaign Members"

Can anyone knows the solution for the above error? Please help us.

Thanks in advance
  • September 17, 2014
  • Like
  • 0
Hi All,

I am trying to open google chrome window while clicking on salesforce custom button in Internet Explorer.

I am trying the below javascript code to open chrome browser in internet explorer by clicking on custom button

function openChrome{
var url = 'http://google.co.in';
var chromeCommand = "Chrome --app="+URL+" --allow-outdated-plugins";
var shell = new ActiveXObject("WScript.Shell");
shell.run(chromeCommand);
}

Any help is appreciated!!
  • February 17, 2015
  • Like
  • 1
Hi All,

When i click on any row using onrowclick function in apex:pageBlockTable. I am able to select the row using javascript functionality but i am not able to get the selected row data to from vf page to controller/avascript to populate selected row data in alert box.

Can any one help me How to get selected row data in controller? 

Please find the vfpage and controller

Visualforce Page
 
<apex:includeScript value="{!URLFOR($Resource.jquery,'/js/jquery-1.4.2.min.js')}" /> 
<script> $j = jQuery.noConflict(); 
var lastRow; 
var sample = document.getElementById('Name').value; 
var firstname1 = document .getElementById('{!$Component.form.pageBlockContact.Name}').value; 
function highlight(elem)
{ if(lastRow != undefined)
lastRow.style.backgroundColor = 'white';
elem.style.backgroundColor = 'yellow'; lastRow = elem;
alert('DDDD'+firstname1 );
alert('DDDDDDD'+sample); 
} 
</script>
<apex:form id="form"> 
<apex:pageBlock id="pageBlockContact"> 
<apex:pageBlockSection columns="1"> 
<apex:pageBlockTable value="{!list1}" var="item" rules="rows" id="example" onRowClick="clickElem(this);"> 
<apex:column value="{!item.Name}" id="Name" styleclass="name" /> 
</apex:pageBlockTable> 
</apex:pageBlockSection>
<apex:commandButton action="{!ok}" value="ok" /> 
</apex:pageBlock>
</apex:form>
</apex:page>

Controller
 
public class SampleController {

    public PageReference ok() {
        return null;
    
    }
    
    public List<Claims__c> list1 { get; set; }

   
    public SampleController ()
{
   list1 = [select id,name from claims__c];
}

}

Output: Based on above vf page and controller
User-added image
  • January 02, 2015
  • Like
  • 1
Hi All,

I am unable to pass the values from input hidden values to javascript function.

In javascript i am not able to get the URL from controller. When i click button, alert box is not displaying.

Please find the below code
VisualForce Page Code
<apex:page controller="ExampleController" action="{!ExampleMethod}">
<script>

function URL()
{
    var URL = document.getElementById('{!$Component.theHiddenInput}').value;

    alert('URL'+URL);
}
</script>
<apex:form >
  <apex:pageMessages />
  <apex:inputHidden value="{!values}" id="theHiddenInput"/>
<apex:commandButton onclick="URL()" value="OK" rerender="e"/>
 </apex:form>
</apex:page>

Apex Code

public with sharing class ExampleController{
Public string values{get; set;}
public ExampleController(){
values = System.currentPageReference().getParameters().get('URL');
System.debug('URL'+values);
}

public pagereference ExampleMethod(){
Public String URL='https://google.co.in';
PageReference Page=new PageReference(URL);
         Page.Redirect(true);
         return Page;
}
}
 
  • February 17, 2015
  • Like
  • 0
Hi All,

I am trying to open google chrome window while clicking on salesforce custom button in Internet Explorer.

I am trying the below javascript code to open chrome browser in internet explorer by clicking on custom button

function openChrome{
var url = 'http://google.co.in';
var chromeCommand = "Chrome --app="+URL+" --allow-outdated-plugins";
var shell = new ActiveXObject("WScript.Shell");
shell.run(chromeCommand);
}

Any help is appreciated!!
  • February 17, 2015
  • Like
  • 1
Hi All,

I am unable to pass the custom field values to the below alert box. My scenario is like when i click on the custom button, i need to pass item_id__c via url to open the visual page. 

var Account = "{!Account.Id}";
var AccountName = "{!Account.Name}";
var ItemName= "{!Account.Item_ID__c}";
if(Account!=null)
{
alert('Account'+ItemName);
window.open('https://www.google.com?item='+ItemName);
}
  • February 04, 2015
  • Like
  • 0
Hi All,

When i click on any row using onrowclick function in apex:pageBlockTable. I am able to select the row using javascript functionality but i am not able to get the selected row data to from vf page to controller/avascript to populate selected row data in alert box.

Can any one help me How to get selected row data in controller? 

Please find the vfpage and controller

Visualforce Page
 
<apex:includeScript value="{!URLFOR($Resource.jquery,'/js/jquery-1.4.2.min.js')}" /> 
<script> $j = jQuery.noConflict(); 
var lastRow; 
var sample = document.getElementById('Name').value; 
var firstname1 = document .getElementById('{!$Component.form.pageBlockContact.Name}').value; 
function highlight(elem)
{ if(lastRow != undefined)
lastRow.style.backgroundColor = 'white';
elem.style.backgroundColor = 'yellow'; lastRow = elem;
alert('DDDD'+firstname1 );
alert('DDDDDDD'+sample); 
} 
</script>
<apex:form id="form"> 
<apex:pageBlock id="pageBlockContact"> 
<apex:pageBlockSection columns="1"> 
<apex:pageBlockTable value="{!list1}" var="item" rules="rows" id="example" onRowClick="clickElem(this);"> 
<apex:column value="{!item.Name}" id="Name" styleclass="name" /> 
</apex:pageBlockTable> 
</apex:pageBlockSection>
<apex:commandButton action="{!ok}" value="ok" /> 
</apex:pageBlock>
</apex:form>
</apex:page>

Controller
 
public class SampleController {

    public PageReference ok() {
        return null;
    
    }
    
    public List<Claims__c> list1 { get; set; }

   
    public SampleController ()
{
   list1 = [select id,name from claims__c];
}

}

Output: Based on above vf page and controller
User-added image
  • January 02, 2015
  • Like
  • 1
Hi All,

I have tried so many functioanlities but am unable to insert the checkbox value in custom object 

Kindly help me out of this

VF Page
<apex:page standardcontroller="TestExample__c" extensions="TestExample">
<apex:form>
<apex:selectCheckboxes title="Reinsurance Verification" value="{!test.TestPage__c}">
             <apex:selectOption value="{!test3}"> </apex:selectOption>
         </apex:selectCheckboxes>
<apex:outputPanel layout="block">
    <apex:commandButton value="Save and Close"   action="{!Save}"/>                           
        </apex:outputPanel>                              
</apex:form>
</apex:page>

controller

public class TestExample{
public TestExample Test{get; set;}
public SelectOption test3 {get;set;}
public TestExample{
test3 = new SelectOption('Apex', 'Apex');
test=new TestExample__c();    
}
public PageReference Save() {
TestExample__c t = new TestExample__c();
t.TestPage__c = Test.TestPage__c;
insert t;
}
}
  • December 31, 2015
  • Like
  • 0
Hi All,

I have created a new apex class and vf page to insert data into a custom object. I am able to insert record in custom object but values are not displaying in record which i have given in vf page.

Kindly help me to solve this

VF Page
<apex:page standardcontroller="Claims__c" extensions="NotesController11">
<apex:form>
<h1 style="font-size:30px"><Center> Reinsurance Verification</center> </h1>
<apex:pageBlock id="Details">
<apex:pageBlockSection columns="2" title="Company Information">
<apex:inputfield value="{!Test.Claim_Numbers__c}"/> 
</apex:pageBlockSection>            
</apex:pageBlock>
<apex:outputPanel layout="block">
<apex:commandButton value="Save and Close" action="{!Save}" immediate="true" /> 
</apex:outputPanel>                          
</apex:form>                               
</apex:page>

Apex Controller

public class NotesController11 {

    public Claims__c Test{get; set;}
    public NotesController11(ApexPages.StandardController controller) {
        test= new Claims__c();
        }

    public PageReference Save() {
 
        Claims__c rv = new Claims__c();
        rv.Claim_Numbers__c= Test.Claim_Numbers__c;
        insert rv;
        PageReference Page = new PageReference('/'+rv.id);
        Page.setRedirect(true);
        return Page;

    }

}

Output:

User-added image
  • December 30, 2015
  • Like
  • 0
trigger DuplicateAccountNameCountryCheck1 on Account (before insert, before update)
{
    For(Account a:Trigger.New)
    {
        List<Account> acc=[SELECT Id, Name FROM Account WHERE Name=:a.Name AND BillingCountry=:a.BillingCountry];
        if(acc.size()>0)
        {
            a.addError('You are not allow to create duplicate Account Name with the same Country');
        } 
    }
}
  • October 31, 2014
  • Like
  • 0
I am recieving the following error message when trying to load records in vf page

"List controllers are not supported in Campaign Members"

Can anyone knows the solution for the above error? Please help us.

Thanks in advance
  • September 17, 2014
  • Like
  • 0

Hi, 

 

  I am new to SalesForce and Am newbie learning Visual Force and Apex Codding. I created a new custom object with name customer_details_c and desinged a page using visual force. 

 

 In customer_details_c object it has First_Name_c and Last_Name_c as two custom fields. 

 

 Now My requirement is to create a class or controller to insert the data into customer_details_c object. Please suggest me know. How to write the class or controler with an example. 

 

Thanks

Sudhir