• Mohammed Azarudeen
  • NEWBIE
  • 19 Points
  • Member since 2015
  • Steadfast Global Technology Services

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 28
    Replies
I just want to align two tables nearby in the output document. This is what I have in the template content source code,
<table style="width:40%;float:left;">
    <tbody>
        <tr>
            <td>First Table</td>
        </tr>
    </tbody>
</table>

<table style="width:40%;float:left;">
    <tbody>
        <tr>
            <td>Second Table</td>
        </tr>
    </tbody>
</table>
This is what I am seeing in the preview of the template content,
User-added imageThis is what rendering in the output document (PDF)
User-added imageI tried Table align:left and align:right for the tables but no luck same result. Can we do the floats in the template content or we have to go to the visualforce page?
After the summer '19 release, we started noticing we have only "cut, copy, paste" right click options inside the chatter new post rich text area. The options for auto correct suggestions gone!. We used to correct the wrongly typed words using the right click auto correct suggestions.

Any comments on this idea? - https://success.salesforce.com/ideaView?id=0873A000000lPEkQAM
If a product has only a list price and contracted pricing for the product and particular account is setup, whenever the user is adding that product to the Quote under that particular account, the contracted pricing is affecting. But this is not happening when the Product price is updating from Price Rule instead of List Price.

So, am confused with the cpq quote price order of execution.

Am I missing anything or it is a bug in Salesforce CPQ?.
Use Case: On Quote Line Editor, I have picklist configuration attribute with the picklist values 1, 2, 3, 4 and 5. When Product1 is selected, the picklist configuration should be filtered and display only 1, 2, 3 and when Product2 is selected, the picklist configuration should display only 4 and 5. This is very similar to parent-child picklist but we don't have parent picklist here instead the parent is Product Name.
Any thoughts?
I'm trying to set up the below product set up in salesforce CPQ.
Product: BAG
Now, I need to set up the price of this particular BAG product based on the Colour in the line editor.
For Ex: If the user selects below configurations in the line editor,
  • Colour - White - $100
  • Colour - Black - $110
  • Colour - Blue - $120
the price should change dynamically for the product BAG.

One way is creating all these combinations as individual products/components and bundle it to choose under BAG. But when there are many combinations, we cannot create all of them as Individual Products/Components.
I've been trying different models in salesforce cpq.
Am trying to achieve the usecase I have in salesforce CPQ.

I want to sum up all the options price and show in the main product while adding into quote.
For ex: 
I have created a Parent Product called  - Desktop Computer with list price of $1.
Now I have added two options under this Desktop Computer with the list price $300 and $400 respectively. So, whenever the sales user is picking up the Main product and selecting the options, the options price should be 0(like Included) and the Desktop Component price should display the sum of all the included options.

Is this possible in salesforce cpq?
 
I have created a lightning component form to insert Contact record which is having Account Name, First Name, Last Name, Email and all the necessary form fields.

I've overridden the Contact object "New" button with this lightning component.

Consider am currently on the Account Detail page, and scrolling down to click on New button of the contact related list. Now, when the lightning component form is loading, the account name from which I redirected should be populated automatically.

This can be easily done in button if the content type is URL. But how do we achieve the same in lightning component content type?

Any ideas would be appreciated. Thanks!.
I just came to know about lightning:tree tag which is a cool tag to represent the role hierarchy.

Am trying to display Account and its related contacts in this lightning:tree structure. Through some examples from salesforce, I can able view tree structure with some hard coded value but it'll be helpful if I can load the dynamic Account and its related Contacts in this lightning:tree view.

Ex from salesforce:
Component
<aura:component>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="items" type="Object"/>
    <lightning:tree items="{! v.items }" header="Roles"/>
</aura:component>
Controller
({
    doInit: function (cmp, event, helper) {
    var items = [{
            "label": "Western Sales Director",
            "name": "1",
            "expanded": true,
            "items": [{
                "label": "Western Sales Manager",
                "name": "2",
                "expanded": true,
                "items" :[{
                    "label": "CA Sales Rep",
                    "name": "3",
                    "expanded": true,
                    "items" : []
                },{
                    "label": "OR Sales Rep",
                    "name": "4",
                    "expanded": true,
                    "items" : []
                }]
            }]
        }];
        cmp.set('v.items', items);
    }     
})

User-added image
 
Here is my usecase,
I need to display case response time for SLA based on Priorities
p1 -> 30 min 
p2 -> 2 hour 
p3 -> 8 hour 
​p4 -> 24 hour


I want to have something like below timer
User-added image
When P1 case arrives, the timer should start decreasing from 30 min. When case owner is changed from Queue to User, the timer should stop wherever it is. If 30 min time is exceeded for p1 case(hits 0), then it should start count in negative untill owner is changed to some user.
Similarly for every other priorities.

NOTE: Entitlement process best suits this usecase but client have to train their support engineers on Entitlement processes. So, asked to go for custom design without entitlement.
Also, when the timer hits 0 it should send an email alert to case to some users.
I want to display the dynamic string date time to current user local date time.

My code sample : 
DateTime currentDate = System.now();
//convert to asset local date time with rawOffset and dstOffset(for this case it is Indian Timezone)
DateTime assetUTCDate = currentDate.addSeconds((integer.valueOf(rmaRawOffset) + integer.valueOf(rmaDstOffset)));
DateTime addDays = assetUTCDate.addDays(1);
//adding days and setting time and assigning to String Field in asset
assetToProcess.assetSLADueDateTime__c = string.valueOf(DateTime.newInstance(addDays.yearGmt(), addDays.monthGmt(), addDays.dayGmt(), 17, 0, 0).format('MM-dd-YYYY HH:mm:ss'));
//Get the string field datetime and convert to user locale datetime
//Consider this is '12-22-2016 17:00:00' a string datetime we got from previous step. If it Indian Standard Time, //I need to show this time to corresponding current user locale time in another asset field.
assetToProcess.SLAInUserLocaleDateTime = ////////user locale datetime from previous date time///////;


for example : 
 
assetToProcess.assetSLADueDateTime__c = '12-22-2016 17:00:00';
//Convert it to user locale. Say if the user is in PST which is 13.30 hours behind Indian time. So I need to show //the user locale field as
assetToProcess.SLAInUserLocaleDateTime = 12/22/2016 3:30 AM;

I have tried wit,
  1. DateTime.newInstanceGMT - but it shows 12/22/2016 9:00 AM. Which is only reducing -8:00 hours of PST GMT and not reducing from Indian GMT which is -5:30
  2. DateTime.newInstance - it shows 12/22/2016 5:00 PM. It is displaying the actual datetime with PST format
  3. DateTime.parse - gives invalid date time error.
  4. DateTime.valueOf 
So, what I need to do to display the datetime in current user locale. 
Any help is appreciable. Thanks.
 
Am keep on hitting "Apex heap size too large" exception.

This is my code,
 
