• Ganesh Rajput
  • NEWBIE
  • 15 Points
  • Member since 2019
  • Salesforce Developer
  • Spark-egnite

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 4
    Questions
  • 13
    Replies
Hello Experts, 
I have to create a formula field which accepts a Decimal number and return currency format(Include comma and decimal points )
I got a solution from the below link:

https://hub.appirio.com/tech-blog/displaying-currencies-in-a-sfdc-formula-field-or-visualforce

but getting error " Missing ")" "

at Bold text in a formula ("0")


formula:

IF(
  someCurrencyField__c >= 1000000,
  TEXT(FLOOR(someCurrencyField__c / 1000000)) & ",",
  "") &
IF(
  someCurrencyField__c >= 1000,
  RIGHT(TEXT(FLOOR(someCurrencyField__c / 1000)), 3) & ",",
  "") &
RIGHT(TEXT(FLOOR(someCurrencyField__c)), 3) & "." &
IF(
  MOD(someCurrencyField__c , 1) * 100
  "0" & TEXT(ROUND(MOD(someCurrencyField__c , 1), 2) * 100),
  TEXT(MIN(ROUND(MOD(someCurrencyField__c , 1), 2) * 100, 99))
)

please anyone can highlight what is wrong with this formula?

Thank you..!
I have two pick lists which are editable for user. when the flow will launch on click, these two Picklists should display with default picklist value but the user should not be able to edit these two picklists.

I am done with this requirement of default values but how can I make these Picklists read-only?
 Is it Possible?


Thank you 
I have a requirement to send visualforce(Include Images from the content document ) page attachment as pdf and as a word document. I am done with PDF but stuck at the second requirement want to send it as a word document file.

Controller 
public class CargoQuoteDocController {
public Quote__c quoteObj{get;set;}
    public User user{get;set;}
    public String todysDate{get;set;}
    public String DepartDate{get;set;}
    public List<String> ImageURLs{get;set;}
    public static String Thank_You_Message{get;set;}
    public static String PRICE_INCLUDES{get;set;}
    public static String PRICE_DOES_NOT_INCLUDE{get;set;}
    public String quo;  
    public String D_Date{get;set;}
    public String A_Date{get;set;}
    public ACType__c acType{get;set;}
    public Quote__c quote{get;set;}
    public Opportunity oppo{get;set;}
    public List<String> imgIds = new List<String>();
        
