• Hengky Ilawan
  • SMARTIE
  • 564 Points
  • Member since 2012

  • Chatter
    Feed
  • 22
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 170
    Replies
Hello,

I am retrieving notes which have line breaks in the body.  I have created a custom extension and pageblocktable to display the note data including the body but the line breaks are ignored in the body column of the table, how do I get the column to recognize the line breaks properly?

Thanks!

Hello,

 

 

   How to display renderas="pdf" visual force page in A5 size am using like

 

<head>
<style>
@page :first
{
size:landscape;
margin-top:0%;
@top-center
{
content: element(header2);
}
}
@page
{
size:landscape;
margin-top:18%;
}
</style>

</head>

 

Is it correct way to set size in A5 page?

 

Can any one help?

 

 

Thank you

 

 

Hi

I have a scenario

i have to a field on opportunity ,i want populate that value in my account record.

for one account so many opportunitys or there ,so i need to populate distinct values into account object field.

 

ex: i have 1 account ,4 opportunitys

opportunity filed values :

1 a

2 A

3 b

4 B

 

so in the account filed i need to show only  A,B

 

 

How can i do this below is the ,my trigger am populating the values into account filed,but am not able to compare the small and capital letters or the same.

 

trigger Populating_CCY_Pair  on Opportunity (after insert,after update) {
List<opportunity> op=new List<opportunity>();
List<opportunity> opp=new List<opportunity>();
Set<id> accIds = new Set<Id>();
string ccy_pair;
set<string> uniuqvalues=new set<String>();
op=[select id,name,Bought_CCY__c,CCY_Pair__c,Sold_CCY__c,accountid from opportunity where id=:trigger.new];

for(opportunity o:op)
{
if(o.accountid != null)
        {
            accIds.add(o.accountid);
        }
}
Account ac=[select id,name,CCY_Pairs_Traded__c from account where id=:accIds];
opp=[select id,name,Bought_CCY__c,CCY_Pair__c,Sold_CCY__c,accountid  from opportunity where accountid=:accIds];
ccy_pair='';

for(Opportunity o1:opp)
{
if(!uniuqvalues.contains(o1.CCY_Pair__c))
{
uniuqvalues.add(o1.CCY_Pair__c);
ccy_pair=ccy_pair+o1.CCY_Pair__c+';';
system.debug('uniuqvalues of valuews'+ccy_pair);
}
}

ac.CCY_Pairs_Traded__c=ccy_pair.touppercase().trim();

system.debug('account updated fields'+ac.CCY_Pairs_Traded__c);
update ac;
system.debug('account updated records'+ac);

}

 

 

regrads

venkatesh.

 

 

Hello Everyone,

 

i have a button called "Generate PDF" on Account Detail page. 

Once we click on the button i want to generate a pdf file and want to insert into an attachments related list.

 

Any suggestions would be helpful.

 

Thanks,

Anil

Within this code, I want to check what's the OLD value of the field Status. This code gives me this error message:


Error: Compile Error: Method does not exist or incorrect signature: [LIST<Contract>].get(String) at line 4 column 70

 

I know that this is not a complete code - I just need someone to look at this part of the code and tell me how can I quickly check what is the old value of con.Status.

 

How can I fix this?

 

for(Contract con : trigger.new){
        if(con.Contract_Years__c != null && trigger.old.get(con.Status) != 'Active')

 

Thank you.

  • January 10, 2013
  • Like
  • 0

Hi 

 

 

To pass the list of ids from one page to another we use the query string with pagereference statement.

 

like this return (new pagereference('/apex/mytestpage?cityVal='+cityValue+'&locationVal='+locationVal).setredirect(true));

 

Instead of passing individually  can we passa list variable

 

List<String> params = new List<String>();

params.add(cityValue);

params.add(locationVal);

 

then i pass this list in query string there in next page i get this id and split the values then i use.

 

Is this possible?

Hi,

 

I'm trying to implement a custom search screen for a custom object based on fields.

 

And i'm planning to use inputField to get the field query. inputField should display correct widget based on the type  (if it's  date, date picker, if a user lookup user selector etc.) But it does not display anything for read only fields (like Last Modified Date etc.). What might be the reason and also how can I implement this?

 

Thanks,

John

I'm new and learning Apex.  I'm having an issue with a trigger I wrote.  It hits the script statements govenor and causes the error "System.LimitException: Too many script statements: 200001".  It works with single updates. The error was caused when I tested it by updating 2,000 opportunity records and started after 937 were succesfully updated.

 

There are three revenue fields on Opportunity (Monthly, Prorated, Membership).  When an opportunity is updated, the trigger searchs through its products and determines which field the revenue belongs to using the product description.

 

