• pranab khatua
  • NEWBIE
  • 130 Points
  • Member since 2015

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 24
    Replies
Hello.  I am trying to add a related list (Approval Processes) to a VF page.  

I can run the following SOQL:
Select o.Name, o.Id, (Select Id, Status From ProcessInstances) From Order_vod__c o

And I can add a different related list to the page via apex:relatedList.

But if I do apex:relatedList list="ProcessInstances", i get the standard "... is not a valid child relationship ..." error.  

Any idea what I'm doing wrong?
thanks for your time.
chris
So i have test class that keeps failing when run in sandbox. The main error i am getting is:

Error MessageSystem.AssertException: Assertion Failed: Expected: , Actual: Collection
Stack TraceClass.Test_DataPushtoAccount.testDataPushtoAccount: line 19, column 1

Below is the code and im not sure why its saying its expecting a null i query it in my c = statement and the filed is set in hte creation of the customer. Can anyone let me know what im not seeing.
@isTest
public with sharing class Test_DataPushtoAccount {
	@isTest
    public static void testDataPushtoAccount(){
        Account a = new Account(Name = 'Test MainContactTrigger', RecordTypeID = '01240000000UZ4V');
 //       a.RecordType = 'Household';
        insert a;
        
        Contact c = new Contact(AccountID = a.id, firstName = 'Test MainContactTrigger', lastName = 'Tester', email = 'testfake@gmail.com', Pricing_Profile__c = 'Collection');
        insert c;
        
 //       System.debug('Contact record num: ' + [SELECT Id FROM Contact].size());
        
          
        c = [select AccountId, Account.Name, Pricing_Profile__c from Contact where id = :c.id limit 1];
           System.assertEquals('Test MainContactTrigger', a.Name);
           System.assertEquals(1, [SELECT Id FROM Contact].size());
           System.assertEquals(a.id, c.AccountId);
           System.assertEquals(a.Pricing_Profile__c, c.Pricing_Profile__c);
    }
    
}

 
How do i write a unittest for the email class. I attached my code below:
public class SendemailController {
public String OpportunityId {get;set;}

Public SendemailController(){
OpportunityId = ApexPages.currentPage().getParameters().get('Id');
}

Public Pagereference sendEmailFunction(){
Opportunity getEmail = [SELECT Id, Contact__r.email FROM Opportunity WHERE id=:OpportunityId];
   if(getEmail.Contact__r.email != null) {
     String toaddress = getEmail.Contact__r.email;

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {toaddress};
String[] ccAddresses = new String[] {toaddress};
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo(toaddress);
mail.setSenderDisplayName('Name');
mail.setSubject('Testing email through apex');
mail.setBccSender(false);
mail.setUseSignature(true);
mail.setPlainTextBody('Dear tester, here are the attechments. This mail is sent trough apex');

List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();        
for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :OpportunityId]){
   Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
   efa.setFileName(a.Name);
   efa.setBody(a.Body);
   fileAttachments.add(efa);
}    

mail.setFileAttachments(fileAttachments);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
  PageReference reference = new PageReference('https://eu11.salesforce.com/'+ OpportunityId);
  reference.setRedirect(true);
  return reference;
  }
}
Hello, I am curious how to make a apex controller or script to automate an activation process ( for over 900 contacts in a list)

User-added image
Here is the button I am trying to automate 

User-added image

Any help will be greatly appreciated! 

Thank you,

Tony.
I want to integrate  the salesforce live chat in my website. I have problem in popup chat window. i want to chat window in website not in popup.

I have write code for  it. You can check my website as http://thecloudsolutions.in/projects/livechat/index.php
 
<!-- start live chat saleforce-->
	
		<img id="liveagent_button_online_573j0000000k9bs" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('573j0000000k9bs')" src="https://law.secure.force.com/livechat/resource/1461067194000/chat_online" /><img id="liveagent_button_offline_573j0000000k9bs" style="display: none; border: 0px none; " src="https://law.secure.force.com/livechat/resource/1461067142000/chat_offline" />