    public void setValues(){
        ImageURLs = new List<String>();
        //List<String> imgIds = new List<String>();
        quo = apexPages.currentPage().getParameters().get('recId');
        PRICE_DOES_NOT_INCLUDE = apexPages.currentPage().getParameters().get('segThree');//quoteTerms.PRICE_DOES_NOT_INCLUDE__c;
        Thank_You_Message = apexPages.currentPage().getParameters().get('segOne');//quoteTerms.Thank_You_Message__c;
        PRICE_INCLUDES = apexPages.currentPage().getParameters().get('segTwo');//quoteTerms.PRICE_INCLUDES__c;
        Integer length = Integer.valueOf(apexPages.currentPage().getParameters().get('length'));
        
        if(length>0){
            for(Integer i=0; i<length;i++){
                imgIds.add(apexPages.currentPage().getParameters().get('img'+i));
            }
        }
        
        for(String img:imgIds){
            ImageURLs.add(URL.getSalesforceBaseUrl().toExternalForm()+'/sfc/servlet.shepherd/version/download/'+img);  	
        }
        
        for(String img:ImageURLs){
            System.debug('ImageURLs == '+img);  
        }
        System.debug(quoteObj);
        
        user = [SELECT Id, Name,Email, MobilePhone FROM User WHERE Id=:UserInfo.getUserId()];
        
        try{
            System.debug('quote == '+quo);
            this.quote = [SELECT ID, Name, Opportunity__c, Aircraft__c, AircraftType__c,Contact_Name__c, Contact_Email__c,
                          (SELECT Id, From__r.Name, To__r.Name,Airway_Time__c,Duration__c,DepartDate__c,DepartTime__c,
                           Temp_Duration__c, ArriveTime__c, ArriveDate__c,PAX__c,CGO__c FROM Quote_Sectors__r) FROM Quote__c WHERE id=:quo];
            this.oppo = [SELECT Id, Name, ContactId, OppID__c, Depart_Date__c, Cargo_lbs__c  
                         FROM Opportunity WHERE Id =: quote.Opportunity__c];  
            this.acType = [SELECT Id,Name, Load__c, Manufacturer__c,Volume__c,MaxKGS__c FROM ACType__c 
                           WHERE Id=:quote.AircraftType__c];
        }catch(Exception e){
            System.debug('Exception == '+e);
        }
        DateTime dT = System.now();
            todysDate = dT.month()+'/'+dT.day()+'/'+dT.year();
        if(oppo.Depart_Date__c != null){
            DateTime dT2 = oppo.Depart_Date__c;
            DepartDate = dT2.month()+'/'+dT2.day()+'/'+dT2.year(); 
            
        }
    }
}
Visualforce Page
<apex:page controller="CargoQuotePdfController" action="{!setValues}" sidebar="false"
           showHeader="false" contentType="application/vnd.msWord" cache="true">
    <center>
        <html>
            <body>
                <div class="slds-m-around--large">
                    <table width="700">
                        <td>
                            <center>
                                <!--Letter Heade-->  
                                <div class="header">
                                    <center>
                                        <!--<img src="{!$Resource.LetterHead}" width="700" hight="80"/>-->
                                    </center>
                                </div>
                                <!--To From Detils -->
                                <table width="700px">
                                    <tr>
                                        <td style="padding-bottom: 10px; width: 75%;text-align:left;">
                                            <h3>CHARTER FLIGHT</h3><br/>
                                            <b>TRIP # {!oppo.OppID__c}</b><br/>
                                            <p>QUOTATION # {!quote.Name}</p> 
                                        </td>
                                        <td style="padding-bottom: 10px; width: 30%;text-align:left;">
                                            DATE: {!todysDate}<br/><br/>
                                            TO: {!quote.Contact_Name__c}<br/>
                                            FROM: {!user.Name}
                                        </td>
                                    </tr>
                                </table>
                            </center>
                            <!--Thank you Message-->
                            <p>
                                <b>Dear {!quote.Contact_Name__c},</b><br/>
                            </p>
                            <div>
                                <div rows="5" cols="80" name="comment" form="usrform">
                                    {!Thank_You_Message}
                                </div>
                            </div>
                            <!--Iternanery-->
                            <p >
                                <br/><b>Proposed Itinerary</b><br/>
                            </p>
                            <table border="1px;"  width="700" >
                                <tr>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>Depart Date/Time</center></th>
                                    <th style="padding-bottom: 10px; width: 20%; background-color:#4db8ff; color:white;"><center>FROM</center></th>
                                    <th style="padding-bottom: 10px; width: 20%; background-color:#4db8ff; color:white;"><center>TO</center></th>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>Arrive<br/>Date/time</center></th>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>Duration</center></th>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>CGO</center></th>
                                </tr>
                                <apex:repeat value="{!quote.Quote_Sectors__r}" var="queSec" id="theRepeat">
                                    <tr>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.DepartDate__c}<br/>{!queSec.DepartTime__c}</center></td>
                                        <td style="padding-bottom: 10px; width: 20%; background-color:#cbd6d3;"><center>{!queSec.From__r.Name}</center></td>
                                        <td style="padding-bottom: 10px; width: 20%; background-color:#cbd6d3;"><center>{!queSec.To__r.Name}</center></td>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.ArriveDate__c}<br/>{!queSec.ArriveTime__c}</center></td>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.Temp_Duration__c}</center></td>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.CGO__c}</center></td>
                                    </tr>
                                </apex:repeat>
                            </table>
                            <br/><br/>
                            <!--Images-->
                            <b>
                                Aircraft Image <br/><br/>
                            </b>
                            <div style="margin-left:50px;width:700;min-height:300px">
                                <apex:repeat value="{!ImageURLs}" var="image" id="Images">
                                    <!--<img src="{!image}" style="width:200px; hight:200px"/>-->
                                    <apex:image url="{!image}" style="width:200px; hight:200px"/>
                                </apex:repeat>
                            </div>
                            <br/><br/>
                            <!--Price payload-->
                            <table border="1px" width="700">
                                <tr>
                                    <td rowspan="2" style="padding-bottom: 10px; width: 50%;margin-left:20px;">
                                        Aircraft: {!acType.Load__c} <br/>&nbsp;&nbsp;
                                        {!acType.Manufacturer__c} <br/>&nbsp;&nbsp;
                                        {!acType.Name}</td>
                                    <td style="margin-left:20px;">PAYLOAD: {!acType.MaxKGS__c}</td>
                                </tr>
                                <tr>
                                    <td style="margin-left:20px;">VOLUME: {!acType.Volume__c}</td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="margin-left:20px;">PRICE:</td>
                                </tr>
                            </table>
                            <br/>
                            <div>
                                <div rows="5" cols="80" name="comment" form="usrform">
                                    {!PRICE_INCLUDES}
                                </div>
                            </div>
                            <br/>
                            <div>
                                <div rows="5" cols="80" name="comment" form="usrform">
                                    {!PRICE_DOES_NOT_INCLUDE}
                                </div>
                            </div><br/>
                            Please let me know if you require any additional information.<br/>
                            Best Regards,
                            
                            <br/><br/><br/>
                            
                            <p>
                                {!user.Name}<br/>
                                {!user.MobilePhone}<br/>
                                {!user.Email}
                            </p>
                        </td>
                    </table> 
                </div>
                <br/>
            </body>
        </html>  
    </center>  
