• Ohadios
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 14
    Replies
A bit of a story…
We are using several AppExchange packages that rely on configuration data to be usable. As an example, FinancialForce has custom objects that store ‘company’ level configurations, such as Companies, Divisions, Currencies, User/Company allocation and more.

Since these records are highly restricted – FinancialForce (FF) restricts users from creating or updating these records via API (i.e. dataloader) and only allows users to create them through the UI. Some of the records are not even available through the UI and can only be created by the implementation team that set the package up initially.

So far this has caused us to perform all development activities that interact in any way with these packages in Full Sandboxes – since we are able to refresh them WITH all of this data (not to mention the extensive use of @seeAllData in test classes, but that’s a story for another day).
As my development team grows, I am looking to establish more consistent and defined practices, including the use of version control tools, and require new features to be developed in a Developer sandbox prior to deployment into the full sandbox for QA and UAT – but I really am not sure how I can achieve this.

I could invest time writing code that would leverage the FF API’s to create many of these records after refresh, but this by itself would be a significant undertaking which I cannot afford to invest time in currently. Further, some of these other packages are less ‘friendly’ when it comes to even providing a way to create these type of records using code at all.

I’m curious if anyone else has found themselves in a similar situation (I can’t be the only one, right?) and if so – what solutions or advice they have to contribute.

Thanks for reading – I hope this ends up with someone who can help!
 
Hi All,

I am using Apex SingleEmailMessage to send out an email message, and utilizing the setOrgWideEmailAddressIdto make sure this e-mail appears coming from a company e-mail and not from a specific user.
If users have a personal signature set up, the signature gets appended to the bottom of the e-mail message.

Does anyone know of a way to force the message to not include the personal signature?

Thanks!

Hi All,

 

I've created a VF page that allows users to select a list of custom objects related to a particular case, update some field information and attach pictures to any of these related objects. When done, the user clicks on an email that generates an email based on a VF Email template. This part works great.

Instead of sending multiple image attachments on this email, I created a VF page that displays all of these images, and was attempting to generate it as a PDF attachment to attach to the case.

When I load the VF page (which has renderAS="PDF"), it looks great and works as expected.

When I call it from my custom controller using the getContent() method, it is sending a file that I am unable to open using Adobe. When I try I receive the error "insufficient data for an image", and even the text on the page does not render (though, oddly,  the table is visible).

I have no clue how to attempt and troubleshoot it, so I will appreciate any help!

 

Here is my controller extendsion part which calls my page:

Messaging.EmailFileAttachment myAttach = new Messaging.EmailFileAttachment();
myAttach.setFilename(This.Cas.CaseNumber+'_Related_Pictures.pdf');
myAttach.setContentType('application/pdf');
PageReference myPdf = Page.IDS_Quote_Pictures_PDF;
mypdf.setRedirect(true);
myPDF.getParameters().put('ID' , this.Cas.ID);
blob b = myPdf.getContentAsPdf();
myAttach.setbody(b);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setWhatID(Cas.ID);
email.setTargetObjectId(toContacts[0].theContact.id);
EmailTemplate templateId = [Select id from EmailTemplate where name = 'IDS RMA Quote Email'];
email.setTemplateID(templateId.Id);
email.setSaveAsActivity(true);
email.setToAddresses(toAddresses);
email.setCCAddresses(ccAddresses);
email.setOrgWideEmailAddressId([SELECT id, displayName FROM OrgWideEmailAddress WHERE DisplayName = 'I.D. Systems RMA Department'].id);
if (myAttach != NULL) {
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {myAttach});
        }

 And here is the custom controller that the actual PDF VF page calls:

 

public class IDS_RMA_Quote_Pictures_Getter{

    // Wrapper class to wrap an attachment with a selection and some related details in text
    public class attachFile {
        public Attachment theFile {get;set;}
        public String belongsTo {get;set;}
    
        public attachFile(Attachment theFile) {
        	this.theFile = theFile;
        }
    }
    
    public final Case cas;
    //private final ID cas;
    private List<attachFile> readyAttachments;
        