<script type="text/javascript">
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('573j0000000k9bs', document.getElementById('liveagent_button_online_573j0000000k9bs'));
liveagent.showWhenOffline('573j0000000k9bs', document.getElementById('liveagent_button_offline_573j0000000k9bs'));
});</script>



<script type='text/javascript' src='https://c.la2w2.salesforceliveagent.com/content/g/js/36.0/deployment.js'></script>
<script type='text/javascript'>
liveagent.init('https://d.la2w2.salesforceliveagent.com/chat', '572j0000000k9br', '00Dj0000000K88U');
</script>
	
	<!--- end chat salesforce-->

Please any one can help me

Thanks,
Please suggest what I syllabus  cover for that exam.
How to remove "Action" like "Edit | Del" column from related List of custom object?
Please help if it is possible.
I am new in REST API. I created one demo REST Apex Class. How will I test for this are working or not? Please anyone can help how to test it.
 
@RestResource(urlMapping='/hello')
global with sharing class WebServices {
    
@HttpGet  
  global static String createNewCase() {
    String name = RestContext.request.params.get('name');
    Project__c p = new Project__c(name = name); 
    insert p;
   return  name ;
  }

    
}

The end point is https://pranab-dev-ed.my.salesforce.com/services/apexrest/hello?name=hellooo



  
public class AddNoteLeadController {

    Public Lead ld{get;set;}
    public AddNoteLeadController(ApexPages.StandardController controller) {
     
        ld = (Lead)controller.getRecord();   
    }

}


<apex:page standardController="Lead" extensions="AddNoteLeadController">
    
    <apex:form >
        
    </apex:form>
    
</apex:page>

Please help and tell me how will I get the standard lead object?
 
 Hi,

Is there a way for Salesforce to automatically calculate the VAT for a quote (per product)?

So, for example, if I go into a quote and add a line item and be able to select 10% VAT for that product . VAT will be added to Total price on Quote Line Item.
Is it possible?
Thanks.
I have 10millions  records. How will I execute the batch class using transaction.
Hi,
I am use the developer console. But I can't get any autocomplete/any code suggession for apex code. I installed the force.com IDE for eclipse but   I am getting same problem. Is it possible  in any editor for auto complete of apex code ?
been at this for hours and can't seem to figure out why my test class  isn't covering the following controller code:     } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new application.'));
      return null;
        }.

i do have a few workflow rules that are active but the initial insert of a new record would not fire any of these off...would that have an impact?

Controller is
public class KFGCreateTrainingApplicationController {

    public Applications__c applications {get; set;}
   
   // blank constructor
    public KFGCreateTrainingApplicationController() {
  applications = new Applications__c();
    }

  // save button is clicked
    public PageReference save() {
        try {
            upsert(applications); // inserts the new record into the database
        } catch (DMLException e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new application.'));
      return null;
        }
       
    // if successfully inserted new application, then displays the thank you page.
    return Page.TrainingApplicationThankYou;
    }
}