</apex:page>

and this code to send email
 
Messaging.EmailFileAttachment attach2 = new Messaging.EmailFileAttachment();
           	pagereference pageRef2 = Page.CargoQuoteDoc;
            pageRef2.setRedirect(true);
            pageRef2.getParameters().put('recId',recId);
            pageRef2.getParameters().put('segOne',Thank_You_Message);
            pageRef2.getParameters().put('segTwo',PRICE_INCLUDES);
            pageRef2.getParameters().put('segThree',PRICE_DOES_NOT_INCLUDE);
            pageRef2.getParameters().put('length',String.valueOf(length));
            Integer j=0;
            for(String img :imgIds){
                pageRef.getParameters().put('img'+j,img);
                j=j+1;
            }
            
            for(String img :imgIds){
                System.debug('img == '+img);
                
            }
            
            Blob body;//= pageRef.getContent();
            
            if(Test.isRunningTest()) { 
                body = blob.valueOf('Unit.Test');
            } else {
                body = pageRef.getContent();
            }
            attach2.setFileName('Cargo Quote.doc');
            attach2.setBody(body);

when I render visual force page it download on the local system it looks fine with textual content(Images not displaying ) but when I send it as an attachment and open it, it Open in unreadable formatted





%PDF-1.4
%âãÏÓ
2 0 obj <</ColorSpace[/CalRGB<</Gamma[2.2 2.2 2.2]/WhitePoint[0.95043 1 1.09]/Matrix[0.41239 0.21264 0.01933 0.35758 0.71517 0.11919 0.18045 0.07218 0.9504]>>]/Intent/Perceptual/Subtype/Image/Height 137/Filter/FlateDecode/Type/XObject/DecodeParms<</Columns 1131/Colors 3/Predictor 15/BitsPerComponent 8>>/Width 1131/Length 19127/BitsPerComponent 8>>stream
x^í½€Å™÷=&Ïl�V9
$HŒ�³á