public class assetAfterUpdateFutureCall(){
      @future
       public static void futureMethodName(List<ID> lisOfAssetIDs){
           System.debug('++++ Start of the method - Heap Size+++++ '+Limits.getHeapSize());
          for(Asset assetToProcess : [Select id,Install_Street1__c,Install_Street2__c,                                 Install_City__c, Install_State_Province__c, Install_Zip_Code__c, Install_Country__c  from Asset Where ID = :lisOfAssetIDs]){
                    System.debug('++++ After Querying in loop -  Heap Size+++++ '+Limits.getHeapSize());
           }
       }
}

SOQL query returns 166 rows(we cannot assume this), 

Debug log says, after querying it gets exceeded the total heap size

 
++++ Start of the method - Heap Size+++++ 47549
++++ After Querying in loop -  Heap Size+++++ 20736749
++++ After Querying in loop -  Heap Size+++++ 20736759
++++ After Querying in loop -  Heap Size+++++ 20736769
++++ After Querying in loop -  Heap Size+++++ 20736779
.
.
.
.
.
if we see debug log. When start of the method the heap size is just 47549 but after querying in the loop it gets increased to 20736749

So it is hitting heap size limit exception here. What can I do to reduce the heap size in the query.
Note : All the fields in the query is mandatory to process the record. If I remove any of the field I'll get "SObject was retrieved without querying the requested field" error. 

Any help is appreciable
 
Am trying to calculate remaining response time for the case.

Based on the priority of the case we are setting the remaining time to respond the case(in hours and mins).

Please see http://salesforce.stackexchange.com/questions/153040/case-response-time-calculation-in-formula-field/153046?noredirect=1#comment224405_153046 for scenario description.

Important thing is, we need to show the remaining time dynamically. That is, when the page is refreshed after 10 min, it should change the remaining time dynamically.
So went for the formula field to calculate. Here is my formula,
IF( caseOwnerChanged__c , 

IF(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c )    * 24 * 60) / 60) = 0,
LEFT( TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) ,60)),2 ) &' min',
 (TEXT(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) / 60)) &' hr'& LEFT( TEXT(ABS(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) ,60))),2 ) &' min') ),

 IF(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) / 60) = 0, LEFT( TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) ,60)),2 ) &' min',
 (TEXT(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) / 60)) &' hr '& LEFT( TEXT(ABS(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) ,60))),2 ) &' min') ) )

caseOwnerChanged__c - Checkbox field, which returns true if owner changed. When the case owner changes, response time should stop wherever it is.
ResponseTime__c - formula field which returns 30 for P1, 120 for P2, 480 for P3...
caseOwnerChangedOn__c - Returns datetime when owner changed 

So, am trying to save this formula but am getting
Error: Compiled formula is too big to execute (9,018 characters). Maximum size is 5,000 characters