Test Is:
@isTest
public with sharing class KFGCreateTrainingAppControllerTest {
    //==================== TEST METHOD(s) ======================================
    static testMethod void KFGCreateTrainingAppControllerTest() {
     
  Applications__c newApplications = new Applications__c();
   
        // Test insert Applications__c
        newApplications.Application_Date__c = Date.Today();
        newApplications.Online_Application__c = 'Yes';
        newApplications.Class_Number_Being_Applied_For__c = 1; 
        newApplications.Applicant_First_Name__c = 'TestFirstName';
        newApplications.Applicant_Last_Name__c = 'TestLastName';
        newApplications.Age__c = 24;
        newApplications.Gender__c = 'Female';
        newApplications.Race__c = 'Latino/Hispanic';
        newApplications.Email__c = 'testreferrer@test.com';
        newApplications.State__c = 'ca';
        newApplications.Are_You_A_Current_or_Former_Foster_Youth__c = 'Yes';
        newApplications.Are_You_a_Domestic_Violence_Victim__c = 'Yes';       
        newApplications.Did_You_Attend_College__c = 'No';
        newApplications.Did_You_Attend_High_School__c = 'No';       
        newApplications.Have_You_Had_Vocational_Training__c = 'No';
        newApplications.Did_You_Serve_in_the_Armed_Forces__c = 'No';       
        newApplications.Do_You_Currently_Have_Income__c = 'No';       
        newApplications.Do_You_Have_a_History_of_Substance_Abuse__c = 'None';       
        newApplications.Do_You_Have_a_Mental_Health_Diagnosis__c = 'No';       
        newApplications.Do_You_Have_a_Physical_Disorder__c = 'No';
  newApplications.Do_You_Work_With_a_Case_Manager_Program__c = 'No';
  newApplications.How_Did_You_Hear_About_the_Program__c = 'Agency Referral';       
        newApplications.Number_of_People_You_Financially_Support__c = '1';
  newApplications.What_is_Your_Housing_Status__c = 'Rent';
        newApplications.What_is_Your_Legal_History__c = 'None';
        insert newApplications;
        KFGCreateTrainingApplicationController controller=new KFGCreateTrainingApplicationController();
        controller.save();
     
    }   
   
}
I used change set to deploy VF pages, class and test class. It get uploaed from SandBox to Production. But when i try to validate inbound change set, test class doesn't run at all. it not even getting failed. ? It been almost 24 hours.!
User-added image
Hello.  I am trying to add a related list (Approval Processes) to a VF page.  

I can run the following SOQL:
Select o.Name, o.Id, (Select Id, Status From ProcessInstances) From Order_vod__c o

And I can add a different related list to the page via apex:relatedList.

But if I do apex:relatedList list="ProcessInstances", i get the standard "... is not a valid child relationship ..." error.  

Any idea what I'm doing wrong?
thanks for your time.
chris
So i have test class that keeps failing when run in sandbox. The main error i am getting is:

Error MessageSystem.AssertException: Assertion Failed: Expected: , Actual: Collection
Stack TraceClass.Test_DataPushtoAccount.testDataPushtoAccount: line 19, column 1

Below is the code and im not sure why its saying its expecting a null i query it in my c = statement and the filed is set in hte creation of the customer. Can anyone let me know what im not seeing.
@isTest
public with sharing class Test_DataPushtoAccount {
	@isTest
    public static void testDataPushtoAccount(){
        Account a = new Account(Name = 'Test MainContactTrigger', RecordTypeID = '01240000000UZ4V');
 //       a.RecordType = 'Household';
        insert a;
        
        Contact c = new Contact(AccountID = a.id, firstName = 'Test MainContactTrigger', lastName = 'Tester', email = 'testfake@gmail.com', Pricing_Profile__c = 'Collection');
        insert c;
        
 //       System.debug('Contact record num: ' + [SELECT Id FROM Contact].size());
        
          
        c = [select AccountId, Account.Name, Pricing_Profile__c from Contact where id = :c.id limit 1];
           System.assertEquals('Test MainContactTrigger', a.Name);
           System.assertEquals(1, [SELECT Id FROM Contact].size());
           System.assertEquals(a.id, c.AccountId);
           System.assertEquals(a.Pricing_Profile__c, c.Pricing_Profile__c);
    }
    
}

 
How do i write a unittest for the email class. I attached my code below:
public class SendemailController {
public String OpportunityId {get;set;}

Public SendemailController(){
OpportunityId = ApexPages.currentPage().getParameters().get('Id');
}

Public Pagereference sendEmailFunction(){
Opportunity getEmail = [SELECT Id, Contact__r.email FROM Opportunity WHERE id=:OpportunityId];
   if(getEmail.Contact__r.email != null) {
     String toaddress = getEmail.Contact__r.email;

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {toaddress};
String[] ccAddresses = new String[] {toaddress};
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);
mail.setReplyTo(toaddress);
mail.setSenderDisplayName('Name');
mail.setSubject('Testing email through apex');
mail.setBccSender(false);
mail.setUseSignature(true);
mail.setPlainTextBody('Dear tester, here are the attechments. This mail is sent trough apex');

List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();        
for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :OpportunityId]){
   Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
   efa.setFileName(a.Name);
   efa.setBody(a.Body);
   fileAttachments.add(efa);
}    