Please provide some guidence for this issue 
<apex:page standardController="RFQ__c" recordSetVar="RFQ"
           lightningStylesheets="true"
           showHeader="false"
           standardStylesheets="false"
           sidebar="false"
           applyHtmlTag="false" applyBodyTag="false"
           docType="html-5.0"
           action="{!genrateRFQQoute}"
           extensions="QuoteCreatorController">
    <apex:form >
        <apex:pageBlock title="Create Quotes" mode="maindetail">
            <center>
                <apex:outputLabel rendered="{!ifSuccess}" style="color:Green"><H3>
               

                          <!-- Calling success toast-->


                </H3></apex:outputLabel>
                <apex:outputLabel rendered="{!ifError}" style="color:red"><H3>
                    

                           <!-- Calling error toast -->


                    </H3></apex:outputLabel>
            </center>
        </apex:pageBlock>
    </apex:form>
    <apex:slds />
    <script>
    function toastSuccess()
    {
        sforce.one.showToast({
            "title": "Success!",
            "key": 'info_alt',
            "type": "success",
            "message": "Sucess message !!!"
        });
    },
        function toastError()
    {
        sforce.one.showToast({
            "title": "Success!",
            "key": 'info_alt',
            "type": "error",
            "message": "Error message !!!"
        });
    }
        
    </script>
    
    
</apex:page>
calling toast functions dynamically 
this visualforce page is added to listview button controller performing mass action, I have to display toast depending on success or failure
 all things are done just need call this script functions.
Hello Experts, 
I have to create a formula field which accepts a Decimal number and return currency format(Include comma and decimal points )
I got a solution from the below link:

https://hub.appirio.com/tech-blog/displaying-currencies-in-a-sfdc-formula-field-or-visualforce

but getting error " Missing ")" "

at Bold text in a formula ("0")


formula:

IF(
  someCurrencyField__c >= 1000000,
  TEXT(FLOOR(someCurrencyField__c / 1000000)) & ",",
  "") &
IF(
  someCurrencyField__c >= 1000,
  RIGHT(TEXT(FLOOR(someCurrencyField__c / 1000)), 3) & ",",
  "") &
RIGHT(TEXT(FLOOR(someCurrencyField__c)), 3) & "." &
IF(
  MOD(someCurrencyField__c , 1) * 100
  "0" & TEXT(ROUND(MOD(someCurrencyField__c , 1), 2) * 100),
  TEXT(MIN(ROUND(MOD(someCurrencyField__c , 1), 2) * 100, 99))
)

please anyone can highlight what is wrong with this formula?

Thank you..!
Assume A Lead record is inserted, in AfterInsert trigger code is written to populate some fields on the same lead, so update DML is performed on lead from AfterInsert trigger.
But on Update one custom validation rule is failed and error is thrown.
In such scenario the whole transaction should fail or only the Update part? 
I have two pick lists which are editable for user. when the flow will launch on click, these two Picklists should display with default picklist value but the user should not be able to edit these two picklists.

I am done with this requirement of default values but how can I make these Picklists read-only?
 Is it Possible?


Thank you 
I have a requirement to send visualforce(Include Images from the content document ) page attachment as pdf and as a word document. I am done with PDF but stuck at the second requirement want to send it as a word document file.

Controller 
public class CargoQuoteDocController {
public Quote__c quoteObj{get;set;}
    public User user{get;set;}
    public String todysDate{get;set;}
    public String DepartDate{get;set;}
    public List<String> ImageURLs{get;set;}
    public static String Thank_You_Message{get;set;}
    public static String PRICE_INCLUDES{get;set;}
    public static String PRICE_DOES_NOT_INCLUDE{get;set;}
    public String quo;  
    public String D_Date{get;set;}
    public String A_Date{get;set;}
    public ACType__c acType{get;set;}
    public Quote__c quote{get;set;}
    public Opportunity oppo{get;set;}
    public List<String> imgIds = new List<String>();
        
