• Shaan Khokhar 9
  • NEWBIE
  • 30 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 4
    Replies

Hi all,

I am curious how i'd make a test class for the below code. It gets the api from https://api.exchangeratesapi.io/latest.

You can read it below:

 

global class updateCurrency Implements Schedulable{
    global void execute(SchedulableContext sc)
       {
            getCurrencies();
       }
    public static HttpResponse httpRequest(){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://api.exchangeratesapi.io/latest?base=GBP');
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        system.debug('Http request'+response.getBody());
        return response;
    }
  @future(callout=true)  public static void getCurrencies(){
        Id usdID, eurID, cadId;
        double usd, eur, cad;
        HttpResponse response = httpRequest();
        if (response.getStatusCode() == 200) {
            // Deserialize the JSON string into collections of primitive data types.
            Map<String,Object> jsonParsed =(Map<String,Object> ) JSON.deserializeUntyped(response.getBody());
            Map<String,Object> ratesParsed = ( Map<String,Object>) jsonParsed.get('rates');
            usd = (double) ratesParsed.get('USD');
            eur = (double) ratesParsed.get('EUR');
            cad = (double) ratesParsed.get('CAD');
        }
        List<CurrencyType> listCurrencies = new List<CurrencyType>();
        listCurrencies = [SELECT Id,IsoCode FROM CurrencyType WHERE IsActive = true];
        if(listCurrencies.size() > 0){
            for(integer i = 0; i < listCurrencies.size(); i++){
                if(listCurrencies[i].IsoCode == 'USD'){
                    usdID = listCurrencies[i].Id;
                    setCurrency(usdID, usd);
                }
                else if(listCurrencies[i].IsoCode == 'EUR'){
                    eurID = listCurrencies[i].Id;
                    setCurrency(eurID, eur);
                }
                else if(listCurrencies[i].IsoCode == 'CAD'){
                    cadID = listCurrencies[i].Id;
                    setCurrency(cadID, cad);
                }
            }              
        }
    }
    
    public static HttpResponse setCurrency(Id curId, double rate){
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v51.0/sobjects/CurrencyType/'+curId);
        req.setBody('{ "DecimalPlaces" : 2 , "ConversionRate" :'+rate+'}');
        req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
        req.setHeader('Content-Type', 'application/json');
        req.setMethod('PATCH');
        HttpResponse res = h.send(req); 
        system.debug('Request Body' + res);
        return res;
    }
}
Hi all,

I attempted to make an unordered list for my footer, however the css doesn't seem to be working in Salesforce Communities, even though i've trialed in it's own seperate html file and it works. 

This is my html
 
<div class = "site-footer">
<div class="container py-5">
  <div class="row">
      <img src = "" alt="footer logo"/>
    </div><br/>
    <div class = "row">

    <div class="col-6 col-md">
      
      <h5>HEAD OFFICE</h5><br/>
      <ul>
        <li>71-75 Shelton Street</li>
        <li>Covent Garden</li>
        <li>London United Kingdom</li>
        <li>WC2H 9JQ</li><br/>
        <li>+44 (0)20 3916 5004</li>
      </ul>
    </div>
    <div class="col-6 col-md">
      <h5>MAINTENANCE</h5><br/>
      <ul>
        <li><a class="text-muted" href="https://velezmanagedservices.com/break-fix/">Breakfix</a></li>
        <li><a class="text-muted" href="https://velezmanagedservices.com/server-maintenance/">Server Maintenance</a></li>
        <li><a class="text-muted" href="https://velezmanagedservices.com/storage-maintenance/">Storage Maintenance</a></li>
        <li><a class="text-muted" href="https://velezmanagedservices.com/network-maintenance/">Network Maintenance</a></li>
         <li><a class="text-muted" href="https://velezmanagedservices.com/asset-management/">Asset Management</a></li>
          <li><a class="text-muted" href="https://velezmanagedservices.com/data-centre-services/">Data Centre Services</a></li>
      </ul>
    </div>
    <div class="col-6 col-md">
      <h5>USEFUL LINKS</h5><br/>
      <ul>
        <li><a class="text-muted" href="https://velezmanagedservices.com/about-us/">About Us</a></li>
        <li><a class="text-muted" href="https://velezmanagedservices.com/careers/">Careers</a></li>
        <li><a class="text-muted" href="https://velezmanagedservices.com/contact/">Contact</a></li>
        <li><a class="text-muted" href="https://velezmanagedservices.com/partner/">Partner</a></li>
        <li><a class="text-muted" href="https://velezmanagedservices.com/partner/">Legal</a></li>
      </ul>
    </div>
  </div>