trigger Test2 on Opportunity (before insert, before update) {

// CREATE PRODUCT LIST FOR THE OPPORTUNITIES
List<OpportunityLineItem> prodList = [select ID, OpportunityId, Description, TotalPrice from OpportunityLineItem where OpportunityId in: Trigger.new];

// DEFINE STRINGS USED TO DETERMINE TYPE OF PRODUCT
String Prorated = 'Prorated';
String Membership = 'Membership';

// LOOP THROUGH OPPORTUNITIES, RESET 3 REVENUE FIELDS TO 0
	for(Opportunity a : Trigger.new){
		a.Prorated_Total__c = 0;
		a.Membership_Total__c = 0;
		a.Monthly_Total__c = 0;

// LOOP THROUGH PRODUCT LIST TO GET REVENUE TYPE AND TOTAL FOR CURRENT OPPORTUNITY
		for(OpportunityLineItem b : prodList){

//  MAKE SURE PRODUCTS BELONG TO CURRENT OPPORTUNITY
			if(a.Id == b.OpportunityId){
// DETERMINES PRODUCT TYPE FROM DESCRIPTION AND ADDS PRICE TO THE CORRESPONDING FIELD ON THE CURRENT OPPORTUNITY
		    	     if(b.Description.contains(Prorated)){
		     	     a.Prorated_Total__c += b.TotalPrice;         
		   	     }else if(b.Description.contains (Membership)){        
			     a.Membership_Total__c += b.TotalPrice; 
		    	     }else{
		             a.Monthly_Total__c += b.TotalPrice;   
	    		     }
			}   
		}
	}
}

  After looking up the error, I'm sure the issue is with the nested loop. Everything else I tried failed and I'm struggling.  Any help is appreciated, thanks.

  • January 07, 2013
  • Like
  • 0

Good day! Please help with the preparation of the query. I have to make a custom report based on a standard.
How do I properly create a query to select all Opp on criteria which are shown below?

 

I am writing my first controller test and running into an issue.  The controller is used to drive a custom keystroke in the service console.

 

Here is the controller:

public class ShortcutListenerController {

// Lead id for lead to be closed
    public String selectedObjectId {get; set;} 
    public String closeReason {get; set;}

 // Close Lead
    public PageReference closeLead() {
    	system.debug('The Lead Id is :'+ selectedObjectId);
    	system.debug('The Reason is :'+ closeReason);
        Lead selectedLead = [SELECT id, status, Lead_Status_If_Closed_Specify__c FROM Lead WHERE id =:selectedObjectId LIMIT 1];
        selectedLead.status = 'Closed';
        selectedLead.Lead_Status_If_Closed_Specify__c=closeReason;
        update selectedLead;
        return null;
    }
}

 

 

Here is my test script:

@isTest
public class ShortcutControllerTest {

	ShortcutListenerController controller = new ShortcutListenerController();
	
    public static testMethod void shortcuttest() {
        // create lead
         Lead tl = new Lead(
            LastName = '123456', Company= '654321', Phone='1233213222'); 
        insert tl;  
      system.debug('Lead ID ='+tl.id);
      
      ApexPages.currentPage().getParameters().put('selectedObjectId', tl.id);
      ApexPages.currentPage().getParameters().put('closeReason', 'Test');
      
      PageReference pr = controller.closeLead();
      
      Lead t2 =[SELECT id, status, Lead_Status_If_Closed_Specify__c FROM Lead WHERE id =:tl.id];
      
      system.debug('Close Reason ='+t2.Lead_Status_If_Closed_Specify__c);
      system.debug('Status ='+t2.status);
    }
}

 

Why am I getting the error "Method does not exist of incorrect signature: controller.closeLead();

 

Thanks in advance

Phil

Hi  

 

I am trying to deploy my classes and onjects on Production using the Force.com IDE. All my classes and triggers have code coverage more than 75 % , while running tests in force.com IDE , i found that several other test methods are running which are from other classes. There is no relation with my code. It is dropping my Code coverage percentage. How can i prevent the running the tests from other classes or triggers while deploying the code. Refer to the image below - All classes and trigger with Green symbol should only execute the test cases , rest of them should be removed.

 

Hi all, 

I have a strange problem: I have  map as: 

Public map<Sobject__c,String> calresult{get;set;}

 

which i am initialising in constructor, and when values a inserted into a textbox i am putting them in my map,

But problem is this when i want to display it, I use system.debug() to see the map is filled or not, Its filled but when i am tring to fetch the first map value as: calresult.get(object); it always return null,

1.The value is in the map

2.No values are removed form the map

 

But it always return null .Help!

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

Also i found that the first value is not equal to my object as one field which is numaric with value 12.0 is 12 inside my map, but my map is same type as of the object.?

  • November 06, 2012
  • Like
  • 0

I'm brand new to Apex and I'm working on my first trigger, pasted below. Through manual testing, I know that it works--however, i'm not quite sure how to create test code for it (my attempt is also pasted below). 

 

Any help would be appreciated, and thank you!

 

Trigger code:


trigger SpouseTrigger on Contact (before insert) {
    List<Contact> cons = new List<Contact>();
    List<Contact> consToInsert = new List<Contact>();
    
    for(Contact c:trigger.new){
        if(c.Sig_Other_First_Name__c != null && c.Sig_Other_Last_Name__c != null){
            cons.add(c);
        }
    }
    
    for(Contact c: cons){
        Contact newCon = new Contact();
        newCon.FirstName = c.Sig_Other_First_Name__c;
        newCon.LastName = c.Sig_Other_Last_Name__c;
        newCon.AccountId = c.AccountId;
        consToInsert.add(newCon);
    }
    
    insert consToInsert;
}