    public IDS_RMA_Quote_Pictures_Getter(){
        //this.cas = (case)stdController.getRecord();        
        Cas = [Select ID, Subject, CaseNumber, Type_of_RMA__c, Date_RMA_Received__c FROM Case WHERE ID =: ApexPages.CurrentPage().getParameters().get('id')];
    }
    
    public Case getCas() {
    	return cas;   
    }
    
    
    public List<attachFile> getReadyAttachments() {
        System.debug('Starting Getter');
        List<device__C> deviceList = new List<Device__c>();
        deviceList = [SELECT Name,
                      Part_Number__R.Name,
                      Part_Number__R.Description__c,
                      Problem__c,
                      Visual_Inspection_Notes__c,
                      Quoted_Price__c,
                      Quote_Status__c,
                      Customer_Damage__c,
                      In_Warranty__c
                      FROM Device__c 
                      where Quote_Status__c =: 'Quoting' 
                      AND Case__c =: Cas.ID]; 
        System.debug('Devices: '+deviceList);
        
        List<ID> allDeviceIDs = new List<ID>();
        For (device__c d : deviceList) {
         	allDeviceIDs.add(d.ID);   
        }
        System.Debug('Device IDs: '+allDeviceIDs);
        
        List<Attachment> allAttachments = new List<Attachment>();
        allAttachments = [SELECT ID, Name, ParentID, body, ContentType 
                          FROM Attachment 
                          WHERE name != : 'Device_QR_Code.png'
                          AND ContentType LIKE 'image/%'
                          AND (ParentID IN : allDeviceIDs
                                 OR ParentID = : cas.ID)
                         Order by ID desc];
        System.debug('Selected # of Attachments: '+allAttachments.size());
        
        List<attachFile> readyAttachments = new List<attachFile>();
        integer counter = 1;
        
        for (attachment att : allAttachments) {
            attachFile AF = new attachFile(att);
            if (att.ParentID == cas.ID) {
                af.belongsTo = 'Attached to case';
                System.Debug('Device being added to list: '+af);
            } else {
                for (device__c dvc : deviceList) {
                    if (att.ParentID == dvc.ID){
                        af.belongsTo = 'For Part Number ' +dvc.part_number__r.name+' Serial Number: '+dvc.Name;                    
                    }
                }	
            }
            readyAttachments.add(af);
            System.Debug('Device being added to list: '+af);
        }
        System.Debug('Added file to readyAttachments');
        System.debug('Ready Attachments: '+readyAttachments.size());
       
        return readyAttachments;
    }
}

 and lastly, here is the PDF VF page:

<apex:page title="Quote for Repair" showHeader="false" controller="IDS_RMA_Quote_Pictures_Getter">
    <apex:stylesheet value="{!URLFOR($Resource.RepairPDF, 'RFStyle.css')}"/>
    <Apex:form >
        <apex:pageBlock >
        <apex:pageMessages />
            <table width = "100%" align="center">
                <tr width = "100%">
                    <td width = "50%" align="left">
                        <apex:image value="{!URLFOR($Resource.RepairPDF, 'logo.jpg')}"/>
                    </td>
                </tr>
                <tr>
                    <td height="20px">
                        <!-- Spacing between logo and table-->
                    </td>
                </tr>
                <!--<apex:outputText value="Dear Customer"/>-->
                <table width="100%" Class="grid">
                    <tr>                    	
                        <td width="50%" colspan="2" align = "center">
                            <apex:outputText styleClass="headertext" value="Pictures related to RMA #{!cas.CaseNumber}"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="50%" align = "left" >
                        	<apex:outputText value="RMA Type : "/>
                            <apex:outputText value="{!cas.Type_of_RMA__c}"/>
                        </td>
                        <td align = "left">
                            <apex:outputText value="Date RMA Received: "/>	
                            <apex:outputText value="{!cas.Date_RMA_Received__c}"/>
                        </td>
                    </tr>
                </table>
                <!--Here starts the Device List-->
                <apex:variable value="{!1}" var="pgCount"/> 
                <apex:pageBlockSection title="Attached Images" columns="1">
                    <apex:repeat value="{!readyAttachments}" var="ra">
                        <div style="{!if(pgCount = 1, 'page-break-after:auto;', 'page-break-after:always;')}">
                            <apex:outputText value="{!ra.belongsTo}" />
                            <apex:image url="/servlet/servlet.FileDownload?file={!ra.theFile.ID}"/>
                            <apex:variable var="pgCount" value="{!pgCount+ 1}"/>
                        </div>
                    </apex:repeat>
                </apex:pageBlockSection>
            </table>            
        </apex:pageBlock>            
    </Apex:form>
