• Sanchi9
  • NEWBIE
  • 50 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 2
    Replies
Hi,

I have written a code for an email template using visual force where I want to display the Margin percent field upto two decimal places. Currently I am getting the table in this format: 
User-added image


Here is the code:
 <messaging:emailTemplate recipientType="User"
    subject="Quote Appoval for {!relatedTo.name}"
    relatedToType="Quote">
 
    <messaging:htmlEmailBody >
        <html>
            <body>
 
            <p>Dear {!recipient.name},</p>
            <p>Please find below details related to Quote - {!relatedTo.Name}.<br/>
            Customer - {!relatedTo.Account.Name}<br/>
            Customer Type - {!relatedTo.Account.Type}<br/>
            Total amount - ${!relatedTo.New_Total_Price__c}<br/> 
            Margin Percent- {!relatedTo.Margin_Percent__c}%<br/> 
            Approval reason : Total discount on quote exceeds {!relatedTo.Total_Discount__c} %.<br/>
            </p>
            <br/>
            <p>
            Product Information:
            <table border="2" >
                <tr>
                    <th>Product</th>
                    <th>Product quantity</th>
                    <th>Total Price</th>
                    <th>Margin Percent</th>
                    <th>Discount</th>
                    <th>Discount Reason</th>
                </tr>
                <apex:repeat var="cx" value="{!relatedTo.QuoteLineItems}">
                <tr>
                    <td>{!cx.Product2.Name}</td>
                    <td>{!cx.Quantity}</td>
                    <td>${!cx.Total_Price__c}</td>                                      
                    <td>${!cx.Margin_Percent__c}</td>                             
                </tr>
                </apex:repeat> 
            </table>
            </p>
            <br/>
        
            
            </body>
        </html>
Hi, 
I am working on Lightning datatable. Is there any way to default select the checkbox in lightning datatable? 

User-added image
Hi! I have written the following formula in a process builder to update the Margin dollar field on Quote line items. Somehow the field is not getting updated. 
1.The process starts when a record is created and edited. 
2. The Cost field is on the Pricebookentry which I am referencing here to calculate the margin. 
Formula for Margin Calculation
Hi, I want to write a test class for Batch Callout. The code is below:

global class BatchSync implements Database.Batchable<sObject>, Database.AllowsCallouts{
     
    global Database.QueryLocator start(Database.BatchableContext bc){
    
        String query = 'SELECT id, Name, Type From Account WHERE Type='Prospect';
       
        return Database.getQueryLocator(query);
    }
     
    
    global void execute(Database.BatchableContext bc, List<Account> scope){
         
       for (Account acc : scope){  
         
                try{
                    HttpRequest request = new HttpRequest();
                    HttpResponse response = new HttpResponse();
                    Http http = new Http();                    
                    String username = 'Username';
                    String password = 'Password';
                    Blob headerValue = Blob.valueOf(username + ':' + password);
                    String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
                     
                    request.setHeader('Authorization', authorizationHeader);
                    request.setHeader('Content-Type', 'application/json');
                          
                    request.setEndpoint(enpointurl);
                    request.setMethod('GET');
                    response = http.send(request);                      
                        if (response.getStatusCode() == 200) {
                        String jsonResponse = response.getBody();                                           acc.Type='Customer';
                        
                    }
                    JSONParser parser = JSON.createParser(response.getBody());
                    HttpResponse res = http.send(request);
                    //list of header names keys
                    string[] headerkeys = res.getHeaderKeys();
                    Map<string, string> headers = new map<string, string>();
            
                    //iterate through they keys, and populate your map
                    for(string s : headerkeys){
                    headers.put(s,res.getHeader(s));
                    system.debug('header: ' + s + ' value: ' + res.getHeader(s));
                    }
                    }
                     
                                   
                catch(Exception e){
                   System.debug('Error-' + e.getMessage());   
                } 
                      update scope;
                        }
        }
                   
            
        
    }
 
    global void finish(Database.BatchableContext bc)
    { 
         
    }
}
Hi I need help in writing test class for a custom lightning controller.  Posting the code here:

public with sharing class AccountRecordFormClass {
    
    @AuraEnabled 
    public static user fetchUser(){      
      User oUser = [select id,Name, Email FROM User Where id =: userInfo.getUserId()];
        system.debug(oUser);        
        
        return oUser;
    }
    
    
    @AuraEnabled 
    public static account fetchaddress(String accid){
    
      Account acc = [select id, BillingStateCode, BillingCountryCode,BillingStreet,BillingCity,BillingPostalCode,Phone, FROM Account Where id =: accid];
              
        
        return acc;
    }
    
}
  
How to format phone number as 123-123-1234 when entered in a lightning input? 
 
Hey!

I want to show some default values in a lightning input field. How can I achieve this?
Hi!

Given: Quote has a lookup with Pricebook.
I want to write a validation rule on Quote object, to not change the pricebook if Quote line items already exists. 
 
Hi!

Quote has a look up with Pricebook.
PricebookEntry has a lookup with Pricebook.

I have to write a SOQL query on the Quote object to display all the PricebookEntry when a specified Pricebook is selected on the quote object. 

Any idea how this can be done?
Hi!
So I have got a requirement to override the standard 'Add Product' button on the quote line items.
Basically, the pricebook selected in the Opportunity should only be displayed while adding the product. 
Any idea how I can achieve this?
Hi, 
I want to know how can one develop a Lightning UI and deploy it for B2B E-commerce? 

 
Hi,

Given there are two fields A and B.
We can only enter values in field A only if field B is empty. 
What validation rule should I write for this?  
Hi, so I have got a requirement regarding Quotes. I have to create the quote PDF based on a certain field criteria. If the criteria is selected, a particular template should be  generated. Else  another quote should be generated. How can this be done?
Hi!

Given: Quote has a lookup with Pricebook.
I want to write a validation rule on Quote object, to not change the pricebook if Quote line items already exists. 
 
Hi,

Given there are two fields A and B.
We can only enter values in field A only if field B is empty. 
What validation rule should I write for this?