This trigger checks to see if two fields (Sig_Other_First_Name and Sig_Other_Last_Name) are filled in, and if they are, creates a new contact record. The contact record uses the First_Name as the First Name and the Last_Name as the last, and puts the contact within the same account as the original contact.

 

 My attempt at a test:

@istest
private class SpouseTriggerTest
{

static TestMethod void Test1_TestInsertContact()
{
Contact testC1 = new Contact(Text(80)='Test1 Contact', Sig_Other_First_Name__c='John', Sig_Other_Last_Name__c='Smith');
insert testC1;

//pull the account info for that contact
Contact SecContact = [SELECT cv__Contact__c FROM Account WHERE Id = :testc1.id];

//verify that the insert updated by creating another contact as in the trigger
System.assertEquals(testC1.account, SecContact.account);

}
}

I know this test is really awful but I don't even know where to start! So again, any help at all would be appreciated. Thank you!!

Hi,

 

*****************************************************************************************************************************************************************************************

Background:

 

I have created a custom object called Invoice, and all my invoices have a master details relation with the Opportunity object.

When an invoices is created i set a trigger to auto attach my pdf to the invoice's opportunity .

I use the same code as i use for my quote (except that for the quote salesman are clicking to attache the pdf) here i need to make it automatic .

 

*****************************************************************************************************************************************************************************************

 

So far it's looks like working except that i'm not able to open my pdf ,i got the following error :

                                                                           

                                                                                 file does not start by '%PDF-' 

 

Here my code :

 

Trigger:

trigger AttachInvoices on Invoice__c (after insert) {

	for(Invoice__c inv : Trigger.new){
		//TestAttachInvoices.savePdf(inv.Id);
		TestAttachInvoices.savePdf(inv);
	}
}

 

 

Class:

 

public class TestAttachInvoices {


	public static void savePdf(Invoice__c inv){
	
		
			 Pagereference pdfPage = Page.InvoiceDeliveryA;
		
		pdfPage.getParameters().put('Id',inv.id);
		
		//the contents of the attachment from my pdf
		Blob pdfBlob;

		try{
			
			pdfBlob = pdfPage.getContent();
			
		}catch(VisualforceException e){
			pdfBlob = Blob.valueOf('error');
		}
		
		Attachment attach = new Attachment(parentId = inv.id, name= inv.Name + '.pdf', body = pdfBlob);
		attach.IsPrivate = false;
		
		try{
			insert attach;
		}
		 catch(DmlException d){
			d.getMessage();
		}
	 
	}

}

 does anyone can help me ? =(

I'm trying to write a trigger on opportunities that when an opportunity is closed, it will update the invoice date field on a custom object. The records are related based on a unique field on the custom object that is in the description field on the opportunity. The field is called Work_order_id_c on the custom object. I don't know how to assign the CloseDate from the mapWOIds map to the vdDocs InvoiceDate using the WorkOrderID. Any help would be appreciated.

 

trigger UpdateVersaDocDocument on Opportunity (after insert, after update) {
	 if (Trigger.isInsert){
	 	map<String, Date> mapWOIds = new map<String, Date>();
	 	set<String> workOrderIds = new Set<String>();
	 	list<VersaDocDocuments__c> vdDocsUpdate = new list<VersaDocDocuments__c>();
		
		// loop through trigger and add WorkOrderID and Invoice date to map 	
        for (Opportunity o : trigger.new){
        	if (o.StageName == 'Closed/Won' && o.Type == 'Customization' && o.Description.startsWith('WorkOrderID:')) {
               	mapWOIds.put(o.Description.substringAfter(': '), o.CloseDate);  
               	workOrderIds.add(o.Description.substringAfter(': '));               	            	
        	}        	
        }
        // create a map a VersaDoc Documents
       map<String, VersaDocDocuments__c> vdDocs = new map<String, VersaDocDocuments__c>([Select Work_Order_ID__c, Id, Invoice_date__c from VersaDocDocuments__c Where Work_Order_ID__c in :workOrderIds]);

        // iterate over the list of versadoc Documents and assign the invoice date
       	for (String vd : vdDocs.keySet()) {
       		System.debug('in for loop vddocs.key is ' + vdDocs.get(vd));
       		vd.Invoice_Date__c = mapWOIds.get(vdDocs.get(vd));
        	// vdDocsUpdate.add(vd);
      		    		     	
        }  
           
	 }
}

 

Hi,

 

Need help with getting the test class to 100% as I'm having trouble with a couple of lines which may help with future testing.

 

1.) Trigger on Opportunity

 

trigger SetAgent on Opportunity (before insert, before update) { 
List<String> accountIds = new List<String>();
List<Account> parentAccounts = new List<Account>();
for(Opportunity oppty : Trigger.new)
{
accountIds.add(oppty.AccountId);
}
 parentAccounts = [Select Id, Agent__c from Account where Id in :accountIds];
    Map<String,Account> accountMap = new Map<String,Account>();
     for(Account a : parentAccounts)
    {
        accountMap.put(a.Id,a);
    }
   for(Opportunity oppty : Trigger.new)
    {
        Account parentAccount = accountMap.get(oppty.AccountId);
        if(parentAccount != null)
        {
            oppty.Agent__c = parentAccount.Agent__c;
        }
    }
}

 2.) Apex Test Class 

 