    public void setValues(){
        ImageURLs = new List<String>();
        //List<String> imgIds = new List<String>();
        quo = apexPages.currentPage().getParameters().get('recId');
        PRICE_DOES_NOT_INCLUDE = apexPages.currentPage().getParameters().get('segThree');//quoteTerms.PRICE_DOES_NOT_INCLUDE__c;
        Thank_You_Message = apexPages.currentPage().getParameters().get('segOne');//quoteTerms.Thank_You_Message__c;
        PRICE_INCLUDES = apexPages.currentPage().getParameters().get('segTwo');//quoteTerms.PRICE_INCLUDES__c;
        Integer length = Integer.valueOf(apexPages.currentPage().getParameters().get('length'));
        
        if(length>0){
            for(Integer i=0; i<length;i++){
                imgIds.add(apexPages.currentPage().getParameters().get('img'+i));
            }
        }
        
        for(String img:imgIds){
            ImageURLs.add(URL.getSalesforceBaseUrl().toExternalForm()+'/sfc/servlet.shepherd/version/download/'+img);  	
        }
        
        for(String img:ImageURLs){
            System.debug('ImageURLs == '+img);  
        }
        System.debug(quoteObj);
        
        user = [SELECT Id, Name,Email, MobilePhone FROM User WHERE Id=:UserInfo.getUserId()];
        
        try{
            System.debug('quote == '+quo);
            this.quote = [SELECT ID, Name, Opportunity__c, Aircraft__c, AircraftType__c,Contact_Name__c, Contact_Email__c,
                          (SELECT Id, From__r.Name, To__r.Name,Airway_Time__c,Duration__c,DepartDate__c,DepartTime__c,
                           Temp_Duration__c, ArriveTime__c, ArriveDate__c,PAX__c,CGO__c FROM Quote_Sectors__r) FROM Quote__c WHERE id=:quo];
            this.oppo = [SELECT Id, Name, ContactId, OppID__c, Depart_Date__c, Cargo_lbs__c  
                         FROM Opportunity WHERE Id =: quote.Opportunity__c];  
            this.acType = [SELECT Id,Name, Load__c, Manufacturer__c,Volume__c,MaxKGS__c FROM ACType__c 
                           WHERE Id=:quote.AircraftType__c];
        }catch(Exception e){
            System.debug('Exception == '+e);
        }
        DateTime dT = System.now();
            todysDate = dT.month()+'/'+dT.day()+'/'+dT.year();
        if(oppo.Depart_Date__c != null){
            DateTime dT2 = oppo.Depart_Date__c;
            DepartDate = dT2.month()+'/'+dT2.day()+'/'+dT2.year(); 
            
        }
    }
}
Visualforce Page
<apex:page controller="CargoQuotePdfController" action="{!setValues}" sidebar="false"
           showHeader="false" contentType="application/vnd.msWord" cache="true">
    <center>
        <html>
            <body>
                <div class="slds-m-around--large">
                    <table width="700">
                        <td>
                            <center>
                                <!--Letter Heade-->  
                                <div class="header">
                                    <center>
                                        <!--<img src="{!$Resource.LetterHead}" width="700" hight="80"/>-->
                                    </center>
                                </div>
                                <!--To From Detils -->
                                <table width="700px">
                                    <tr>
                                        <td style="padding-bottom: 10px; width: 75%;text-align:left;">
                                            <h3>CHARTER FLIGHT</h3><br/>
                                            <b>TRIP # {!oppo.OppID__c}</b><br/>
                                            <p>QUOTATION # {!quote.Name}</p> 
                                        </td>
                                        <td style="padding-bottom: 10px; width: 30%;text-align:left;">
                                            DATE: {!todysDate}<br/><br/>
                                            TO: {!quote.Contact_Name__c}<br/>
                                            FROM: {!user.Name}
                                        </td>
                                    </tr>
                                </table>
                            </center>
                            <!--Thank you Message-->
                            <p>
                                <b>Dear {!quote.Contact_Name__c},</b><br/>
                            </p>
                            <div>
                                <div rows="5" cols="80" name="comment" form="usrform">
                                    {!Thank_You_Message}
                                </div>
                            </div>
                            <!--Iternanery-->
                            <p >
                                <br/><b>Proposed Itinerary</b><br/>
                            </p>
                            <table border="1px;"  width="700" >
                                <tr>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>Depart Date/Time</center></th>
                                    <th style="padding-bottom: 10px; width: 20%; background-color:#4db8ff; color:white;"><center>FROM</center></th>
                                    <th style="padding-bottom: 10px; width: 20%; background-color:#4db8ff; color:white;"><center>TO</center></th>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>Arrive<br/>Date/time</center></th>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>Duration</center></th>
                                    <th style="padding-bottom: 10px; width: 15%; background-color:#4db8ff; color:white;"><center>CGO</center></th>
                                </tr>
                                <apex:repeat value="{!quote.Quote_Sectors__r}" var="queSec" id="theRepeat">
                                    <tr>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.DepartDate__c}<br/>{!queSec.DepartTime__c}</center></td>
                                        <td style="padding-bottom: 10px; width: 20%; background-color:#cbd6d3;"><center>{!queSec.From__r.Name}</center></td>
                                        <td style="padding-bottom: 10px; width: 20%; background-color:#cbd6d3;"><center>{!queSec.To__r.Name}</center></td>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.ArriveDate__c}<br/>{!queSec.ArriveTime__c}</center></td>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.Temp_Duration__c}</center></td>
                                        <td style="padding-bottom: 10px; width: 15%; background-color:#cbd6d3;"><center>{!queSec.CGO__c}</center></td>
                                    </tr>
                                </apex:repeat>
                            </table>
                            <br/><br/>
                            <!--Images-->
                            <b>
                                Aircraft Image <br/><br/>
                            </b>
                            <div style="margin-left:50px;width:700;min-height:300px">
                                <apex:repeat value="{!ImageURLs}" var="image" id="Images">
                                    <!--<img src="{!image}" style="width:200px; hight:200px"/>-->
                                    <apex:image url="{!image}" style="width:200px; hight:200px"/>
                                </apex:repeat>
                            </div>
                            <br/><br/>
                            <!--Price payload-->
                            <table border="1px" width="700">
                                <tr>
                                    <td rowspan="2" style="padding-bottom: 10px; width: 50%;margin-left:20px;">
                                        Aircraft: {!acType.Load__c} <br/>&nbsp;&nbsp;
                                        {!acType.Manufacturer__c} <br/>&nbsp;&nbsp;
                                        {!acType.Name}</td>
                                    <td style="margin-left:20px;">PAYLOAD: {!acType.MaxKGS__c}</td>
                                </tr>
                                <tr>
                                    <td style="margin-left:20px;">VOLUME: {!acType.Volume__c}</td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="margin-left:20px;">PRICE:</td>
                                </tr>
                            </table>
                            <br/>
                            <div>
                                <div rows="5" cols="80" name="comment" form="usrform">
                                    {!PRICE_INCLUDES}
                                </div>
                            </div>
                            <br/>
                            <div>
                                <div rows="5" cols="80" name="comment" form="usrform">
                                    {!PRICE_DOES_NOT_INCLUDE}
                                </div>
                            </div><br/>
                            Please let me know if you require any additional information.<br/>
                            Best Regards,
                            
                            <br/><br/><br/>
                            
                            <p>
                                {!user.Name}<br/>
                                {!user.MobilePhone}<br/>
                                {!user.Email}
                            </p>
                        </td>
                    </table> 
                </div>
                <br/>
            </body>
        </html>  
    </center>  