</apex:page>

 

Hi Guys.

 

I created a class to create an "Orders__c" record from opportunities.

So far everythis looks and works great, with the exception of the recordtype selection.

As you can see in the code below, I am finding the Opportunity's record type (either "VMS Opportunity" or "Transportation Opportunity")

and then based on the I assign "VMS Orders" or "TAM Orders" record type for the new Order record.

I've originally used a simple MAP to match these, but when this did not work - I tried loading the RecordTypes into individual variables, and then assigning them.

 

When I degub - I can see in the log that the newOrder.RecordType actually gets assigned with the CORRECT RecordTypeID, BUT

Once I open the new record - it is always showing the "VMS Orders" record type, regardless of what is assigned in the code.

I've even tried inserting the record first, and then updating the recordtype as a secondary operation... still no dice.

 

I've looked at my triggers and workflows and cannot see anything that should change the recordtype...

 

Any help figuring this out would be greatly appreciated.

I feel like I am missing something stupid.

 

CODE: (Just the relevant snippet from my class)

 public pagereference createOrder(){        
        if (acctAsEndCustomer && this.Opp.End_User__c==null) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Must select a Customer'));
            PageReference pageRef = ApexPages.currentPage();
            return pageRef;
        }
        Opportunity myOpp = [select id, Name, AccountID, RecordTypeID from Opportunity where id = :this.opp.ID];

        Orders__c newOrder = new Orders__c();
        IF( acctAsEndCustomer ) {
            newOrder.Customer__c = this.Opp.End_User__c;
            newOrder.End_Customer__c = myOpp.AccountID;
        } Else {
            newOrder.Customer__c = myOpp.AccountID;
            newOrder.End_Customer__c = this.Opp.End_User__c;
        }  
 
        newOrder.Originating_Opportunity__c = this.opp.ID;
        newOrder.Summary__c= myOpp.Name;
        newOrder.Status__c = 'Created';
        newOrder.Date_of_Order__c = date.Today();
        newOrder.Required_Delivery_Date__c = reqDlvDate;
        newOrder.Requested_Ship_date__c = reqShipDate;
        newOrder.Type__c='Order';
        newOrder.Shipping_Charges__c = selShippingCharges;
        newOrder.Travel_Charges__c = selTravelCharges;
        newOrder.Purchase_Type__c = selPurchaseType;        
        
        insert newOrder; // insert the new order into DB

       //instantiate map to hold Order Record Types so we can create the correct type
//        map<id, recordtype> recordTypes = new map<id, recordtype>([select id, name from recordtype where sobjecttype='Opprtunity']);
        RecordType vmsOppRT = [ Select ID, Name from RecordType where SobjectType='Opportunity' and Name='VMS Opportunity' LIMIT 1];
        RecordType tranOppRT = [ Select ID, Name from RecordType where SobjectType='Opportunity' and Name='Transportation Opportunity' LIMIT 1];
        RecordType vmsOrdRT = [ Select ID, Name from RecordType where SobjectType='Orders__c' and Name='VMS Orders' LIMIT 1];
        RecordType tranOrdRT = [ Select ID, Name from RecordType where SobjectType='Orders__c' and Name='TAM Orders' LIMIT 1];
        System.debug('VMS Opp RT ID = '+vmsOppRT.id+', Trans Opp RT ID = '+tranOppRT.id);
        System.debug('This Opportunitys RT ID = '+myOpp.RecordTypeID);
        System.Debug('VMS Order RT ID = '+vmsOrdRT.id+', TAM Orders RT IT = '+tranOrdRT.id);
        IF (myOpp.RecordTypeID==vmsOppRT.id) {
//            newOrder.RecordType=[Select id FROM RecordType where SobjectType='orders__c' and name='VMS Orders' LIMIT 1];    
            newOrder.RecordType=vmsOrdRT;
            System.Debug('New Order Type (S/B VMS) = '+newOrder.RecordType);            
            update newOrder;
//        } ELSE IF (myOpp.RecordTypeID==recordTypes.get('Transportation Opportunity').id) {
        } ELSE IF (myOpp.RecordTypeID==tranOppRT.id){
//            newOrder.RecordType=[Select id FROM RecordType where SobjectType='orders__c' and name='TAM Orders' LIMIT 1];    
            neworder.RecordType=tranOrdRT;
            System.Debug('New Order Type (S/B TAM) = '+newOrder.RecordType);
            update newOrder;
        }

 

 