@isTest
private class SetAgentTest {
    static testMethod void SetAgent() {
        Account a = new Account(Id = '001K000000KnlcE', Agent__c = 'a03K0000001A7v2');        
        Opportunity o = new Opportunity(Name = 'TestOpportunity', StageName = 'Prospecting', CloseDate = system.Today(), Agent__c = a.Agent__c);
        insert o;
        System.assertEquals(a.Agent__c, o.Agent__c);
    }
}

 3.) The 83% result tells me that these two lines from the code above were not tested, a brief explanation of why would be much appreciated.

 

accountMap.put(a.Id,a);

 

oppty.Agent__c = parentAccount.Agent__c;

 Thanks again!

  • October 26, 2012
  • Like
  • 0

Hi all,

 

I have a custom button on Opportunity which calls a VF Page which passes a number of parameters to a apex class. in the class i create a url set various text fiels and redirect the user to another object screen and the fields are pre populated. This works great for text and currency. 

 

The problem i have is Dates it seems that in the url dates are coming out as 2010-10-25. To put text into the url im using:

 

String AccName  = EncodingUtil.urlEncode(opportunity.Account.Name, 'UTF-8');

 

Does anyone know if there's anything similar for Dates?

 

Thanks

I have created a short list for display on our customer Portal Home Page of the last 5 cases updated by support and I want to include a link to the case detail page from this list.  The Controller queries for the only 5 cases, sorted by last updated and returns the Id field in addition to the others.

 

<apex:page controller="CP_Cases_WOC_Controller" sidebar="false" showHeader="false">
    <apex:pageBlock title="5 Most Recently Updated Cases" mode="list">
      <apex:pageBlockTable value="{!cases}" var="c">
        <apex:column value="{!c.CaseNumber}"/>
        <apex:column value="{!c.Status}"/>
        <apex:column value="{!c.Subject}"/>
      </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 I want to have the CaseNumber be a link to the Case Detail page.  How can I do that?

Dear community,

 

********************************************************************************************

Background:

 

I created a visualforce page for my Quote to get it as pdf.

So far it's working but i got an issue with my QuoteLineItems.( design problem)

********************************************************************************************

In my code i used the apex:repeatas you can see below :

 

 <apex:repeat value="{!Quote.QuoteLineItems}" var="line">
                        <tbody id="lineItem">
                           ****Quote Line Items information are displayed here ****
                        </tbody>
                        
</apex:repeat>  

 The problem come from the number of Quote Line Items, if have two or less items it's fine :

(all the informations are fake information from my sandbox)

 

 

 

Between two and five there is a problem for the price summary:

(all the informations are fake information from my sandbox)

 

With 5 items i don't have any problem :

 

and more than 5 my Quote Line item's tab is dirty:

(all the informations are fake information from my sandbox)

 

I'm not very skilled with this kind of design, so my questions are;

 

Should i created different page depend of the number of my quote line items?
Can we make a count on the visualforce page using apex?

I'm kind a lost .

 

Sincerely,

 

 

Hi,

 

my requirement is :

send an email notification to Accout Owner on Agreement Object .

There is two fields : 1.contract End date 

                                     2. 'Notification days' -  In whihc user set  how many days before contract end date he wnat notifications.

 

I go for the workflow ,Time dependent workflow ,but found I was not able to do this by workflow .I have to use Trigger. 

am I correct? is there any way to do this by workflow.

Hi,

I have a visualforce page that has a picklist form element (Billing_Entity__c), when it is onChange I need to assign a custom long text field (Declaration__c) whereby the value is from another Visualforce page (SOF_Declaration) which returns text/plain contentType.
Both pages are using the same standardController and extensions.

Problem: Instead of returning the correct content from SOF_Declaration, it simply return the caller's HTML page. So now the page becomes nested. 
Note: I have tried to run the code in getSOFDeclarationString method succesfully in the dev console; it returned the expected text. 

Here is the visualforce:
 
<apex:actionRegion>
    <apex:selectList value="{!Service_Order__c.Billing_Entity__c}" size="1" id="BillingEntity" 
        onChange="changeBillingEntity()">
        <apex:selectOptions value="{!Entities}"/>
        <apex:actionFunction name="changeBillingEntity" action="{!changeBillingEntity}" 
            reRender="elSOFClause" />
    </apex:selectList>
</apex:actionRegion>

....

<apex:outputPanel layout="block" style="padding-bottom:10px" id="elSOFClause">
    <apex:outputText value="{!SOFDeclaration}" escape="false"/>
</apex:outputPanel>

Controller:
 
private String getSOFDeclarationString() {
  PageReference pr = Page.SOF_Declaration;
  pr.getParameters().put('id', SO.Id);
  return pr.getContent().toString();
}

public PageReference changeBillingEntity() {
  SO.Declaration__c = getSOFDeclarationString();
  return null;
}