I tried putting the formula's
  1. (((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60)
  2. TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60)
in seperate formula fields and referenced in the current main formula but it is reducing only less number of characters.
So, Any other way to simplify this formula?. 
In the console view I have added visualforce page to show related RMAs for the current case in the right side bar of the console. I am allowing users to click on RMA link and opening the link in subtab of the current case. Am using the openSubtab javascript method and calling it in RMA link.
<script type="text/javascript">
        var globalRMAID = '';
        function testOpenSubtab(RMAId) {
            globalRMAID = RMAId;
            //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        }
        var openSubtab = function openSubtab(result) {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var rmaurl = document.getElementById("rmaID").href;
            rmaurl = rmaurl+globalRMAID;
            var primaryTabId = result.id;
            sforce.console.openSubtab(primaryTabId , rmaurl, true, 
                'RMA', null, null, 'salesforceSubtab');
        };
    </script>

<apex:repeat value="{!listOfRMA}" var="RMAs">
<tr class="spaceUnder">
    <td>
         <label class="labelCol">RMA Number</label><br/>
         <a href="{!$Site.Prefix}/" id="rmaID" onClick="testOpenSubtab('{!RMAs.id}');return false;" style="text-decoration: none;"><apex:outputText id="rmaName" value="{!RMAs.Name}"/></a>
    </td>
</tr>
</apex:repeat>

If there is only one RMA is associated with case then if user clicks on it, it is opening well in subtab. But if I have another RMA below then when user clicks on it, it is ovverriding the already opened rma and showing on the same previous subtab.

User-added image
My scenario : I am having custom object called Module__c, where users can able to type module names/name in a multiline textbox and that module should be assigned to users/user(standard user object users).

for example :                  Module Name                                                                User
                                     Account Management                                                 
                                                                                                                        Username
                                     Asset Management

for the above example both Account and Asset management Modules this username is assigned( Many To One i.e, N : 1). Likewise for single Module Many users can assign. How can I achieve this functionalities. Any link, suggestions, idea, code snippet is helpful.

Thanks
My Scenario : I am doing with custom object. Object name is Test_Case__c and it has lookup to Module__c object. Module__c object contains one Long Text Area field called Components__c where users can enter texts by separate lines. So on new record creation of Test_case__c when Module__c is selected then the Components__c from Module__c should load into one of the picklist field called Solution_Component__c in Test_case__c. 
  1. Is this possible without writing vfp and controller?.
  2. If it is possible by writing vfp and controller what is the way i need to go?
  3. If it is not possible without writing vfp and controller, how could I get ID of the selected Module__c in Test_case__c creation(because need to capture the ID when it is selected from lookup popup)
Scenario: Am having Invoice__c Object. On the list view I have download button to download the selected invoices PDF's. What my below code is doing is it is after fetching the selected records id's of the PDF it is saving to notes and attachments and then downloading from there. Now I don't want to save to notes and attachments before downloading. I want to save in the program itself using some variables or anything. How can I do this.
Below link has full codes and description

http://salesforce.stackexchange.com/questions/104004/download-invoice-pdfs-on-list-view-without-saving-to-notes-and-attachment-as-a

Any help is appreciable. Thanks!
My custom object name is Patient__c
On the List View I have Download button to download the PDF(VFP rendered as PDF)
Here, before downloading am adding the pdf to notes and attachments and then downloading.
Now I dont want to store to notes and attachments and it should store programatically(like storing to variable) and should download from there.
How to achieve this.
Any help is appreciable thanks!!
Code :
global class DownloadPatient 
{
 // Receive Attachments info from Attachment ParentId
   private static String API_STATUS_NORMAL = '200';
 
   webService static string getAttachmentByParentId(string sfdcId)
    {
         
         List<id> ids = new List<id>();
         if(string.isempty(sfdcId))  {
            return DownloadPatientResponse.errorJson('Parameter sfdcId is required.');
        }
        system.debug('SFDCid'+sfdcId);
        string[] idsArray = sfdcId.split(',');
        for(integer i=0; i<idsArray.size();i++)
        {
           ids.add(idsArray[i]);
        }
        
        // Added this code to restrict batch download for some of the accounts who all are having uncheck for this field  Print_Patient__c
        List<Patient__c> invList = New List<Patient__c>();
        invList = [Select id, name, Print_Patient__c, Account__r.name from Patient__c where ID IN: ids];
        List<Attachment> attInsert = new List<Attachment>();
        if(invList.size() > 0){
            System.debug(' ====> invList size <==== ');
            for(Patient__c invc : invList){
                System.debug(' ====> Patient is : <==== ' + invc);
                String msg = 'Selected invoices are not eligible for Patient Printing, please check the Account '+invc.Account__r.name;
                if(invc.Print_Patient__c == false){
                    System.debug(' ====> invc.Print_Patient__c value false <==== ');
                    return DownloadPatientResponse.errorJson( msg );
                }
                
                PageReference pdf = new PageReference('/apex/PatienDetails?id='+invc.id);
                Attachment attach = new Attachment();
                if (attach == null) attach = new Attachment();
                Blob body;
                try {
                    if(Test.IsRunningTest()){
                        System.debug(' ==> as Test Class <== ');
                        body = Blob.valueOf('Some Text');
                    }
                    else{
                        System.debug(' ==> as Apex normal Class <== ');
                        body = pdf.getContentAsPDF();   
                    }
                 } 
                catch (VisualforceException e) {
                    String msg2 = e.getMessage();
                    return DownloadPatientResponse.errorJson( msg2 );
                 }
                attach.Body = body;
                attach.name= invc.name +'_Patient_'+ Datetime.Now() +'.PDF';
                attach.IsPrivate = false;
                attach.ParentId = invc.id;
                attach.contentType = 'application/pdf';
                attInsert.add(attach);
            }            
        }
        
        Insert attInsert;
                             
        integer totalSizeOfFiles=0;
        integer totalSizeAnPatient=0;
        String invoiceId='';
        set<String> remainingsIdsSet=new set<String>();
        List<attachment> attachmentList = new List<attachment>();
          //for(attachment att:[select ParentId,id,Name,Body,contenttype from attachment where ParentId IN:ids]) {
          for(attachment att: attInsert) {          
                integer eachFileSize=att.Body.size();
                String parentId=att.ParentId;
                att.contenttype='application/pdf';
                if(!invoiceId.equals(parentId)){
                    invoiceId=parentId;
                    totalSizeAnPatient=eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalPatientSize: '+totalSizeAnPatient);
                }else if(invoiceId.equals(parentId)){
                    totalSizeAnPatient=totalSizeAnPatient+eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalPatientSize: '+totalSizeAnPatient);
                }
                if(eachFileSize<4500000 && totalSizeAnPatient<4500000){
                    totalSizeOfFiles=totalSizeOfFiles+eachFileSize;
                    System.debug('--ID: '+parentId+'. FileSize: '+eachFileSize+'. TotalFileSize: '+totalSizeOfFiles+'. HeapSize: '+Limits.getHeapSize());
                    if(totalSizeOfFiles>= 4500000){
                          System.debug('--Adding to RemIDs ID: '+parentId+'. FileSize: '+eachFileSize);
                          remainingsIdsSet.add(parentId);
                     }else{
                          attachmentList.add(att);                      
                     }
                 }
             }
             String remainingIds=null;
             List<String> remainingIdList=new List<String>(remainingsIdsSet);
             for(integer i=0;i<remainingIdList.size();i++){
                 if(i==0){
                     remainingIds=remainingIdList.get(i);
                 }else{
                     remainingIds=remainingIds+','+remainingIdList.get(i);
                  }                 
             }
             
             List<Object> dataList = new List<Object>();
             for(Attachment at :attachmentList)
             {
                Map<String, String> atMap = new Map<String, String>();
                atMap.put( 'Name', at.Name );
                atMap.put( 'Body', EncodingUtil.base64Encode( at.body ));
                datalist.add( atMap );
             
             }
               
                 Map<String, Object> response = new Map<String, Object>();
                 response.put('status', API_STATUS_NORMAL);
                 if( datalist != null ){
                     response.put('data',datalist);
                     response.put('id', remainingIds);
                 }
                 return json.serialize( response );
                                
     
     }
     
        
                
         // Save Zip file to Document
   webService static String saveToDocument( String zipFileData, String fileName ){
       try{
            String userId = UserInfo.getUserId();
            List<Document> docList = [SELECT Id, Name, FolderId, Body FROM Document WHERE Name = :fileName AND FolderId = :userId];
            Document doc = new Document();
            if( docList == null || docList.size() == 0 ) {
                doc.Name = fileName;
                doc.FolderId = UserInfo.getUserId();
                doc.Body = EncodingUtil.base64Decode( zipFileData );
                System.debug(' Insert Doc @@@@ ' + doc);
                insert doc;
               } 
            else {
                doc = docList.get(0);
                doc.Body = EncodingUtil.base64Decode( zipFileData );
                update doc;
            }
            System.debug('--ZipFileName: '+fileName+'. DocId: '+doc.Id);
            return DownloadPatientResponse.normalJson( doc.Id );
        } catch ( Exception ex ) {
            return DownloadPatientResponse.errorJson( ex.getMessage() );
        }
    }
    
}

 
Scenario : In the ListView of Invoice Download button is placed. This will Download the Invoice PDFif the invoice has notes and attachments else notes and attachments is null for the invoice then it will download another PDF which has some contents of the invoice.
Problem : I can able to download the corresponding PDF for single invoice selection on the List View. If I select Records(Multiple selection) with notes and attachments and without notes and attachments then it is downloading the INVOICE PDF only for both record.

Below is my Code
 
global class DownloadInvoice 
{

   private static String API_STATUS_NORMAL = '200';

   webService static string getAttachmentByParentId(string sfdcId)
    {

         List<id> ids = new List<id>();
         if(string.isempty(sfdcId))  {
            return DownloadInvoiceResponse.errorJson('Parameter sfdcId is required.');
        }
        system.debug('SFDCid'+sfdcId);
        string[] idsArray = sfdcId.split(',');
        for(integer i=0; i<idsArray.size();i++)
        {
           ids.add(idsArray[i]);
        }


        List<Invoice__c> invList = New List<Invoice__c>();
        invList = [Select id, name, Print_Invoice__c,Account__r.name from Invoice__c where ID IN: ids];

        List<Attachment> attInsert = new List<Attachment>();

        if(invList.size() > 0){

            for(Invoice__c invc : invList){

                String msg = 'Selected invoices are not eligible for Invoice Printing, please check the Account '+invc.Account__r.name;
                if(invc.Print_Invoice__c == false){

                    return DownloadInvoiceResponse.errorJson( msg );
                }
                Blob body;

       ****From here taking Attachment and adding the condition****

                Integer WithAttachCount = [SELECT count() FROM Attachment where ParentId IN:ids AND id !=null];

                if (WithAttachCount > 0){

                        PageReference pdf = new PageReference('/apex/InvoicePDF?id='+invc.id);

                        try {
                            if(Test.IsRunningTest()){
                                System.debug(' ==> as Test Class <== ');
                                body = Blob.valueOf('Some Text');
                            }
                            else{
                                System.debug(' ==> as Apex normal Class <== ');
                                body = pdf.getContentAsPDF(); 
                                Attachment attach = new Attachment(); 
                                attach.Body = body;
                                attach.name= invc.name +'_Invoice_'+ Datetime.Now() +'.PDF';
                                attach.IsPrivate = false;
                                attach.ParentId = invc.id;
                                attach.contentType = 'application/pdf';
                                attInsert.add(attach); 
                           }
                         } 
                        catch (VisualforceException e) {
                                String msg2 = e.getMessage();
                                return DownloadInvoiceResponse.errorJson( msg2 );
                           }

                        }

                 if(WithAttachCount <= 0 || WithAttachCount == null){

                        PageReference pdff = new PageReference('/apex/InvoicesIfAttachIsNull?id='+invc.id); 
                        try {
                             if(Test.IsRunningTest()){
                             body = Blob.valueOf('Some Text');
                            }
                        else{
                            System.debug(' ==> as Apex normal Class <== ');
                            body = pdff.getContentAsPDF();
                            Attachment attach = new Attachment(); 
                            attach.Body = body;
                            attach.name= invc.name +'_Invoice_'+ Datetime.Now() +'.PDF';
                            attach.IsPrivate = false;
                            attach.ParentId = invc.id;
                            attach.contentType = 'application/pdf';
                            attInsert.add(attach);   
                            }
                         } 
                        catch (VisualforceException e) {
                            String msg2 = e.getMessage();
                            return DownloadInvoiceResponse.errorJson( msg2 );
                           }
                       }                               
                    }       
                }    

        Insert attInsert;

        integer totalSizeOfFiles=0;
        integer totalSizeAnInvoice=0;
        String invoiceId='';
        set<String> remainingsIdsSet=new set<String>();
        List<attachment> attachmentList = new List<attachment>();
          //for(attachment att:[select ParentId,id,Name,Body,contenttype from attachment where ParentId IN:ids]) {
          for(attachment att: attInsert) {          
                integer eachFileSize=att.Body.size();
                String parentId=att.ParentId;
                att.contenttype='application/pdf';
                if(!invoiceId.equals(parentId)){
                    invoiceId=parentId;
                    totalSizeAnInvoice=eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalInvoiceSize: '+totalSizeAnInvoice);
                }else if(invoiceId.equals(parentId)){
                    totalSizeAnInvoice=totalSizeAnInvoice+eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalInvoiceSize: '+totalSizeAnInvoice);
                }
                if(eachFileSize<4500000 && totalSizeAnInvoice<4500000){
                    totalSizeOfFiles=totalSizeOfFiles+eachFileSize;
                    System.debug('--ID: '+parentId+'. FileSize: '+eachFileSize+'. TotalFileSize: '+totalSizeOfFiles+'. HeapSize: '+Limits.getHeapSize());
                    if(totalSizeOfFiles>= 4500000){
                          System.debug('--Adding to RemIDs ID: '+parentId+'. FileSize: '+eachFileSize);
                          remainingsIdsSet.add(parentId);
                     }else{
                          attachmentList.add(att);                      
                     }
                 }
           }
             String remainingIds=null;
             List<String> remainingIdList=new List<String>(remainingsIdsSet);
             for(integer i=0;i<remainingIdList.size();i++){
                 if(i==0){
                     remainingIds=remainingIdList.get(i);
                 }else{
                     remainingIds=remainingIds+','+remainingIdList.get(i);
                  }                 
             }

             List<Object> dataList = new List<Object>();
             for(Attachment at :attachmentList)
             {
                Map<String, String> atMap = new Map<String, String>();
                atMap.put( 'Name', at.Name );
                atMap.put( 'Body', EncodingUtil.base64Encode( at.body ));
                datalist.add( atMap );

             }

                 Map<String, Object> response = new Map<String, Object>();
                 response.put('status', API_STATUS_NORMAL);
                 if( datalist != null ){
                     response.put('data',datalist);
                     response.put('id', remainingIds);
                 }
                 return json.serialize( response );
          }                      

     }
}

How to deal with multiple selection of records with notes and attachments and without notes and attachments. Any help is appreciable. Thanks
I have Custom Object called Patient__c and 2 vfp pages rendered as PDF.

It has the Notes and Attachments.

If Notes and Attachments is not null for the record then it should download the first VFP page.

If Notes and Attachments is null for the record then it should download the second VFP page.

My full Code is below
List<Attachment> attInsert = new List<Attachment>();
        Blob body;

                Integer attachmentCount = [SELECT count() FROM Attachment where ParentId IN:ids];

                if (attachmentCount > 0 ){

                        PageReference pdf = new PageReference('/apex/PatienDetails?id='+invc.id);
                        body = pdf.getContentAsPDF(); 
                        Attachment attach = new Attachment(); 
                        attach.Body = body;
                        attach.name= invc.name +'_Invoice_'+ Datetime.Now() +'.PDF';
                        attach.IsPrivate = false;
                        attach.ParentId = invc.id;
                        attach.contentType = 'application/pdf';
                        attInsert.add(attach);  
                 }

                else if(attachmentCount <= 0){

                    PageReference pdff = new PageReference('/apex/PatientsIfAttachIsNull?id='+invc.id); 
                    body = pdff.getContentAsPDF();
                    Attachment attach = new Attachment(); 
                        attach.Body = body;
                        attach.name= invc.name +'_Invoice_'+ Datetime.Now() +'.PDF';
                        attach.IsPrivate = false;
                        attach.ParentId = invc.id;
                        attach.contentType = 'application/pdf';
                        attInsert.add(attach);            

                 }

        Insert attInsert;
Problem: On the List view If i click seperately and click on download it is downloading their corresponding VFP(attachment count is > 0 downloading firstVFP and attachment count is < 0 downloading secondVFP) as PDF But If I Click Multiple Record(records with attachments and without attachments) and tried to download it is downloading only the firstVFP(PatienDetails).

Multiple Selection
How can I download their corresponding VFP if multiple records selected.
I have one static resource zip file, which has N number of Images. So I don't know the exact number of images are present in zip file.
I just want loop through all the images in zip file. How can I achieve this?. Any help is appreciable.
My VFP page is,

        
<apex:page Controller="repeatCon">
<body style="font-size:10pt; font-family:sans-serif">
        <table>
            <td style="font-family:'Segoe UI', Tahoma, sans-serif;">
                <apex:repeat value="{!imageList}" var="img">
                    <td><apex:image url="{!URLFOR($Resource.MinionsDemo,img)}" height="200" width="200" /><br/></td>
                </apex:repeat>
            </td>
        </table>
    </body>
</apex:page>

and my controller class is,
 
public class repeatCon {
    public List<string> getimageList(){
        List<String> imgstr = new List<String>();
        for(integer i = 1; i <= zipfileimagesize; i++){
            imgstr.add('Minion/'+i+'.jpg');
        }
    return imgstr;
    }
}
in the loop how do I give the size of images present in zip file
 
Hi. I am getting more and more strong by reading forums and practising. Here I have a problem. I have two objects one is Department and another one is Medical_Equipment. Department object is Master for Medical_Equipment. Medical_Equipment has Amount__c field. Am rendering page by pdf format. In controller, I want to calculate total amount for items(medical equipment)

Here is my controller.
public class Medical_Equipment_ControllerCls {

    public decimal totalAmount {get;set;}
    public decimal temp = 0;
    set<id> getid = new set<id>();
    public Medical_Equipment_ControllerCls(ApexPages.StandardController controller)
    {       
        Medical_Equipment__c med = new Medical_Equipment__c();
        for(Medical_Equipment__c medical : [select name, Amount__c,Equipment_for_Department__c from Medical_Equipment__c])
        {
            getid.add(medical.Equipment_for_Department__c);  
            
        }
        List<Medical_Equipment__c> lstmedical = [select Amount__c from Medical_Equipment__c where id in : getid and Amount__c !=null];
        for(Medical_Equipment__c medicalequp : lstmedical)
           {
                temp = temp + medicalequp.Amount__c;  
                totalAmount = temp;
           }
        
    }
}

It is showing nothing for Total Amount
User-added image

I think the problem on getting Departmennt id for particular medical equipment(parent id -> child)
Any discussion and ans is welcome !!!
Am keep on hitting "Apex heap size too large" exception.

This is my code,
 
public class assetAfterUpdateFutureCall(){
      @future
       public static void futureMethodName(List<ID> lisOfAssetIDs){
           System.debug('++++ Start of the method - Heap Size+++++ '+Limits.getHeapSize());
          for(Asset assetToProcess : [Select id,Install_Street1__c,Install_Street2__c,                                 Install_City__c, Install_State_Province__c, Install_Zip_Code__c, Install_Country__c  from Asset Where ID = :lisOfAssetIDs]){
                    System.debug('++++ After Querying in loop -  Heap Size+++++ '+Limits.getHeapSize());
           }
       }
}

SOQL query returns 166 rows(we cannot assume this), 

Debug log says, after querying it gets exceeded the total heap size

 
++++ Start of the method - Heap Size+++++ 47549
++++ After Querying in loop -  Heap Size+++++ 20736749
++++ After Querying in loop -  Heap Size+++++ 20736759
++++ After Querying in loop -  Heap Size+++++ 20736769
++++ After Querying in loop -  Heap Size+++++ 20736779
.
.
.
.
.
if we see debug log. When start of the method the heap size is just 47549 but after querying in the loop it gets increased to 20736749

So it is hitting heap size limit exception here. What can I do to reduce the heap size in the query.
Note : All the fields in the query is mandatory to process the record. If I remove any of the field I'll get "SObject was retrieved without querying the requested field" error. 

Any help is appreciable
 
Am trying to calculate remaining response time for the case.

Based on the priority of the case we are setting the remaining time to respond the case(in hours and mins).

Please see http://salesforce.stackexchange.com/questions/153040/case-response-time-calculation-in-formula-field/153046?noredirect=1#comment224405_153046 for scenario description.

Important thing is, we need to show the remaining time dynamically. That is, when the page is refreshed after 10 min, it should change the remaining time dynamically.
So went for the formula field to calculate. Here is my formula,
IF( caseOwnerChanged__c , 

IF(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c )    * 24 * 60) / 60) = 0,
LEFT( TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) ,60)),2 ) &' min',
 (TEXT(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) / 60)) &' hr'& LEFT( TEXT(ABS(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60) ,60))),2 ) &' min') ),

 IF(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) / 60) = 0, LEFT( TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) ,60)),2 ) &' min',
 (TEXT(FLOOR((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) / 60)) &' hr '& LEFT( TEXT(ABS(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - NOW() ) * 24 * 60) ,60))),2 ) &' min') ) )