mail.setFileAttachments(fileAttachments);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
  PageReference reference = new PageReference('https://eu11.salesforce.com/'+ OpportunityId);
  reference.setRedirect(true);
  return reference;
  }
}
Hello, I am curious how to make a apex controller or script to automate an activation process ( for over 900 contacts in a list)

User-added image
Here is the button I am trying to automate 

User-added image

Any help will be greatly appreciated! 

Thank you,

Tony.
Hi.. I am using <iframe> tag in my VF page and want to post doubts:

1) I am using src as bucket url - "https://bucketeer-8c4ead3e-9208-43cb-bb6c-f4a5cc3b597e.s3.amazonaws.com/......html/". I have set the X-Frame-Options to "Allow" for my bucket. Now when I use the above path as src, instead of showing the content of .html file it is directly getting downloaded and when I see the console, I find below:

"Resource interpreted as Document but transferred with MIME type application/octet-stream in iframe"

2) Since I was not able to get any positive solution on 1, I was trying to implement "http://jsfiddle.net/Y9beh/", however same doesnt work in my Salesforce instance. 

Can anybody please comment on above mentioned points?
Here my code is

public class FileUploader 
{
    public string nameFile{get;set;}
    public Blob contentFile{get;set;}
    String[] filelines = new String[]{};
    List<Account> accstoupload;
    
    public Pagereference ReadFile()
    {
        try{
                nameFile =blobToString( contentFile,'ISO-8859-1');
                
                filelines = nameFile.split('\n');
                
                accstoupload = new List<Account>();
                for (Integer i=1;i<filelines.size();i++)
                {
                    String[] inputvalues = new String[]{};
                    inputvalues = filelines[i].split(',');
                    
                    Account a = new Account();
                    a.Name = inputvalues[0];
                    a.ShippingStreet = inputvalues[1];       
                    a.ShippingCity = inputvalues[2];
                    a.ShippingState = inputvalues[3];
                    a.ShippingPostalCode = inputvalues[4];
                    a.ShippingCountry = inputvalues[5];
        
                    accstoupload.add(a);
                }
         }
         catch(Exception e){
                 ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured reading the CSV file'+e.getMessage());
                ApexPages.addMessage(errormsg);
         }       
        try{
            insert accstoupload;
        }
        catch (Exception e)
        {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured inserting the records'+e.getMessage());
            ApexPages.addMessage(errormsg);
        }    
        return null;
    }
   
    public List<Account> getuploadedAccounts()
    {
        if (accstoupload!= NULL)
            if (accstoupload.size() > 0)
                return accstoupload;
            else
                return null;                    
        else
            return null;
    }  
        
    public static String blobToString(Blob input, String inCharset){
        String hex = EncodingUtil.convertToHex(input);
        System.assertEquals(0, hex.length() & 1);
        final Integer bytesCount = hex.length() >> 1;
        String[] bytes = new String[bytesCount];
        for(Integer i = 0; i < bytesCount; ++i)
            bytes[i] =  hex.mid(i << 1, 2);
        return EncodingUtil.urlDecode('%' + String.join(bytes, '%'), inCharset);
    }         
}
Hi Friends
i have two fields one is text field (field__c) another is formula field (formula__c).if formula field value is "c2" and text field value is blank its showing error message .i have tried this but ist not working
 
