• Ruwantha Lankathilaka
  • 127 Points
  • Member since 2014
  • Software Engineer

  • Chatter
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 47
how to display corresponding data in page block table of VF page Based on picklist selection.

some sample code please
When we user apex:param in the visual force

              what is the use of it.......... please let me know with code example.....................

<apex:page >
    <apex:includeScript value="{!URLFOR($Resource.satish,'/satish/js/jquery-1.8.3.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.satish,'/satish/js/jquery-ui-1.9.2.custom.js')}"/>
    <apex:includeScript value="{!URLFOR($Resource.satish,'/satish/js/jquery-ui-1.9.2.custom.min.js')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.satish,'/satish/css/ui-lightness/jquery-ui-1.9.2.custom.css')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.satish,'/satish/css/ui-lightness/jquery-ui-1.9.2.custom.min.css')}"/>
    <script type="text/javascript">

            alert('NOt loaded');
      <script type="text/javascript">

here i am dowonloaded the library file (http://jqueryui.com/download/#!version=1.9.2), and renamed the file like satish.zip the i am uploaded in to my sandbox as a static resources having the name satish instatic resources....... but i am not getting any messages as per my code like success..........
Please Help me out............ I am trying for so many days with diffierent sites.......... but i am unable to execute even single visualforce page having jQuery
Please help me ...................
                      i Would appriciate for any kind of replay..........................
trigger expenses on Expense_Payouts__c (after insert,after update) 

list<string> departmentnames= new list<string>();
Decimal amount;
for(Expense_Payouts__c ep:trigger.new)



list<Employee__c> employee = [select id,name,Expense__c,Company_Expenses__c,Department_Cost_Center__c from
				 Employee__c where Department_Cost_Center__c IN:departmentnames];

decimal divAmount;


for(Employee__c e:employee )
if(e.Department_Cost_Center__c !='Others' && divAmount!=null)

update employee;


//////////////////trigger 2///////////////////////////

trigger otherdepartment on Expense_Payouts__c (after insert, after update) {

list<employee__c> employ= [select id,name,Expense__c,Company_Expenses__c,Department_Cost_Center__c from Employee__c];
decimal amount;

for(Expense_Payouts__c e:trigger.new)

Decimal diamount;
if(employ.size()!=null && amount!=null)

for(employee__c e:employ)
update employ;

I Wrote two triggers on a same object..Now i am trying to merge them but cant able to merge both functionality in one trigger..
Please help by ur thoughts...
When writing a validation rule in a custom object field is it required to drop the global relationship inside the LEN (text) function?
eg LEN( $ObjectType.Customer__c.Fields.ID_Number__c )  gives error "Error: Incorrect parameter type for function 'LEN()'. Expected Text, received Object"

But when I put it LEN(ID_Number__c ) it works fine!!!
Hello, I am in beginner level of Salesforce. I need help, I already read and did all the steps from other forums about this Trailhead challenge but I still have the  error. 
Challenge Not yet complete... here's what's wrong: 
Could not find the 'Enter Feedback' quick action in the publisher for the 'Showing Layout' layout.  I would appreciate any help.
This is driving me crazy.

I have couple of questions in my VF page.
A has 3 checkboxes (A,B,C)
B has 3 checkboxes (A,B,C)
I've created a wrapper class with the question's Id, checkbox name and the isSelected Boolean. But it only passes the values of the last Item to controller.

Do you have any idea why it's not working?

Thx in advance!
In one Org we have data model  
Object = CountryValidity 
Field : 
  • Country = india , IsValid =True
  • Country = USA , IsValid =False
  • Country = AUS , IsValid =True
  • Country = S.Afrika , IsValid =Flase
  • Country = PAK , IsValid =True

In other org we are creating data for the same object what we want is while creating the data for object I will just enter the "country" field value and "IsValid" field's value we need to check from first org and whatevr will be the value we will store it in current org.
Hope explaination is good enough .....
Public class AutoConvertLeads
    public static void LeadAssign(List<Id> LeadIds)
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
1) Make two DateTime fields on contact object.



2) Whenever a task is created on Contact LastTaskCreatedTime field should be updated.