</div>
</div>
My css
.site-footer
{
  background-color:#262626;
  padding:45px 0 20px;
  font-size:15px;
  line-height:24px;
  color:#737373;
}

ul{
  list-style-type: none;
  margin: 0px !important;
  padding: 0px !important;
}
.site-footer hr
{
  border-top-color:#bbb;
  opacity:0.5
}
.site-footer hr.small
{
  margin:20px 0
}
.site-footer h6
{
  color:#fff;
  font-size:16px;
  text-transform:uppercase;
  margin-top:5px;
  letter-spacing:2px
}
.site-footer a
{
  color:#737373;
}
.site-footer a:hover
{
  color:#3366cc;
  text-decoration:none;
}

.site-footer .social-icons
{
  text-align:right
}
.site-footer .social-icons a
{
  width:40px;
  height:40px;
  line-height:40px;
  margin-left:6px;
  margin-right:0;
  border-radius:100%;
  background-color:#33353d
}
.copyright-text
{
  margin:0
}
@media (max-width:991px)
{
  .site-footer [class^=col-]
  {
    margin-bottom:30px
  }
}
@media (max-width:767px)
{
  .site-footer
  {
    padding-bottom:0
  }
  .site-footer .copyright-text,.site-footer .social-icons
  {
    text-align:center
  }
}

 

Hi all,
We have a scenario where someone has a system that when they reply, it doesn't directly reply meaning the case thread ID is lost.

However, the system they use include there own support case number and this will be the same number, but, there subject changes after creation of the case to include 'Updated'. 

I've attempted to utilize my code here inside the Apex Trigger of Email Message but it doesn't seem to be doing anything:

 

trigger AssociateEmail on EmailMessage (before insert) {

    for(EmailMessage eMsg : Trigger.new) {
        String json = JSON.serialize(eMsg.Subject);
        String jsondata = json.replaceAll('[^0-9]','');
        
        System.debug('test');
        System.debug(jsondata);

        List<Case> c = [select Id from Case where Subject = :jsondata LIMIT 1];
        
        
        if(c.size() > 0) {
            
            eMsg.Id = c[0].Id;
        }
    }
}
Hi Everyone,

I am trying to make it so my html table has it so that it looks like this:

User-added image
However, currently it looks more like this:

User-added image

I know that the apex:repeat is causing the problem, would i be able to exclude the first column somehow?

Here's my table code:
<table id = "table" style="width:50%">
                <thead>
                    <tr>
                    <th title="Field #0"></th>
                    <apex:outputPanel rendered="{!anyHourlyRatePopulated}" layout="none">
                        <th title="Field #1">Services</th>
                    </apex:outputPanel>
                    <apex:outputPanel rendered="{!anyHourlyRatePopulated}" layout="none">
                        <th title="Field #1">Hourly Rate</th>
                    </apex:outputPanel>
                    <apex:outputPanel rendered="{!any2HourRatePopulated}" layout="none">
                        <th title="Field #2">2 Hour Rate</th>
                    </apex:outputPanel>
                    </tr>
                    </thead>
                <tbody>
                <apex:repeat value="{!qli}" var="opp">
                <tr>

                    <th scope ="row">Level 1</th>
                        <td>
                           L1 Hourly Rate Field
                        </td>
                    <td>
                        " L1 2 Hour Rate Field "
                    </td>
            
                </tr>
                </apex:repeat> 
                <apex:repeat value="{!qli}" var="opp">
                <tr>

                    <th scope ="row">Level 2</th>
                        <td>
                            "L2 Hourly Rate Field"
                        </td>
                    <td>
                       " L2 2 Hour Rate Field "
                    </td>
            
                </tr>
                </apex:repeat> 
            </tbody>

        </table>



 