if( curriculum .Product_Code__c =='C2' && curriculum .No_of_ups__c==null  )
        {
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please fill the field value !!!...........'));
   return null;
        }

 
Hello,

I am calling one rest api in salesforce. Following is the deatil code:

 HttpRequest req = new HttpRequest();
                req.setEndpoint('https://example.com'+lo[0].Company__c);
                req.setMethod('GET');
                req.setHeader('ACCEPT','application/xml');
                req.setHeader('Authorization', authorizationHeader);
                Http http = new Http();
                HTTPResponse res = http.send(req);
                system.debug('res:'+res);

In above code lo[0].Comapny__c value is " Test Example " . In this name there is space between Test and Example. When My code execute for this example it is given me blank response body.

I am passing like "TestExample" it is working. Actually when space came at that time "%20" should pass in that url. 

I know how to do in .net , PHP, JAva ( line encodeURI("Test Example)"). 

How can i do this in Salesforce? Please help me.
Hi,
I am able to integrate the live agent into my app, but it always pop up a new window. I am trying to make it display in an iframe within the page to avoid a pop up window. I have look into liveagent.startChatWithWindow(), but I couldn't get it to work when I pass the iframe id as parameter to the function. Is it possible to do that? Thanks!

Hi Community,

I am new to Salesforce and using APEX.  I am completely self-taught too.  With that said, I am trying to learn triggers and cannot find an exact example of how to achieve what I am working on.  My problem is that when a Contact updates their information through my Visualforce page, Salesforce will overwright fields with the new data they inputted - which is great, except for the 'Description' field.  I want the new 'Description' to append to whatever they previously had written in that field.  Can anyone help me?

The pseudo code would be something like:

trigger UpdateDescription on Contact (before update) {
          Contact.Description = Contact.OldDescription + " " + Contact.NewDescription;

}

Thank you in advance for your help!

Hi All,

Can anyone send me the source code for this requirement.

Thanks in advance
How to diable commandbutton by comparing two field values of two dfferent object.

Thanks
Hi,

We are seeking an app developer to create a business to consumer mobile app, in which customers will be booking, and paying for various services offered by various vendors.

For those interested, please provide your contact info.

Dan
Hi,
I am trying to diplay a VF page as a custom console component (subtab - right sidebar) and get the message 'undefined'. When I add a related list in the same section it diplays fine. When I add my VF page it in the detail page layout it works but not in the sidebar. What do I miss?

User-added image

Here is my codes:
VisualforcePage: CaseList
<apex:page standardController="Case" extensions="CaseListController">
<apex:form > 
<apex:pageBlock >
<apex:pageBlockTable value="{!CA}" var="C" columnsWidth="10%,50%,20%,20%" > 
                                                             
                <apex:column headerValue="Case Number" >
                <apex:commandLink value="{!C.CaseNumber}" action="/{!C.Id}" target="_blank" />
                </apex:column>                
                <apex:column headerValue="Subjet" value="{!C.Subject}" />
                <apex:column headerValue="Status" value="{!C.Status}" />
                <apex:column headerValue="Created Date" value="{!C.CreatedDate}" />       
</apex:pageBlockTable>               
</apex:pageBlock>
</apex:form>
</apex:page>
ApexClass: CaseListController
public with sharing class CaseListController {

    public List<Case> CA { get; private set; }

    public CaseListController(ApexPages.StandardController controller) {
       if (Test.isRunningTest() == false) {
      controller.addFields(new List<String>{ 'ContactId' });
}
        Case currentCase = (Case)controller.getRecord();
        CA = [Select Id, CaseNumber, CreatedDate, Status, Subject, ContactId FROM Case Where ContactId = :currentCase.ContactId and Id != :currentCase.Id Order by CaseNumber DESC Limit 5];
      }
}

Thank you in advance for your help.
Sylvie