3) Whenever you send an email LastEmailSentTime field should be updated.

4) Make trigger as bulk
How to send json data form salesforce to external system using restresourse with username and password authentication ..?
  • November 17, 2017
  • Like
  • 0
Hi, First question so go easy on me.

We are using live agent.
After a Live agent interaction we want to ask a few survey questions.
I set up Surveyforce and have the survey being viewed and answers being save.
However would like to also save the caseID and agentID to the results.

The object <SurveyTaker> has the attributes <User_c> and <Case__c>.
I've added a div tag to the TakeSurvey visualforce page and can output the JSON with these elements (in order to convince myself they were there!) This works.
<div id="passInDataToSurvey"> 
Chat Details: <apex:outputText value="{!$CurrentPage.parameters.chatDetails}" />
Attached Records : <apex:outputText value="{!$CurrentPage.parameters.attachedRecords}" />
So I have my JSON. I want to parse that and pass through the attributes. Something like... (probably not the way to do it...)
var getUser = JSON.parse({!$CurrentPage.parameters.chatDetails}); 
document.getElementById("User__c").innerHTML = getUser.agent.userId; 

<apex:inputHidden value="{!User__c}" id="User__c"/>

But when I save the visualforce page I get the error Unknown property 'Survey__cStandardController.User__c' as the User__c attribute is on <SurveyTaker> not <Survey__c>

Would be awesome if anyone could help,

Hi Friends
When i am click on custom button in CRM account then it is working fine
But when i am click on same custom buttons in Community Portal it showing a error message like
a problem with the onclick javascript for this button or link was encountered
{faultcode:'soapenv:Server',faultstring:'Page not allowed for the profile',}

my custom button code is

window.open("/apex/GenerateInvoice?id={! Work_Order__c.Id }",'_blank');
var oppty= '{!Work_Order__c.Id }';
var result = sforce.apex.execute('Generateinvoice' ,'FieldServieRates',{opptyId:oppty});
Here my Class(Generateinvoice) is global and Method(FieldServieRates) is webservices

User-added image

Thank You
Hi everyone, 

I am creating an unmanaged package that includes three process builders, two of which are launching a visual flow. 

When I try to download the package in my developer account, I am getting this error for two of the process builders: 

myRule_1_A1 (Action Call) - We can't find an action with the name and action type that you specified. 

I have read almost everything online relating to this issue - I have deleted inactive versions of both the process builders and the visual flows, I have ensured that all fields are included in the package. Not sure what else to do, so here I am! 

Any ideas? Thank you in advance! 