Hi.. Everything that I have found on this topic has been dated.  I have two field updates and I need one to fire before the other.  I strated by trying to build a formula field butthe formula ended up too big so I moved on to workflow field updates.

I know there is the checkbox to re-evaluate the rules if a specific field update changes the field but I wnat to be sure that will work.  My seond field update uses the field in the first field update so I really need them to be ordered properly.

Thank you!!!

Fred
  • November 30, 2016
  • Like
  • 0
Hi, I am trying to create a Visual Force email template that would display recently shipped items and tracking.

From the App Exchange, I downloaded "Product Line Items in Email Templates."

Its semi helpful, but it includes Opportunity and Products which seems to be a related or maybe lookup relationship.

In our system, the related Objects are a Master Detail Relationship.
Accounts -> Sales Orders -> Sales Order Lines

I am trying to do two unique things.

1. In terms of who gets emailed, instead of a Contact, is it possible to send an email to an address in an email field on the Sales Order Record, and if that is blank/null, send it to an address an on the Account object?

2. The Sales Order Lines will likely include Products and tracking. (I might need to make additional tweaks)
To display Products, I'd like to show Sales Order Lines where Line Status equals Shipped today.
To display tracking, I'd like to show Sales Order Lines where Description starts with TRPK.  (In our system, tracking lines display as TRPK 1Z11205, someting along those lines.)

If anyone can provide guidance to get me going, that would be appreciated.

Thanks,

Aron

Hi All,

 

I've created a VF page that allows users to select a list of custom objects related to a particular case, update some field information and attach pictures to any of these related objects. When done, the user clicks on an email that generates an email based on a VF Email template. This part works great.

Instead of sending multiple image attachments on this email, I created a VF page that displays all of these images, and was attempting to generate it as a PDF attachment to attach to the case.

When I load the VF page (which has renderAS="PDF"), it looks great and works as expected.

When I call it from my custom controller using the getContent() method, it is sending a file that I am unable to open using Adobe. When I try I receive the error "insufficient data for an image", and even the text on the page does not render (though, oddly,  the table is visible).

I have no clue how to attempt and troubleshoot it, so I will appreciate any help!

 

Here is my controller extendsion part which calls my page:

Messaging.EmailFileAttachment myAttach = new Messaging.EmailFileAttachment();
myAttach.setFilename(This.Cas.CaseNumber+'_Related_Pictures.pdf');
myAttach.setContentType('application/pdf');
PageReference myPdf = Page.IDS_Quote_Pictures_PDF;
mypdf.setRedirect(true);
myPDF.getParameters().put('ID' , this.Cas.ID);
blob b = myPdf.getContentAsPdf();
myAttach.setbody(b);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setWhatID(Cas.ID);
email.setTargetObjectId(toContacts[0].theContact.id);
EmailTemplate templateId = [Select id from EmailTemplate where name = 'IDS RMA Quote Email'];
email.setTemplateID(templateId.Id);
email.setSaveAsActivity(true);
email.setToAddresses(toAddresses);
email.setCCAddresses(ccAddresses);
email.setOrgWideEmailAddressId([SELECT id, displayName FROM OrgWideEmailAddress WHERE DisplayName = 'I.D. Systems RMA Department'].id);
if (myAttach != NULL) {
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {myAttach});
        }

 And here is the custom controller that the actual PDF VF page calls:

 