Hi all,

I am trying to work with quote line items to generate a quote, i have around 26 columns that potentially might show at one time.

I want these columns to be all on one page, so it scales the data down. I have tried to use width but it doesn't work,

Here is my VF code:
<apex:page standardController="Quote" extensions="QLICon" standardStylesheets="false" showHeader="false" renderAs="pdf" applyBodyTag="false">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
        <apex:stylesheet value="{!$Resource.stylesheet}"/>
    </head>
    <body>
                    <div>  
                        <table id = "table" style="width:50%">
                            <thead>
                                <tr>
                                    <th>......</th>
                                </tr>
                                </thead>
                        <apex:repeat value="{!qli}" var="opp">
                            <tbody>
                                
                            <tr>
                                <td>
                                    .......
                                </td>

                            </tr>
                        </tbody>
                    </apex:repeat> 
                    </table>
                </div>  
    </body>
</apex:page>

css:
​​​​​​​  #table{
    max-width: 2480px;
    width:100%;
  }
  #table td{
    width: auto;
    overflow: hidden;
    word-wrap: break-word;
  }
Hi everyone,

So i am trying to make my empty columns disappear, and i've achieved this however, the rendered part of my code is also making my headers disappear. How would i solve this?

My code:
<apex:pageBlock >
            <apex:pageBlockTable value="{!qli}" var ="opp">
                <apex:column  headerValue = "Device Name" value = "{!opp.Device_Name__c}" rendered="{!NOT(ISNULL(opp.Device_Name__c))}"/>
                <apex:column headerValue = "Device Type" value="{!opp.Device_Type__c}" rendered="{!NOT(ISNULL(opp.Device_Type__c))}" />
                <apex:column headerValue = "Part Number" value="{!opp.Product2.Name}" rendered="{!NOT(ISNULL(opp.Product2.Name))}" />
                <apex:column headerValue="Serial Number" value="{!opp.Serial_Number__c}" rendered="{!NOT(ISNULL(opp.Serial_Number__c))}" />
                <apex:column headerValue="Contract Start Date" value="{!opp.Contract_Start_Date__c}" rendered="{!NOT(ISNULL(opp.Contract_Start_Date__c))}"/>
                <apex:column  headerValue="Contract End Date" value="{!opp.Contract_End_Date__c}" rendered="{!NOT(ISNULL(opp.Contract_End_Date__c))}"/>
            </apex:pageBlockTable>             
      </apex:pageBlock>

 
I am using below but the text is still showing

rendered="{!objTenant.Applicant_Status__c=='Submitted'}"
Hi everyone,

So i am trying to make my empty columns disappear, and i've achieved this however, the rendered part of my code is also making my headers disappear. How would i solve this?

My code:
<apex:pageBlock >
            <apex:pageBlockTable value="{!qli}" var ="opp">
                <apex:column  headerValue = "Device Name" value = "{!opp.Device_Name__c}" rendered="{!NOT(ISNULL(opp.Device_Name__c))}"/>
                <apex:column headerValue = "Device Type" value="{!opp.Device_Type__c}" rendered="{!NOT(ISNULL(opp.Device_Type__c))}" />
                <apex:column headerValue = "Part Number" value="{!opp.Product2.Name}" rendered="{!NOT(ISNULL(opp.Product2.Name))}" />
                <apex:column headerValue="Serial Number" value="{!opp.Serial_Number__c}" rendered="{!NOT(ISNULL(opp.Serial_Number__c))}" />
                <apex:column headerValue="Contract Start Date" value="{!opp.Contract_Start_Date__c}" rendered="{!NOT(ISNULL(opp.Contract_Start_Date__c))}"/>
                <apex:column  headerValue="Contract End Date" value="{!opp.Contract_End_Date__c}" rendered="{!NOT(ISNULL(opp.Contract_End_Date__c))}"/>
            </apex:pageBlockTable>             
      </apex:pageBlock>