public String getSOFDeclaration() {
  if (SO.Declaration__c != null) {
    return SO.Declaration__c.replaceAll('\n *\n', '<br/><br/>');
  }
  return '';
}

I tried to change the PageReference instantiation by hardcoding the URL and record ID as the following, and it was working well (scratching my head....)
PageReference pr = new PageReference('https://c.cs5.visual.force.com/apex/SOF_Declaration?id=a06O000000L9pFMIAZ')
return pr.getContent().toString();
Any idea why is that?
Thanks!

Hi,

 

I am running Summer 13 in my sandbox, but I noticed the apex class/VF editor textarea box is now just a plain textarea, not the usual 'rich text' box.

Anyone having the same issue? Is there any setup to configure this? 

I can't find anywhere.

 

Note: I login to other org which is not yet updated to Summer 13, the editor is fine.

 

Thanks.

Hi,

 

I just uploaded a change set from sandbox to production, and I have received the email stated that the upload was successful.

But when I login to the production, I don't see any change set awaiting for deployment. This had happened a few times lately.

Did anybody face the same issue before?

Any workaround to make to change set appear?

 

Thanks!!

 

-Hengky-

Hi,

 

I am dealing with a lot of change requests to my company org, and sometimes I need to put aside a request and work on a new one because it is top priority. And sometimes the changes are not quickly deployed to production and being hold in sandbox for some reasons. Now there are quite a number of changes in the sandbox and I kind of lose track of which changes are for which request.

How do you guys deal with the similar issue?

 

Thanks!

Hengky

Hi,

 

I have a nested bullet and numbering in a Rich Text Area custom field, something like this:

 

  1. aaa
  2. aaa
    • bbb
    • bbb
  3. aaa
  4. aaa

But if I render the above field as PDF in a VF page using apex:outputText with escape=false. It will display as:

 

  1. aaa
  2. aaa
    1. bbb
    2. bbb
  3. aaa
  4. aaa

The bullets weren't displayed correctly.

Anybody encountered the same issue? Any idea how to solve this?

Thanks!

Hello,

I am retrieving notes which have line breaks in the body.  I have created a custom extension and pageblocktable to display the note data including the body but the line breaks are ignored in the body column of the table, how do I get the column to recognize the line breaks properly?

Thanks!
Hi,

I would like to have all new Opportunities start with a default stage value of Stage 1: Initial Interest. I tried a WF rule but was unsuccessful. (below)

I think the best way to do this is with a trigger but i cannot find how to setup a trigger to insert a default value when the opp is created.

Please Help!!



User-added image



 
I want to create a custom Note list, which has already been done with others help.  Instead of a table layout however I want a list l want more of this format which should use the entire width of the list and scroll....

Bill Woodson
11/14/2014

Body of the note that wraps over and
Over again.
---------------------------------------------------------
Bill Woodson
11/14/2014

Body of the note that wraps over and
Over again.
---------------------------------------------------------
etc...

Has anyone done this or can help me find where to find details on how?

Thanks!

Which field shows the type or name of the object in the items to approve list.

I could not find anything on the ProcessInstanceWorkitem..

 

Thanks

I've been trying to do this by setting the DML options, but it doesn't seem to be working.

 

Stuck as to what I'm doing wrong.

This is the code I'm using:

 

    public PageReference doSave()
    {
        List<sObject> sList=setCon.getSelected();
        List<CaseComment> ccList=new List<CaseComment>();
        for(sObject s:sList)
        {
            s.Put('Status',CaseStatus);
            s.Put('Reason',CaseReason);
            if(!String.isBlank(Comment))
            {
                ccList.Add(new CaseComment(CommentBody=Comment, ParentId=(Id)s.Get('id'), isPublished=PublicComment));
            }
        }
        if(!ccList.isEmpty())
        {
            Database.DMLOptions dmlOpts = new Database.DMLOptions();
            dmlOpts.EmailHeader.triggerAutoResponseEmail = true;
            dmlOpts.EmailHeader.triggerOtherEmail = true;
            database.insert(ccList,dmlOpts);
        }
        return setCon.save();
    }

I did a sandbox refresh today and before I did it, my fields were populating just fine (in the test environment) and now they aren't. All the classes were backed up and now recreated and I can't seem to find anything wrong with the code. The code saves fine, and has 98% coverage. This field population problem requires some triggers, a schedulable class, a batchable class, a test class, and then the Contact_RollupTrades Class itself. If you need these other pieces of code I can provide them. Please have a look at this code and see if you can find anything wrong with it.

 

public class Contact_RollupTrades {
    public Contact[] contactOldList { set; get; }
    public Contact[] contactNewList { set; get; }
    public Contact_Setting__c setting { set; get; }
    
    public Contact_RollupTrades(Contact[] contactOldList, Contact[] contactNewList) {
        this.contactOldList = contactOldList == null ? new Contact[] {} : contactOldList.clone();
        this.contactNewList = contactNewList == null ? new Contact[] {} : contactNewList.clone();
  
        this.setting = Contact_Setting__c.getInstance();
        this.setting = setting == null ? new Contact_Setting__c() : setting;
    }
    