</apex:page>

and this code to send email
 
Messaging.EmailFileAttachment attach2 = new Messaging.EmailFileAttachment();
           	pagereference pageRef2 = Page.CargoQuoteDoc;
            pageRef2.setRedirect(true);
            pageRef2.getParameters().put('recId',recId);
            pageRef2.getParameters().put('segOne',Thank_You_Message);
            pageRef2.getParameters().put('segTwo',PRICE_INCLUDES);
            pageRef2.getParameters().put('segThree',PRICE_DOES_NOT_INCLUDE);
            pageRef2.getParameters().put('length',String.valueOf(length));
            Integer j=0;
            for(String img :imgIds){
                pageRef.getParameters().put('img'+j,img);
                j=j+1;
            }
            
            for(String img :imgIds){
                System.debug('img == '+img);
                
            }
            
            Blob body;//= pageRef.getContent();
            
            if(Test.isRunningTest()) { 
                body = blob.valueOf('Unit.Test');
            } else {
                body = pageRef.getContent();
            }
            attach2.setFileName('Cargo Quote.doc');
            attach2.setBody(body);

when I render visual force page it download on the local system it looks fine with textual content(Images not displaying ) but when I send it as an attachment and open it, it Open in unreadable formatted





%PDF-1.4
%âãÏÓ
2 0 obj <</ColorSpace[/CalRGB<</Gamma[2.2 2.2 2.2]/WhitePoint[0.95043 1 1.09]/Matrix[0.41239 0.21264 0.01933 0.35758 0.71517 0.11919 0.18045 0.07218 0.9504]>>]/Intent/Perceptual/Subtype/Image/Height 137/Filter/FlateDecode/Type/XObject/DecodeParms<</Columns 1131/Colors 3/Predictor 15/BitsPerComponent 8>>/Width 1131/Length 19127/BitsPerComponent 8>>stream
x^í½€Å™÷=&Ïl�V9
$HŒ�³á