caseOwnerChanged__c - Checkbox field, which returns true if owner changed. When the case owner changes, response time should stop wherever it is.
ResponseTime__c - formula field which returns 30 for P1, 120 for P2, 480 for P3...
caseOwnerChangedOn__c - Returns datetime when owner changed 

So, am trying to save this formula but am getting
Error: Compiled formula is too big to execute (9,018 characters). Maximum size is 5,000 characters

I tried putting the formula's
  1. (((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60)
  2. TEXT(MOD((((CreatedDate + ( ResponseTime__c /1440 )) - caseOwnerChangedOn__c ) * 24 * 60)
in seperate formula fields and referenced in the current main formula but it is reducing only less number of characters.
So, Any other way to simplify this formula?. 
In the console view I have added visualforce page to show related RMAs for the current case in the right side bar of the console. I am allowing users to click on RMA link and opening the link in subtab of the current case. Am using the openSubtab javascript method and calling it in RMA link.
<script type="text/javascript">
        var globalRMAID = '';
        function testOpenSubtab(RMAId) {
            globalRMAID = RMAId;
            //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        }
        var openSubtab = function openSubtab(result) {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var rmaurl = document.getElementById("rmaID").href;
            rmaurl = rmaurl+globalRMAID;
            var primaryTabId = result.id;
            sforce.console.openSubtab(primaryTabId , rmaurl, true, 
                'RMA', null, null, 'salesforceSubtab');
        };
    </script>

<apex:repeat value="{!listOfRMA}" var="RMAs">
<tr class="spaceUnder">
    <td>
         <label class="labelCol">RMA Number</label><br/>
         <a href="{!$Site.Prefix}/" id="rmaID" onClick="testOpenSubtab('{!RMAs.id}');return false;" style="text-decoration: none;"><apex:outputText id="rmaName" value="{!RMAs.Name}"/></a>
    </td>
</tr>
</apex:repeat>

If there is only one RMA is associated with case then if user clicks on it, it is opening well in subtab. But if I have another RMA below then when user clicks on it, it is ovverriding the already opened rma and showing on the same previous subtab.

User-added image
My Scenario : I am doing with custom object. Object name is Test_Case__c and it has lookup to Module__c object. Module__c object contains one Long Text Area field called Components__c where users can enter texts by separate lines. So on new record creation of Test_case__c when Module__c is selected then the Components__c from Module__c should load into one of the picklist field called Solution_Component__c in Test_case__c. 
  1. Is this possible without writing vfp and controller?.
  2. If it is possible by writing vfp and controller what is the way i need to go?
  3. If it is not possible without writing vfp and controller, how could I get ID of the selected Module__c in Test_case__c creation(because need to capture the ID when it is selected from lookup popup)
My custom object name is Patient__c
On the List View I have Download button to download the PDF(VFP rendered as PDF)
Here, before downloading am adding the pdf to notes and attachments and then downloading.
Now I dont want to store to notes and attachments and it should store programatically(like storing to variable) and should download from there.
How to achieve this.
Any help is appreciable thanks!!
Code :
global class DownloadPatient 
{
 // Receive Attachments info from Attachment ParentId
   private static String API_STATUS_NORMAL = '200';
 
   webService static string getAttachmentByParentId(string sfdcId)
    {
         
         List<id> ids = new List<id>();
         if(string.isempty(sfdcId))  {
            return DownloadPatientResponse.errorJson('Parameter sfdcId is required.');
        }
        system.debug('SFDCid'+sfdcId);
        string[] idsArray = sfdcId.split(',');
        for(integer i=0; i<idsArray.size();i++)
        {
           ids.add(idsArray[i]);
        }
        
        // Added this code to restrict batch download for some of the accounts who all are having uncheck for this field  Print_Patient__c
        List<Patient__c> invList = New List<Patient__c>();
        invList = [Select id, name, Print_Patient__c, Account__r.name from Patient__c where ID IN: ids];
        List<Attachment> attInsert = new List<Attachment>();
        if(invList.size() > 0){
            System.debug(' ====> invList size <==== ');
            for(Patient__c invc : invList){
                System.debug(' ====> Patient is : <==== ' + invc);
                String msg = 'Selected invoices are not eligible for Patient Printing, please check the Account '+invc.Account__r.name;
                if(invc.Print_Patient__c == false){
                    System.debug(' ====> invc.Print_Patient__c value false <==== ');
                    return DownloadPatientResponse.errorJson( msg );
                }
                
                PageReference pdf = new PageReference('/apex/PatienDetails?id='+invc.id);
                Attachment attach = new Attachment();
                if (attach == null) attach = new Attachment();
                Blob body;
                try {
                    if(Test.IsRunningTest()){
                        System.debug(' ==> as Test Class <== ');
                        body = Blob.valueOf('Some Text');
                    }
                    else{
                        System.debug(' ==> as Apex normal Class <== ');
                        body = pdf.getContentAsPDF();   
                    }
                 } 
                catch (VisualforceException e) {
                    String msg2 = e.getMessage();
                    return DownloadPatientResponse.errorJson( msg2 );
                 }
                attach.Body = body;
                attach.name= invc.name +'_Patient_'+ Datetime.Now() +'.PDF';
                attach.IsPrivate = false;
                attach.ParentId = invc.id;
                attach.contentType = 'application/pdf';
                attInsert.add(attach);
            }            
        }
        
        Insert attInsert;
                             
        integer totalSizeOfFiles=0;
        integer totalSizeAnPatient=0;
        String invoiceId='';
        set<String> remainingsIdsSet=new set<String>();
        List<attachment> attachmentList = new List<attachment>();
          //for(attachment att:[select ParentId,id,Name,Body,contenttype from attachment where ParentId IN:ids]) {
          for(attachment att: attInsert) {          
                integer eachFileSize=att.Body.size();
                String parentId=att.ParentId;
                att.contenttype='application/pdf';
                if(!invoiceId.equals(parentId)){
                    invoiceId=parentId;
                    totalSizeAnPatient=eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalPatientSize: '+totalSizeAnPatient);
                }else if(invoiceId.equals(parentId)){
                    totalSizeAnPatient=totalSizeAnPatient+eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalPatientSize: '+totalSizeAnPatient);
                }
                if(eachFileSize<4500000 && totalSizeAnPatient<4500000){
                    totalSizeOfFiles=totalSizeOfFiles+eachFileSize;
                    System.debug('--ID: '+parentId+'. FileSize: '+eachFileSize+'. TotalFileSize: '+totalSizeOfFiles+'. HeapSize: '+Limits.getHeapSize());
                    if(totalSizeOfFiles>= 4500000){
                          System.debug('--Adding to RemIDs ID: '+parentId+'. FileSize: '+eachFileSize);
                          remainingsIdsSet.add(parentId);
                     }else{
                          attachmentList.add(att);                      
                     }
                 }
             }
             String remainingIds=null;
             List<String> remainingIdList=new List<String>(remainingsIdsSet);
             for(integer i=0;i<remainingIdList.size();i++){
                 if(i==0){
                     remainingIds=remainingIdList.get(i);
                 }else{
                     remainingIds=remainingIds+','+remainingIdList.get(i);
                  }                 
             }
             
             List<Object> dataList = new List<Object>();
             for(Attachment at :attachmentList)
             {
                Map<String, String> atMap = new Map<String, String>();
                atMap.put( 'Name', at.Name );
                atMap.put( 'Body', EncodingUtil.base64Encode( at.body ));
                datalist.add( atMap );
             
             }
               
                 Map<String, Object> response = new Map<String, Object>();
                 response.put('status', API_STATUS_NORMAL);
                 if( datalist != null ){
                     response.put('data',datalist);
                     response.put('id', remainingIds);
                 }
                 return json.serialize( response );
                                
     
     }
     
        
                
         // Save Zip file to Document
   webService static String saveToDocument( String zipFileData, String fileName ){
       try{
            String userId = UserInfo.getUserId();
            List<Document> docList = [SELECT Id, Name, FolderId, Body FROM Document WHERE Name = :fileName AND FolderId = :userId];
            Document doc = new Document();
            if( docList == null || docList.size() == 0 ) {
                doc.Name = fileName;
                doc.FolderId = UserInfo.getUserId();
                doc.Body = EncodingUtil.base64Decode( zipFileData );
                System.debug(' Insert Doc @@@@ ' + doc);
                insert doc;
               } 
            else {
                doc = docList.get(0);
                doc.Body = EncodingUtil.base64Decode( zipFileData );
                update doc;
            }
            System.debug('--ZipFileName: '+fileName+'. DocId: '+doc.Id);
            return DownloadPatientResponse.normalJson( doc.Id );
        } catch ( Exception ex ) {
            return DownloadPatientResponse.errorJson( ex.getMessage() );
        }
    }
    
}

 
Scenario : In the ListView of Invoice Download button is placed. This will Download the Invoice PDFif the invoice has notes and attachments else notes and attachments is null for the invoice then it will download another PDF which has some contents of the invoice.
Problem : I can able to download the corresponding PDF for single invoice selection on the List View. If I select Records(Multiple selection) with notes and attachments and without notes and attachments then it is downloading the INVOICE PDF only for both record.

Below is my Code
 
global class DownloadInvoice 
{

   private static String API_STATUS_NORMAL = '200';

   webService static string getAttachmentByParentId(string sfdcId)
    {

         List<id> ids = new List<id>();
         if(string.isempty(sfdcId))  {
            return DownloadInvoiceResponse.errorJson('Parameter sfdcId is required.');
        }
        system.debug('SFDCid'+sfdcId);
        string[] idsArray = sfdcId.split(',');
        for(integer i=0; i<idsArray.size();i++)
        {
           ids.add(idsArray[i]);
        }


        List<Invoice__c> invList = New List<Invoice__c>();
        invList = [Select id, name, Print_Invoice__c,Account__r.name from Invoice__c where ID IN: ids];

        List<Attachment> attInsert = new List<Attachment>();

        if(invList.size() > 0){

            for(Invoice__c invc : invList){

                String msg = 'Selected invoices are not eligible for Invoice Printing, please check the Account '+invc.Account__r.name;
                if(invc.Print_Invoice__c == false){

                    return DownloadInvoiceResponse.errorJson( msg );
                }
                Blob body;

       ****From here taking Attachment and adding the condition****

                Integer WithAttachCount = [SELECT count() FROM Attachment where ParentId IN:ids AND id !=null];

                if (WithAttachCount > 0){

                        PageReference pdf = new PageReference('/apex/InvoicePDF?id='+invc.id);

                        try {
                            if(Test.IsRunningTest()){
                                System.debug(' ==> as Test Class <== ');
                                body = Blob.valueOf('Some Text');
                            }
                            else{
                                System.debug(' ==> as Apex normal Class <== ');
                                body = pdf.getContentAsPDF(); 
                                Attachment attach = new Attachment(); 
                                attach.Body = body;
                                attach.name= invc.name +'_Invoice_'+ Datetime.Now() +'.PDF';
                                attach.IsPrivate = false;
                                attach.ParentId = invc.id;
                                attach.contentType = 'application/pdf';
                                attInsert.add(attach); 
                           }
                         } 
                        catch (VisualforceException e) {
                                String msg2 = e.getMessage();
                                return DownloadInvoiceResponse.errorJson( msg2 );
                           }

                        }

                 if(WithAttachCount <= 0 || WithAttachCount == null){

                        PageReference pdff = new PageReference('/apex/InvoicesIfAttachIsNull?id='+invc.id); 
                        try {
                             if(Test.IsRunningTest()){
                             body = Blob.valueOf('Some Text');
                            }
                        else{
                            System.debug(' ==> as Apex normal Class <== ');
                            body = pdff.getContentAsPDF();
                            Attachment attach = new Attachment(); 
                            attach.Body = body;
                            attach.name= invc.name +'_Invoice_'+ Datetime.Now() +'.PDF';
                            attach.IsPrivate = false;
                            attach.ParentId = invc.id;
                            attach.contentType = 'application/pdf';
                            attInsert.add(attach);   
                            }
                         } 
                        catch (VisualforceException e) {
                            String msg2 = e.getMessage();
                            return DownloadInvoiceResponse.errorJson( msg2 );
                           }
                       }                               
                    }       
                }    

        Insert attInsert;

        integer totalSizeOfFiles=0;
        integer totalSizeAnInvoice=0;
        String invoiceId='';
        set<String> remainingsIdsSet=new set<String>();
        List<attachment> attachmentList = new List<attachment>();
          //for(attachment att:[select ParentId,id,Name,Body,contenttype from attachment where ParentId IN:ids]) {
          for(attachment att: attInsert) {          
                integer eachFileSize=att.Body.size();
                String parentId=att.ParentId;
                att.contenttype='application/pdf';
                if(!invoiceId.equals(parentId)){
                    invoiceId=parentId;
                    totalSizeAnInvoice=eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalInvoiceSize: '+totalSizeAnInvoice);
                }else if(invoiceId.equals(parentId)){
                    totalSizeAnInvoice=totalSizeAnInvoice+eachFileSize;
                    System.debug('--ID: '+att.id+'. ParentId: '+parentId+'. FileSize: '+eachFileSize+'. TotalInvoiceSize: '+totalSizeAnInvoice);
                }
                if(eachFileSize<4500000 && totalSizeAnInvoice<4500000){
                    totalSizeOfFiles=totalSizeOfFiles+eachFileSize;
                    System.debug('--ID: '+parentId+'. FileSize: '+eachFileSize+'. TotalFileSize: '+totalSizeOfFiles+'. HeapSize: '+Limits.getHeapSize());
                    if(totalSizeOfFiles>= 4500000){
                          System.debug('--Adding to RemIDs ID: '+parentId+'. FileSize: '+eachFileSize);
                          remainingsIdsSet.add(parentId);
                     }else{
                          attachmentList.add(att);                      
                     }
                 }
           }
             String remainingIds=null;
             List<String> remainingIdList=new List<String>(remainingsIdsSet);
             for(integer i=0;i<remainingIdList.size();i++){
                 if(i==0){
                     remainingIds=remainingIdList.get(i);
                 }else{
                     remainingIds=remainingIds+','+remainingIdList.get(i);
                  }                 
             }

             List<Object> dataList = new List<Object>();
             for(Attachment at :attachmentList)
             {
                Map<String, String> atMap = new Map<String, String>();
                atMap.put( 'Name', at.Name );
                atMap.put( 'Body', EncodingUtil.base64Encode( at.body ));
                datalist.add( atMap );

             }

                 Map<String, Object> response = new Map<String, Object>();
                 response.put('status', API_STATUS_NORMAL);
                 if( datalist != null ){
                     response.put('data',datalist);
                     response.put('id', remainingIds);
                 }
                 return json.serialize( response );
          }                      

     }
}

How to deal with multiple selection of records with notes and attachments and without notes and attachments. Any help is appreciable. Thanks
Has anyone else come up with a solution by Trigger for this? I have been trying to figure this out for a few weeks now but to no avail.

for e.g
 
Amount - 200$
Amount in words - Two hundred Dollar only.

I found apex class from this website http://http://salesforcewithkiran.blogspot.in/2013/05/number-to-words-in-apex.html

that works fine for apex class but not for apex trigger.

and I found another site https://sites.google.com/a/forcegenie.com/kb/home/numberstowords/7-ways-to-integrate-with-your-salesforce-org/continouos-conversion-from-number-currency-to-text-using-a-trigger with trigger program to convert but they calling a NumbersToWords apex class but there is no code for that class.

Need a Trigger to convert numbers/currency to words

Anyone have idea about this?

Thanks!
Hi all,

I have a currecy field and needs to convert it into words without clicking any button.
Ex: Amount : Rs.1,10,521
 It should be converted into text as "1 lakh 10 thousand five hundred and twenty 1 Rupees only".

Plese suggest me
Hi all,

I have a currecy field and needs to convert it into words.
Ex: Amount : $ 1,10,521
 It should be converted into text as "1 lakh 10 thousand five hundred and twenty 1 dollars only".

Plese suggest me

Hi Guys/lLadies,

I'm creating a visualforce page and Im using bootstrap to make it fluid. I've successfully linked my VF Page to Bootstrap 3.2.0 (static Resource), everything is working fine except for the CAROUSEL. I've tried every variation of it I could think of. Help?? I think it may be to due the fact that I'm attempting to cycle through  static resources but I could be wrong. Any and All help will be greatly appreciated. Thanks

<apex:page standardStylesheets="false" sidebar="false" showHeader="false" applyHtmlTag="false" applyBodyTag="False">
<HTML>
<BODY>
<div class ="container fluid">
    <div id="homeCarousel" class="carousel slide" data-ride="carousel">
        <div class="carousel-inner">
            <div class="item active">
                <img src="{!URLFOR($Resource.Pkg, 'Pkg/carousel/pic1.jpg')}" alt="First Slide"/>
            </div>
           
            <div class="item">
                <img src="{!URLFOR($Resource.Pkg, 'Pkg/carousel/pic2.jpg')}" alt="Second Slide"/>
            </div>
           
            <div class="item">
                <img src="{!URLFOR($Resource.Pkg, 'Pkg/carousel/pic3.jpg')}" alt="Third Slide"/>
            </div>
        </div>
        <!-- Controls -->
  <a class="left carousel-control" href="#homeCarousel" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="#homeCarousel" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>
</div>
</div>
<script>
        $('#homeCarousel').carousel({ interval: 1200 });
    </script>

<!--BootStrap -->
<apex:includeScript value="{!URLFOR($Resource.Pkg, 'Pkg/bootstrap_js/bootstrap.min.js')}"/>
   <apex:stylesheet value="{!URLFOR($Resource.Pkg, 'Pkg/bootstrap_css/bootstrap.min.css')}"/>
   <!-- Jquery : For Bootstrap Carousel -->
   <apex:includeScript value="{!URLFOR($Resource.Pkg, 'Pkg/jquery/jquery-2.1.1.min.js')}"/>
</BODY>
</apex:page>

hi friends i need code for the slide show in visualforce,  i took images in static resource  those images should get slide show and for that i kept and next and previous button also.

  • November 26, 2013
  • Like
  • 0

I want to make a slideshow of images by embedding javascript in visualforce.

I wrote the following code. It shows the same image even after clicking next button. Can anyone tell me how to fix it? thanks

 

<apex:page showChat="false" sidebar="false" standardController="account">
<apex:pageBlock >
<apex:form >
<center>
<apex:image id="img" value="{!$Resource.one}" width="600" height="400"/>
<br>
</br>

<apex:commandButton value="Next" styleClass="groovybutton" onclick="next();return false;"/>

</center>
</apex:form>
<script>
function next()
{

var img = document.getElementById('img');
img.value= "{!$Resource.two}";

}
</script>
</apex:pageBlock>
</apex:page>

I have two fields named Primarypicture__c and SecondaryPictures__c which was the image urls. PrimaryPicture__c has single image url of data type URL and the SecondaryPictures__c has multiple image url's seperated by semicolon which is Long Text Area data type.

 

Now I want to display both the fileds as image slider in VF page where primarypicture__c should be defalut image and the secondaryPictures__c were to be the next to the primaryPicture__c image in the image slider slide show.

 

Can any one please post your suggestions or any sample code on how I could achieve this.....

I need to have Salesforce automatically send an email to the Primary Contact Role on an opportunity, when the opportunity is created only (not updated), when the created opportunity meets very specific criteria in 4 of its fields.

 

I can get this to work for one-off opps created in the UI with a combination of a trigger and a workflow rule with email alert, BUT, this is not a viable solution, because I'm hitting governor limits when opps are created in bulk.

 

Any code help that a dev can provide would be much appreciated.

 

Here are the requirements for this to work:

 

If:

An opportunity is created

 

And the following criteria are TRUE regarding that opportunity:

  • Opportunity Creator = “Salesforce Leads RT”
  • Opportunity Record Type = “Custom Services”
  • Opportunity field called Service_Type__c  = “Quick Start”
  • Opportunity field called Referring_Group__c = “In-Product Sale”

Then:

Send an email from Salesforce to the Contact Role on that opportunity listed as the Primary Contact on that opportunity

 

Note: the email should be sent using a custom template that is already created and saved in Salesforce with name “Test”.  If this is not possible and there is some other way to send the email subject/body, that is fine, as long as I can modify the subject/body content

How can i convert number to word11

for eg: if i give Input : 1265

                         output: twelve hundred sixty five only.

 

i have tried this in javascript, its working fine , but unable to pass javascript value to custom object field value.

 

<HTML>
 <HEAD>
 <script type = "text/javascript">
function test_skill() {
var junkVal="1000" // 
//var junkVal=document.getElementById('rupees').value;
junkVal=Math.floor(junkVal);
var obStr=new String(junkVal);
numReversed=obStr.split("");
actnumber=numReversed.reverse();
if(Number(junkVal) >=0){
//do nothing
}
else{
alert('wrong Number cannot be converted');
return false;
}
if(Number(junkVal)==0){
document.getElementById('container').innerHTML=obStr+''+'Rupees Zero Only';
return false;
}
if(actnumber.length>9){
alert('Oops!!!! the Number is too big to covertes');
return false;
}
var iWords=["Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine"];
var ePlace=['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'];
var tensPlace=['dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety' ];
var iWordsLength=numReversed.length;
var totalWords="";
var inWords=new Array();
var finalWord="";
j=0;
for(i=0; i<iWordsLength; i++){
switch(i)
{
case 0:
if(actnumber[i]==0 || actnumber[i+1]==1 ) {
inWords[j]='';
}
else {
inWords[j]=iWords[actnumber[i]];
}
inWords[j]=inWords[j]+' Only';
break;
case 1:
tens_complication();
break;
case 2:
if(actnumber[i]==0) {
inWords[j]='';
}
else if(actnumber[i-1]!=0 && actnumber[i-2]!=0) {
inWords[j]=iWords[actnumber[i]]+' Hundred and';
}
else {
inWords[j]=iWords[actnumber[i]]+' Hundred';
}
break;
case 3:
if(actnumber[i]==0 || actnumber[i+1]==1) {
inWords[j]='';
}
else {
inWords[j]=iWords[actnumber[i]];
}
if(actnumber[i+1] != 0 || actnumber[i] > 0){
inWords[j]=inWords[j]+" Thousand";
}
break;
case 4:
tens_complication();
break;
case 5:
if(actnumber[i]==0 || actnumber[i+1]==1) {
inWords[j]='';
}
else {
inWords[j]=iWords[actnumber[i]];
}
if(actnumber[i+1] != 0 || actnumber[i] > 0){
inWords[j]=inWords[j]+" Lakh";
}
break;
case 6:
tens_complication();
break;
case 7:
if(actnumber[i]==0 || actnumber[i+1]==1 ){
inWords[j]='';
}
else {
inWords[j]=iWords[actnumber[i]];
}
inWords[j]=inWords[j]+" Crore";
break;
case 8:
tens_complication();
break;
default:
break;
}
j++;
}
function tens_complication() {
if(actnumber[i]==0) {
inWords[j]='';
}
else if(actnumber[i]==1) {
inWords[j]=ePlace[actnumber[i-1]];
}
else {
inWords[j]=tensPlace[actnumber[i]];
}
}
inWords.reverse();
for(i=0; i<inWords.length; i++) {
finalWord+=inWords[i];
}
document.getElementById('container').innerHTML=finalWord; // we are getting values in to it.
}
 </script>
 </HEAD>
 <BODY onload="test_skill()">
 
<div id="container"></div>
 </BODY>
 
</HTML>
i want that value (document.getElementById('container').innerHTML=finalWord;) in field namely amountinwords__c .

I have an IF statement that needs to read

 

"New monthly rate going forward is $1,000.00"

 

My formula is

 

IF(ISBLANK( Custom_Description__c ),
"" ,
"New monthly rate going forward is" &""& Opportunity__r.Current_Monthly_Revenue__c)

 

but the Opportunity__r field is a currency field and the formula Error says "Incorrect parameter for function &(). Expected Text, received Number

 

Thank you in advance

  • July 12, 2010
  • Like
  • 2
I am trying to figure out how to produce a mail merge template for Microsoft Word that will have a check as a page.  In order to fill out the check properly, I need to figure out how to express a currency field from salesforce.com as written out text. 
 
For example, I want $17.96 to appear in another field as "Seventeen Dollars and Ninety Six Cents"
 
What is the best way to do this?