    public void execute() {
        if (setting.Disable_Contact_Rollup__c == true)
            return;
        
        Contact[] contactUpdateableList = new Contact[] {};
        
        for(Contact contactNew : contactNewList) {
            if (contactNew == null || contact.Id == null)
                continue;
            if (contactNew.Rollup_Trades__c != null)
                continue;
            contactUpdateableList.add(contactNew);
        }
        
        execute(contactUpdateableList);
    }
    
    public void execute(Contact[] contactList) {
        if (contactList == null || contactList.size() == 0)
            return;
        
        // Reset contacts
        Map<Id, Contact> contactListMap = new Map<Id, Contact>(contactList);
        
        for(Contact contact : contactList) {
            contact.Total_NIOR_I_Sales__c = 0;
            contact.Total_NIOR_I_Shares__c = 0;
            contact.YTD_NIOR_I_Sales__c = 0;
            contact.YTD_NIOR_I_Shares__c = 0;
            contact.QTD_NIOR_I_Sales__c = 0;
            contact.QTD_NIOR_I_Shares__c = 0;
            contact.MTD_NIOR_I_Sales__c = 0;
            contact.MTD_NIOR_I_Shares__c = 0;
            contact.PY_NIOR_I_Sales__c = 0;
            contact.PY_NIOR_I_Shares__c = 0;
            
            contact.Total_NS_REIT_Sales__c = 0;
            contact.Total_NS_REIT_Shares__c = 0;
            contact.YTD_NS_REIT_Sales__c = 0;
            contact.YTD_NS_REIT_Shares__c = 0;
            contact.QTD_NS_REIT_Sales__c = 0;
            contact.QTD_NS_REIT_Shares__c = 0;
            contact.MTD_NS_REIT_Sales__c = 0;
            contact.MTD_NS_REIT_Shares__c = 0;
            contact.PY_NS_REIT_Sales__c = 0;
            contact.PY_NS_REIT_Shares__c = 0;
            
            contact.Total_NS_HIT_Sales__c = 0;
            contact.Total_NS_HIT_Shares__c = 0;
            contact.YTD_NS_HIT_Sales__c = 0;
            contact.YTD_NS_HIT_Shares__c = 0;
            contact.QTD_NS_HIT_Sales__c = 0;
            contact.QTD_NS_HIT_Shares__c = 0;
            contact.MTD_NS_HIT_Sales__c = 0;
            contact.MTD_NS_HIT_Shares__c = 0;
            contact.PY_NS_HIT_Sales__c = 0;
            contact.PY_NS_HIT_Shares__c = 0;
            
            contact.Rollup_Trades__c = DateTime.now();
        }
        
        // Roll up the trades based on the Resolved Firm Trading ID field
        
        Trades__c[] tradesList = [
            select Dollar_Amount_of_the_transaction__c
                 , Fund_Number__c
                 , Number_of_Shares_of_the_transaction__c
				 , Resolved_Firm_Trading_ID__c
				 , Resolved_Firm_Trading_IDs__c
				 , Resolved_to_Rep_Trading_ID__c
                 , Trade_Date__c
              from Trades__c
             where Resolved_Firm_Trading_IDs__c in :contactList
               and Fund_Number__c in ('3910', '3911', '3912')       // NIOR I; NS REIT; NS HIT
               and Dollar_Amount_of_the_transaction__c != null      // prevents null pointers below
               and Number_of_Shares_of_the_transaction__c != null   // prevents null pointers below
               and Trade_Date__c != null                            // prevents null pointers below
               
               // Negative values are ignored for roll-up purposes
               and Dollar_Amount_of_the_transaction__c >= 0
               and Number_of_Shares_of_the_transaction__c >= 0
        ];
        
        
        // Nothing to do?
        if (tradesList.size() == 0)
            return;
        
        // Update contacts
        for(Trades__c trades : tradesList) {
            Contact account = contactListMap.get(trades.Resolved_Firm_Trading_IDs__c);
            
            if (account == null || trades == null || trades.Trade_Date__c == null)
                continue;
            else if ('3910'.equals(trades.Fund_Number__c))
                processFund_3910(account, trades);
            else if ('3911'.equals(trades.Fund_Number__c))
                processFund_3911(account, trades);
            else if ('3912'.equals(trades.Fund_Number__c))
                processFund_3912(account, trades);
        }
    }
    