public class IDS_RMA_Quote_Pictures_Getter{

    // Wrapper class to wrap an attachment with a selection and some related details in text
    public class attachFile {
        public Attachment theFile {get;set;}
        public String belongsTo {get;set;}
    
        public attachFile(Attachment theFile) {
        	this.theFile = theFile;
        }
    }
    
    public final Case cas;
    //private final ID cas;
    private List<attachFile> readyAttachments;
        
    public IDS_RMA_Quote_Pictures_Getter(){
        //this.cas = (case)stdController.getRecord();        
        Cas = [Select ID, Subject, CaseNumber, Type_of_RMA__c, Date_RMA_Received__c FROM Case WHERE ID =: ApexPages.CurrentPage().getParameters().get('id')];
    }
    
    public Case getCas() {
    	return cas;   
    }
    
    
    public List<attachFile> getReadyAttachments() {
        System.debug('Starting Getter');
        List<device__C> deviceList = new List<Device__c>();
        deviceList = [SELECT Name,
                      Part_Number__R.Name,
                      Part_Number__R.Description__c,
                      Problem__c,
                      Visual_Inspection_Notes__c,
                      Quoted_Price__c,
                      Quote_Status__c,
                      Customer_Damage__c,
                      In_Warranty__c
                      FROM Device__c 
                      where Quote_Status__c =: 'Quoting' 
                      AND Case__c =: Cas.ID]; 
        System.debug('Devices: '+deviceList);
        
        List<ID> allDeviceIDs = new List<ID>();
        For (device__c d : deviceList) {
         	allDeviceIDs.add(d.ID);   
        }
        System.Debug('Device IDs: '+allDeviceIDs);
        
        List<Attachment> allAttachments = new List<Attachment>();
        allAttachments = [SELECT ID, Name, ParentID, body, ContentType 
                          FROM Attachment 
                          WHERE name != : 'Device_QR_Code.png'
                          AND ContentType LIKE 'image/%'
                          AND (ParentID IN : allDeviceIDs
                                 OR ParentID = : cas.ID)
                         Order by ID desc];
        System.debug('Selected # of Attachments: '+allAttachments.size());
        
        List<attachFile> readyAttachments = new List<attachFile>();
        integer counter = 1;
        
        for (attachment att : allAttachments) {
            attachFile AF = new attachFile(att);
            if (att.ParentID == cas.ID) {
                af.belongsTo = 'Attached to case';
                System.Debug('Device being added to list: '+af);
            } else {
                for (device__c dvc : deviceList) {
                    if (att.ParentID == dvc.ID){
                        af.belongsTo = 'For Part Number ' +dvc.part_number__r.name+' Serial Number: '+dvc.Name;                    
                    }
                }	
            }
            readyAttachments.add(af);
            System.Debug('Device being added to list: '+af);
        }
        System.Debug('Added file to readyAttachments');
        System.debug('Ready Attachments: '+readyAttachments.size());
       
        return readyAttachments;
    }
}

 and lastly, here is the PDF VF page:

<apex:page title="Quote for Repair" showHeader="false" controller="IDS_RMA_Quote_Pictures_Getter">
    <apex:stylesheet value="{!URLFOR($Resource.RepairPDF, 'RFStyle.css')}"/>
    <Apex:form >
        <apex:pageBlock >
        <apex:pageMessages />
            <table width = "100%" align="center">
                <tr width = "100%">
                    <td width = "50%" align="left">
                        <apex:image value="{!URLFOR($Resource.RepairPDF, 'logo.jpg')}"/>
                    </td>
                </tr>
                <tr>
                    <td height="20px">
                        <!-- Spacing between logo and table-->
                    </td>
                </tr>
                <!--<apex:outputText value="Dear Customer"/>-->
                <table width="100%" Class="grid">
                    <tr>                    	
                        <td width="50%" colspan="2" align = "center">
                            <apex:outputText styleClass="headertext" value="Pictures related to RMA #{!cas.CaseNumber}"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="50%" align = "left" >
                        	<apex:outputText value="RMA Type : "/>
                            <apex:outputText value="{!cas.Type_of_RMA__c}"/>
                        </td>
                        <td align = "left">
                            <apex:outputText value="Date RMA Received: "/>	
                            <apex:outputText value="{!cas.Date_RMA_Received__c}"/>
                        </td>
                    </tr>
                </table>
                <!--Here starts the Device List-->
                <apex:variable value="{!1}" var="pgCount"/> 
                <apex:pageBlockSection title="Attached Images" columns="1">
                    <apex:repeat value="{!readyAttachments}" var="ra">
                        <div style="{!if(pgCount = 1, 'page-break-after:auto;', 'page-break-after:always;')}">
                            <apex:outputText value="{!ra.belongsTo}" />
                            <apex:image url="/servlet/servlet.FileDownload?file={!ra.theFile.ID}"/>
                            <apex:variable var="pgCount" value="{!pgCount+ 1}"/>
                        </div>
                    </apex:repeat>
                </apex:pageBlockSection>
            </table>            
        </apex:pageBlock>            
    </Apex:form>
</apex:page>

 

I'm trying to create a trigger on attachments, so that when an attachment is added to a Task, and the Task is related to an opportunity, the attachment will be cloned onto the Opportunity.

 

Below is the code I have so far, but I can only get it to work if I remove the if(a.parentid == t.id) before creating the new attachment. Any thoughts?

 

trigger CloneOppTask on Attachment (after insert, after update) {

    Attachment[] insertAttList = new Attachment[]{};
    Set<ID> taskset = new Set<ID>();
    List<Attachment> attlist = [Select Id, parentId, name, body from Attachment where Parent.Type='Task' AND Id in :Trigger.new];

        for(Attachment a : attlist){
            taskset.add(a.parentId);
            }
            
        for(Task t: [Select ID, WhatId From Task Where WhatID in :taskset]){
            for(Attachment a: attlist){
                if(a.parentid == t.id){
                    Attachment att = new Attachment(name = a.name, body = a.body, parentid = t.WhatId);
                    
                    insertAttList.add(att);
                }
            }
        }
        if(insertAttList.size() > 0){
            insert insertAttList;
        }
}

 

What are the methods are involved while deploying the Apex class and trigger ?

 

Thank u in Advance.

Hi All,

 

I have a pop-up page which sends email to end user, I have done validation on server side and want to show Apexpagemessages on VFP through server side validations but unfortunately I am not able to show page messages when I use actionstatus and command button action.

Below is my Visualforce page code snippet to this:

 

<apex:pageMessages id="errors"/>
<apex:pageBlockButtons rendered="{!showButtons}" id="buttons"> <apex:commandButton action="{!Send}" value="Send" rerender="buttons" status="closer"/> <apex:commandButton value="Cancel" onclick="javascript&colon;closeWindow()"/> <apex:actionStatus startText="(Sending...)" stopText="" onStop="window.close();" id="closer"/> </apex:pageBlockButtons>

Please let me know your thoughts/suggestions on this.

Thank you!

 

Regards,

Lakshman

Create a formula field on the cases object called "Reference"

 

with the following formula

 

"[ ref:???????.????" & SUBSTITUTE( RIGHT(Id,11) , "0", "") & ":ref ]"

 

Replacing the ?? with the data from one of your own ref records.

The Red ?? you can copy directly from one of your own Ref records

The Blue ?? are the first 4 of the Case ID which doesn't change

 

 

Once you've created this field you can add it to workflow email templates on the subject line and it will basicly do what SF does when you email out from a case

 

You can also copy  this Reference when someone sends you an offline email and forward it to your support email with the Ref pasred in the subject line and it will attach that email to your case.

Hello,

Can anyone tell me :

Am I missing something or it's not possible to create a lookup relationship to Articles ?

Thats something i definitely need.

So, at this point, should I create something like a String field on my Custom Object that will store the article id and make another SOQL query to fetch it every time additionally ?

 

Kind regards

  • September 20, 2011
  • Like
  • 1