Here is the class that I want to create a test class for
global class SmsDeliveryReport {

    global static void receiveReport() {
    	RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;

        if(req.params.containsKey('Transaction') && req.params.containsKey('Status')) {
        	List<Task> updatedSms = updateDeliveryStatus(req.params.get('Transaction'), req.params.get('Status'));

        	if(!updatedSms.isEmpty()) {
        		res.statuscode = 200;
		        res.addHeader('Content-Type', 'text/html');
				res.responseBody = Blob.valueOf('REPORT_RECEIVED');

        	} else {
        		res.statuscode = 500;
		        res.addHeader('Content-Type', 'text/html');
				res.responseBody = Blob.valueOf('FAILED_TO_RECEIVE_REPORT');

        } else {
        	res.statuscode = 400;
	        res.addHeader('Content-Type', 'text/html');
			res.responseBody = Blob.valueOf('MISSING_REQUIRED_FIELD');

    private static List<Task> updateDeliveryStatus(String transactionId, String newStatus) {
    	List<Task> sms = [
            SELECT SMS_Delivery_Status__c 
            FROM Task 
            WHERE SMS_Transaction_ID__c = :transactionId 
            ORDER BY CreatedDate DESC 
            LIMIT 1

    	if(!sms.isEmpty()) {
    		sms.get(0).SMS_Delivery_Status__c = newStatus;

    		update sms;

    	return sms;

I've tried to test it with CalloutWithStaticResources but it turned out that the class method declared as a void type. Here is the test class that I've tried to use:
public class SmsDeliveryReportTest {

    @isTest static void receiveReportTest() {
        // Use StaticResourceCalloutMock built-in class to
        // specify fake response and include response body 
        // in a static resource.
        StaticResourceCalloutMock mock = new StaticResourceCalloutMock();
        mock.setHeader('Content-Type', 'application/json');
        // Set the mock callout mode
        Test.setMock(HttpCalloutMock.class, mock);
        HTTPResponse res = new HTTPResponse();
        // Call the method that performs the callout
        // Verify response received contains values returned by
        // the mock response.
        // This is the content of the static resource.
        System.assertEquals('{"hah":"fooled you"}', res.getBody());
        System.assertEquals('application/json', res.getHeader('Content-Type'));   

The test is failed and I only got 18% coverage.
I will appreciate any kind of help. Thank you.
I have a trigger that I've been working on for a few days and worked through all of the errors (with a lot of help from this forum). However, it's simply not working and I can't figure out why.  This trigger is on Campaign Member and if the Current_Campaign__c value in my Lead is blank, it looks to add the Campaign_Name__c from my Campaign Member to the Current_Campaign__c field on my associated Lead record.  I've tried everything I know to do.   Here is my code:
trigger setLeadStatusandCurrentCampaign on CampaignMember (after insert) {
			/*Set<Id> leadIds = new Set<Id>();
			for (CampaignMember cml: Trigger.new){
			Map<Id, Lead> LeadMap2 = 
				new Map<Id, Lead>([SELECT Id, Current_Campaign__c, Status 
								   FROM Lead 
								   WHERE Id IN :Trigger.newMap.keyset()]);
			List<Lead> leadToUpdate2 = new List<Lead>();
			Lead associatedLead2;			
			//Loop through Campaign Member Leads and look for Current Campaign values
			for (CampaignMember cml: Trigger.new){
					associatedLead2 = LeadMap2.get(cml.LeadId);
					if(associatedLead2.Current_Campaign__c == NULL)
//This is not working
						associatedLead2.Status = 'In Campaign';
						associatedLead2.Current_Campaign__c = cml.Campaign_Name__c;
			update leadToUpdate2;

I replaced "associatedLead2.Current_Campaign__c = cml.Campaign_Name__c;" with "associatedLead2.Current_Campaign__c = "text";" to make sure it wasn't the formula field that was causing the error.  For some reason, my update isn't working.  Any ideas?
Can anyone help with Code Coverage error. Tried to update a Class (that's already in production) to include one extra field (picklist - Status__c). Test passed, but getting 0% Code Coverage when deploying to production.

public class MultiAddUSUWHold {
    private ApexPages.StandardController std;
    // the associated USUWHs
   public List<US_UW_Hold__c> USUWH;
    // the chosen USUWH id - used when deleting a USUWH
    public Id chosenUSUWHId {get; set;}
    public MultiAddUSUWHold(ApexPages.StandardController stdCtrl)
    public ISOOffice__Merchant_Application__c getApplication_Package()
     return (ISOOffice__Merchant_Application__c) std.getRecord();
    private boolean updateUSUWHs()
        boolean result=true;
        if (null!=USUWH)
           List<US_UW_Hold__c> updConts=new List<US_UW_Hold__c>();
               update USUWH;
              catch (Exception e)
                 String msg=e.getMessage();
                 integer pos;
                 // if its field validation, this will be added to the messages by default
                 if (-1==(pos=msg.indexOf('FIELD_CUSTOM_VALIDATION_EXCEPTION, ')))
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, msg));
           return result;
    public PageReference saveAndExit()
     boolean result=true;
     if (result)
        // call standard controller save
        return std.save();
      return null;
    public PageReference save()
     Boolean result=true;
     PageReference pr=Page.USUWHolds;
     if (null!=getApplication_Package().id)
     if (result)
        // call standard controller save, but don't capture the return value which will redirect to view page
           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Changes saved'));
        pr.getParameters().put('id', getApplication_Package().id);
     return pr;
    public void newUSUWH()
       if (updateUSUWHs())
          US_UW_Hold__c cont=new US_UW_Hold__c(Stip__c='', Application_Package__c=getApplication_Package().id);
          insert cont;
          // null the USUWHs list so that it is rebuilt
    public void deleteUSUWH()
       if (updateUSUWHs())
          if (null!=chosenUSUWHId)
             US_UW_Hold__c cont=new US_UW_Hold__c(Id=chosenUSUWHId);
              delete cont;
           // null the USUWHs list so that it is rebuilt
   public List<US_UW_Hold__c> getUSUWHs()
       if ( (null!=getApplication_Package().id) && (USUWH == null) )
           USUWH=[SELECT Id, Name, Stip__c, Received__c, Status__c, CreatedDate, Application_Package__r.Id
                         FROM US_UW_Hold__c 
                         WHERE Application_Package__r.Id = : getApplication_Package().ID
                         ORDER BY CreatedDate];
       return USUWH;

private class USUWHoldTest 
    public static testMethod void MultiAddUSUWHold()
        ISOOffice__Merchant_Application__c App = new ISOOffice__Merchant_Application__c();
        App.Name =  'Test for US UW Holds';
        insert App;
        US_UW_Hold__c U = new US_UW_Hold__c();
        U.Stip__c = 'CRM Testing Stip';
        U.Received__c = true;
        U.Status__c = 'Received';
        U.Application_Package__c = App.Id;
        insert U;

Tried to take off SeeAllData on test class, same results.
Anyone have idea on how to resolve this? Any help will be much appreciated :)​
  • September 28, 2017
  • Like
  • 0

I was wondering if someone would be kind enough to help me. 

I am looking for a trigger to pull into a custom object the amount for a closed won opportunity based on a user lookup field filled with their name. 

So if User Joe Bloggs has closed won £ this month, list the opportunities in the custom object called targets, so I can roll up the total amount of opportunities and compare it to a field that has a sales target. 

I dont write code unfortunatley but willing to learn. 

Your help or advice is very much appreciated in advance. 

 I want to make a chart of a custom object's   parent-child hierarchy. That part  I was done. and now i want to drag and drop nodes and change their parents in this chart.And it should have to also update in a database can anyone give some suggestions.

  I wrote below trigger and helper class which is working fine need your suggestion how to modify the code to handle bulk transaction please suggest me.

trigger CtapAssessmentTrigger on CTAP_Assessment__c (before Insert, before Update) {

     if(Trigger.isBefore) {
       if(Trigger.isInsert) {
        } else if(Trigger.isUpdate) {
            CtapAssessmentTriggerUtils.processUpdate(Trigger.newMap, Trigger.oldMap);                     

Helper Class

public class CtapAssessmentTriggerUtils {
    public static void processInsert(List<CTAP_Assessment__c> newLst) {
       for(CTAP_Assessment__c  ctap : newLst){
              ctap.Contact__c = CtapAssessmentTriggerUtils.GetContact(ctap.Partner_email__c);
              ctap.Lead__c = CtapAssessmentTriggerUtils.GetLead(ctap.Partner_email__c);
    public static void processUpdate(Map<id,CTAP_Assessment__c> newMap, Map<id,CTAP_Assessment__c> oldMap) {
      for(CTAP_Assessment__c  ctap : newMap.values()){
              ctap.Contact__c = CtapAssessmentTriggerUtils.GetContact(ctap.Partner_email__c);
              ctap.Lead__c = CtapAssessmentTriggerUtils.GetLead(ctap.Partner_email__c);
   public static String GetContact(String partneremail){
    String ContID;   
    list<Contact> con = [select id,email from contact where email = :partneremail];  
      if( con.size()>0){
        ContID = con[0].id;
     return ContID; 
   public static String GetLead(String partneremail){
     String LedID;
     list<Lead> led = [select id, email from lead where email = :partneremail];  
      if (led.size() > 0){
        LedID = led[0].id;
     return LedID;

I am trying the Lightning ExpenseTracker app.

During Step 3 - Load the Expense Data, i am running into this error.

"This page has an error. You might just need to refresh it. Error during init [Assertion Failed!: Unknown controller action 'getExpenses' : undefined]"

Has anybody experienced the same?