    void processFund_3910(Contact contact, Trades__c trades) {
        system.assert(null != contact);
        system.assert(null != trades);
        system.assert(null != trades.Trade_Date__c);
        
        Boolean isYTD = (date.today().year() == trades.Trade_Date__c.year());
        Boolean isMTD = (date.today().month() == trades.Trade_Date__c.month()) && isYTD;
        Boolean isQTD = (((date.today().month() - 1) / 3) + 1) == (((trades.Trade_Date__c.month() - 1) / 3) + 1) && isYTD;
        Boolean isPY = ((date.today().year() - 1) == trades.Trade_Date__c.year());
        Boolean isTotal = true;
        
        // YTD
        if (isYTD) {
            contact.YTD_NIOR_I_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.YTD_NIOR_I_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // QTD
        if (isQTD) {
            contact.QTD_NIOR_I_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.QTD_NIOR_I_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // MTD
        if (isMTD) {
            contact.MTD_NIOR_I_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.MTD_NIOR_I_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // 
        if (isPY) {
            contact.PY_NIOR_I_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.PY_NIOR_I_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // 
        if (isTotal) {
            contact.Total_NIOR_I_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.Total_NIOR_I_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
    }

    void processFund_3911(Contact contact, Trades__c trades) {
        system.assert(null != contact);
        system.assert(null != trades);
        system.assert(null != trades.Trade_Date__c);
        
        Boolean isYTD = (date.today().year() == trades.Trade_Date__c.year());
        Boolean isMTD = (date.today().month() == trades.Trade_Date__c.month()) && isYTD;
        Boolean isQTD = (((date.today().month() - 1) / 3) + 1) == (((trades.Trade_Date__c.month() - 1) / 3) + 1) && isYTD;
        Boolean isPY = ((date.today().year() - 1) == trades.Trade_Date__c.year());
        Boolean isTotal = true;
        
        // YTD
        if (isYTD) {
            contact.YTD_NS_REIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.YTD_NS_REIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // QTD
        if (isQTD) {
            contact.QTD_NS_REIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.QTD_NS_REIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // MTD
        if (isMTD) {
            contact.MTD_NS_REIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.MTD_NS_REIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // 
        if (isPY) {
            contact.PY_NS_REIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.PY_NS_REIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // 
        if (isTotal) {
            contact.Total_NS_REIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.Total_NS_REIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
    }
    
    void processFund_3912(Contact contact, Trades__c trades) {
        system.assert(null != contact);
        system.assert(null != trades);
        system.assert(null != trades.Trade_Date__c);
        
        Boolean isYTD = (date.today().year() == trades.Trade_Date__c.year());
        Boolean isMTD = (date.today().month() == trades.Trade_Date__c.month()) && isYTD;
        Boolean isQTD = (((date.today().month() - 1) / 3) + 1) == (((trades.Trade_Date__c.month() - 1) / 3) + 1) && isYTD;
        Boolean isPY = ((date.today().year() - 1) == trades.Trade_Date__c.year());
        Boolean isTotal = true;
        
        // YTD
        if (isYTD) {
            contact.YTD_NS_HIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.YTD_NS_HIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // QTD
        if (isQTD) {
            contact.QTD_NS_HIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.QTD_NS_HIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // MTD
        if (isMTD) {
            contact.MTD_NS_HIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.MTD_NS_HIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // 
        if (isPY) {
            contact.PY_NS_HIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.PY_NS_HIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
        
        // 
        if (isTotal) {
            contact.Total_NS_HIT_Sales__c += trades.Dollar_Amount_of_the_transaction__c;
            contact.Total_NS_HIT_Shares__c += trades.Number_of_Shares_of_the_transaction__c;
        }
    }
}

 I create a new trade, and it's not populating in the Contact, but it will populate in the National Accounts page which is the source of the code I used for the Contact page.

Hello,

 

         My requirement is display records in visual force page side by side.

 

for example :

 

                      record1                     record2

                        link                              link

 

                      record3                     record4

                        link                              link

 

                       record5                     record6

                        link                              link

 

 

Here link is a command link or output link. How to display records in visual force page?

 

Any one help me?

 

 

 

  • May 27, 2013
  • Like
  • 0

Hello,

 

 

   How to display renderas="pdf" visual force page in A5 size am using like

 

<head>
<style>
@page :first
{
size:landscape;
margin-top:0%;
@top-center
{
content: element(header2);
}
}
@page
{
size:landscape;
margin-top:18%;
}
</style>

</head>

 

Is it correct way to set size in A5 page?

 

Can any one help?

 

 

Thank you

 

 

Hi

I have a scenario

i have to a field on opportunity ,i want populate that value in my account record.

for one account so many opportunitys or there ,so i need to populate distinct values into account object field.

 

ex: i have 1 account ,4 opportunitys

opportunity filed values :

1 a

2 A

3 b

4 B

 

so in the account filed i need to show only  A,B

 

 

How can i do this below is the ,my trigger am populating the values into account filed,but am not able to compare the small and capital letters or the same.

 

trigger Populating_CCY_Pair  on Opportunity (after insert,after update) {
List<opportunity> op=new List<opportunity>();
List<opportunity> opp=new List<opportunity>();
Set<id> accIds = new Set<Id>();
string ccy_pair;
set<string> uniuqvalues=new set<String>();
op=[select id,name,Bought_CCY__c,CCY_Pair__c,Sold_CCY__c,accountid from opportunity where id=:trigger.new];

for(opportunity o:op)
{
if(o.accountid != null)
        {
            accIds.add(o.accountid);
        }
}
Account ac=[select id,name,CCY_Pairs_Traded__c from account where id=:accIds];
opp=[select id,name,Bought_CCY__c,CCY_Pair__c,Sold_CCY__c,accountid  from opportunity where accountid=:accIds];
ccy_pair='';

for(Opportunity o1:opp)
{
if(!uniuqvalues.contains(o1.CCY_Pair__c))
{
uniuqvalues.add(o1.CCY_Pair__c);
ccy_pair=ccy_pair+o1.CCY_Pair__c+';';
system.debug('uniuqvalues of valuews'+ccy_pair);
}
}

ac.CCY_Pairs_Traded__c=ccy_pair.touppercase().trim();

system.debug('account updated fields'+ac.CCY_Pairs_Traded__c);
update ac;
system.debug('account updated records'+ac);

}

 

 

regrads

venkatesh.

 

 

Hi All,

 

How to get current week records using soql query, I want to display this week records Sunday to Saturday created records. Help me please.

 

Thanks

Gopi

 

 

Hi,

 

In my Apex class i am converting leads. When i test my code through UI it is working fine but when i run my test class it get failed and shows this error:

22:21:47.413 (413465000)|FATAL_ERROR|leadconvert.BulkLeadConvert.LeadInUseByWorkflowException: 00Qi0000003QfGrEAK

(System Code)

22:21:47.413 (413480000)|FATAL_ERROR|leadconvert.BulkLeadConvert.LeadInUseByWorkflowException: 00Qi0000003QfGrEAK

(System Code) 22:21:47.414 (414323000)|DML_END|[237] 22:21:47.414 (414406000)|EXCEPTION_THROWN|[237]|System.DmlException: ConvertLead failed. First exception on row 0; first error: RECORD_IN_USE_BY_WORKFLOW, Unable to convert lead that is in use by workflow: []

I am just passing list of leads as parameter into convertlead() in Apex class :

 

List<Database.LeadConvertResult> lcr = Database.convertLead(listOfLeadConvert);

 My test class

@isTest(SeeAllData=true) 
public class Test_CVFC_massConvertwithInputs {
public static testmethod void Test_CVFC_massConvertwithInputs(){
    Account a = new Account (); 
    a.Name = 'LeadCompany';
    insert a;

    Opportunity o = new Opportunity();
    o.AccountId = a.Id;
    o.Name = 'LeadCompany';
    O.StageName = 'Prospecting';
    O.CloseDate = date.today();

    insert o;

    Contact c = new Contact();
    c.AccountId = a.id;
    c.FirstName = 'LeadFirstname';
    c.LastName = 'Leadlastname';
    c.MailingStreet = 'LeadStreet';
    c.MailingCity = 'LeadCity';
    c.MailingState = 'LeadState';
    c.MailingPostalCode = '09877';
    insert c;

    Lead l = new Lead();
    //l.Name = 'LeadName';
    l.Company = 'LeadCompany';
    l.IsUnreadByOwner__c = true;
    l.Description = 'leadDescription';
    //l.Status = 'Closed - Converted';
    l.FirstName = 'LeadFirstname';
    l.LastName ='Leadlastname';
    l.Street = 'LeadStreet';
    l.City = 'LeadCity';
    l.State = 'LeadState';
    l.PostalCode = '09877';
    insert l; 

    List<Lead> leadLst = new List<Lead>();
    leadLst = [SELECT  FirstName, LastName, Street, City, State, PostalCode from Lead where id =: l.Id ];

    /*Database.LeadConvert lc = new Database.LeadConvert();
    lc.setLeadId(l.Id);

    LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
    lc.setConvertedStatus(convertStatus.MasterLabel);*/

    PageReference pageRef = Page.massConvertWithInputs;
    Test.setCurrentPage(pageRef); 
    pageRef.getParameters().put('toconvertLeadIds', l.id); 

    ApexPages.StandardController sc = new ApexPages.standardController(l);  

    CVFC_massConvertwithInputs cmc = new CVFC_massConvertwithInputs(sc);
    system.debug('Wrapper list size '+cmc.wrapperList.size());
    for(Integer i = 0; i < cmc.wrapperList.size(); i++){
        System.debug('Values in Wrapper list ' + cmc.wrapperList[i]);
    }
    //cmc.leadIds = leadLst;
    cmc.convert();

}
}

 is there any thing i am missing out please guide me.

Thanks

Anu

Hello,

 

I have come across an issue I am struggling to solve but not sure how to approach a solution. The issue is as follows:

 

I have a Vf page that mimics the Multi Product page (the one that is used to add products to an Opp). The main difference is that I also give users the option to enter Discount AMount then recalculate the discount percent so when saving to the database SF will calculate the total price. BUT I have come across an issue when entering a discount amount that translates to a discount percent with more than 2 digits of scale (for example: 365-235 will yield 39,16666666666664%, but SF rounds up to 39,17). This causes an issue because when I save the record to the database the auto calculated total price is 364,98 and not 365. This is because when SF rounds up to 39,17 it translates to 235,02 as the amount discounted.

 

Does anyone know how to  work around this issue?

Hi,

 

I am running Summer 13 in my sandbox, but I noticed the apex class/VF editor textarea box is now just a plain textarea, not the usual 'rich text' box.

Anyone having the same issue? Is there any setup to configure this? 

I can't find anywhere.

 

Note: I login to other org which is not yet updated to Summer 13, the editor is fine.

 

Thanks.

Hello Everyone,

 

i have a button called "Generate PDF" on Account Detail page. 

Once we click on the button i want to generate a pdf file and want to insert into an attachments related list.

 

Any suggestions would be helpful.

 

Thanks,

Anil