Please provide some guidence for this issue 
<apex:page standardController="RFQ__c" recordSetVar="RFQ"
           lightningStylesheets="true"
           showHeader="false"
           standardStylesheets="false"
           sidebar="false"
           applyHtmlTag="false" applyBodyTag="false"
           docType="html-5.0"
           action="{!genrateRFQQoute}"
           extensions="QuoteCreatorController">
    <apex:form >
        <apex:pageBlock title="Create Quotes" mode="maindetail">
            <center>
                <apex:outputLabel rendered="{!ifSuccess}" style="color:Green"><H3>
               

                          <!-- Calling success toast-->


                </H3></apex:outputLabel>
                <apex:outputLabel rendered="{!ifError}" style="color:red"><H3>
                    

                           <!-- Calling error toast -->


                    </H3></apex:outputLabel>
            </center>
        </apex:pageBlock>
    </apex:form>
    <apex:slds />
    <script>
    function toastSuccess()
    {
        sforce.one.showToast({
            "title": "Success!",
            "key": 'info_alt',
            "type": "success",
            "message": "Sucess message !!!"
        });
    },
        function toastError()
    {
        sforce.one.showToast({
            "title": "Success!",
            "key": 'info_alt',
            "type": "error",
            "message": "Error message !!!"
        });
    }
        
    </script>
    
    
</apex:page>
calling toast functions dynamically 
this visualforce page is added to listview button controller performing mass action, I have to display toast depending on success or failure
 all things are done just need call this script functions.
I have custom object called 'Mall'. Once users have selected the Malls, there would be a button on the top right that says "Add to Account".
When the user clicks the button, it will ask them to select an account (they will be able to search accounts). Once they select an Account, there will be a button that says 'Add'. 
When they click add, the Malls that they selected on the list view would be added to the selected account they chose. 





How can I achieve this functionality in Lightening ?User-added image
Hello,

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

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

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

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

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

How can i do this in Salesforce? Please help me.
Hi all,

I have six queries and i would want to retrieve the data by merging those queries into a single one . How can this be done?

retrieveUserProfile  -> SELECT Mobile_Configuration_Profile__r.Name, Mobile_Configuration_Profile__r.API_Access__c FROM UserToMobileLink__c WHERE User__c = 'userId’
 
retrieveCurrentUserDetails -> select  Languages__c, User_Sales_Org__c from User where Id = ‘userId’
 
retrieveLocaleObject -> Select Name, Translated_Text__c from Translations__c where Language__c = 'userLocale'
 
retrieveUserProfileSpecification -> select Id, Name, Tab__c ,Create__c, Delete__c,Update__c, SOQL_Data_Filter__c from Mobile_Configuration_Item__c where Mobile_Configuration_Profile__r.Name = 'profileName’ ORDER BY Id.
 
 Everytime I try to save a visualforce page in the setup section I get the following error:Error: <apex:page> is required and must be the outermost tag in the markup at line 1 column 1

I get the error if i edit the page, if i try to rename the file or even if i open it up and just hit save. This is happening on all visualforce pages. Any ideas? My Code: (This is just the standard SFDC Login Visualforce page.
I want to retrieve Images from notes and attachments except other notes like pdf,text... how can we write soql query
  • December 24, 2013
  • Like
  • 0
We have one trigger in org on sobject type Delete Content Document. I am not sure what is this object and how to create its record in test class.I am not able to write test class for it.

Please find below code of trigger:
trigger DeleteContentDocumentTrigger on Delete_Content_Document__e (after insert) {
    List<ContentDocument> contentDocumentList = new List<ContentDocument>();
    List<Attachment> attachmentList = new List<Attachment>();
    List<eLicense_Attachment__c> eLicenseAttachmentList = new List<eLicense_Attachment__c>();
       
    for (Delete_Content_Document__e event : Trigger.New) {
        if (event.Content_Document_Id__c != null) {
            contentDocumentList.add(new ContentDocument(id = event.Content_Document_Id__c));
        }
        if (event.Attachment_Id__c != null) {
            attachmentList.add(new Attachment(id = event.Attachment_Id__c));
        }
        if (event.eLicense_Attachment_Id__c != null) {
            eLicenseAttachmentList.add(new eLicense_Attachment__c(id = event.eLicense_Attachment_Id__c));
        }
   }
    
    delete contentDocumentList;
    delete attachmentList;
    delete eLicenseAttachmentList;
}

Please find below test class:
@isTest
public class DeleteContentDocumentTriggerTest {
    
    public static testmethod void test_contentDoc(){
        Test.startTest();
          //try{
    Global_Settings__c globalSettings = new Global_Settings__c(Name = 'Default', Disable_Triggers__c = true);
        if(globalSettings != null) insert globalSettings;
        Account acc = OH_Utility_UnitTestData.createTestAccount();
        insert acc;
        Blob beforeblob=Blob.valueOf('Unit Test Attachment Body');

        ContentVersion cv = new ContentVersion();
        cv.title = 'test content trigger';      
        cv.PathOnClient ='test';           
        cv.VersionData =beforeblob;          
        insert cv;             
                                                
         List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];

        ContentDocumentLink contentlink=new ContentDocumentLink();
        contentlink.LinkedEntityId=acc.id;
        contentlink.ShareType= 'V';
        contentlink.ContentDocumentId=documents[0].Id;
        contentlink.Visibility = 'AllUsers'; 
        insert contentlink;
    
      
         delete documents;
        
         delete contentlink;
         Delete_Content_Document__e dc = new Delete_Content_Document__e();
       // EventBus.publish(dc);
            
        //}
        //catch(Exception e){}
        Test.stopTest();
    //insert dc;
    }

}
It is not covering trigger at all.