• jane1234
  • NEWBIE
  • 258 Points
  • Member since 2016
  • SALESFORCE DEVELOPER
  • xyz

  • Chatter
    Feed
  • 5
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 54
    Replies
HOW WILL I DOWNLOAD A FILE  FROM DOCUMENT IN SALESFORCE APP
HOW TO USE SOQL QUERY IN JAVASCRIPT TO QUERY ACCOUNT

 
Dear all,
We are trying to deploy in production a trigger that capitalize the first letter of a name and a last name of a contact (even when there is a compound given name) and that the last name is in capital letters (example: Jean-Pierre DEBOIS). We tested in Sandbox and everything worked. But when we tried to deploy in production, we get the following errors and the test class has 0% code coverage (please see image below). Could anyone please help us to resolve this problem? 
Thank you! 

Trigger that we are trying to implement: 
trigger CapitalizeName on Contact( before insert , before update)
{
for(Contact c : Trigger.new)
{
if(c.FirstName != null)
{
String prev='';
String response='';
for (Integer i=0;i<c.FirstName.length();i++)
{
String cur=c.FirstName.subString(i ,i+1);
if (prev=='' || prev==' ' || prev=='-')
response+=cur.toUpperCase();
else
response+=cur.toLowerCase();
prev=cur;
}
c.FirstName = response;
}
c.LastName = c.LastName.ToUpperCase() ;
}
}


User-added image

 
Upon update of a date field on an Account, i would like all contacts that have the checkbox "Admin Contact" selected to update the same date field. 

i cannot see what i am doing wrong. i have looked up every single post and help forum i can find. documentation does not help. please dont post links, im sure ive seen it. 

tell me how i can get this to actually fire? 

Class:
public with sharing class AdminUsersAccount
{
	public void leadAlerts(List<Account> lstAcct)
	{
		sendAlertsPrivate(lstAcct);
	}

	private void sendAlertsPrivate(List<Account> lstAcct)
	{
		List<Contact> lstUpdateCon = new List<Contact>();
		map<Id, Contact> conMap = new map<Id, Contact>();
		for(Account a : lstAcct)
			conMap.put(a.Id, null);
		conMap.remove(null);
		conMap.putAll([SELECT Id, Admin_User__c, Account_Expiration__c FROM Contact WHERE Admin_User__c = true AND AccountId In : conMap.keySet()]);
		for(Account acc : lstAcct)
		{	
			if(conMap.containsKey(acc.Id))
			{
				if(acc.Approved_Date__c != null)
				{
					Date tdy = date.today();
					Date expire = acc.Approved_Date__c.addDays(365);
					boolean approved = expire >= tdy;
					lstUpdateCon.add(new Contact(Account_Expiration__c = approved?conMap.get(acc.Id).Account_Expiration__c: null));
				}
				else
				{
					lstUpdateCon.add(new Contact(Account_Expiration__c = null));
				}
			}
		}
		if(!lstUpdateCon.isEmpty())
			update lstUpdateCon;		
	}
}

 

I only i have trailhead link with me . How can i recover my account

https://trailhead.com/me/{ID}
which set of small and large data backup methods are available in native salesforce
What should administaror to do ensure the approprtiate price are tagged to products for his partners
I need to use the angular 6 with salesforce visualforce . Is that possible
I need to export the contact details from salesforce in txt file to ftp locations . How can i do that . is there is any limitation for size

I want alternative other than jitterbit .
 
 say if we have 100 objects
[
{“ECN”:10001, “PCN”:”2131932199”, “RoleType”=”PNI”},
{“ECN”:10002, “PCN”:”2131932199”, “RoleType”=”PNI”},
.
.
.
{“ECN”:10099, “PCN”:”2131932199”, “RoleType”=”SNI”},
{“ECN”:10100, “PCN”:”2131932199”, “RoleType”=”SNI”}
]
 
If I want to take the object having the ECN value as 10099, how should I take it using single line of code instead of looping all the elements.
 
In JAVA, it can be done through lambda expression in one line of code. Please check the feasibility.
If  connection from the odata service is stopped . Can we get  external object records from cache . 
Add to outlook button in event is visible in classic , but not visible in lightening experience
In paglayout  of an object  have embeded charts from  an report . In lightening experience , when we click on the report , view report button is visible . But when it comes to SF1 the vire report button is not visible

 

I have send the email automaticaly when the when certain field criteria of my custom object satisfied 

i tried conga workflow , but email is not sending properly

i have some js file which are hidden , so i cannot check then with lightning CLI. 
I want to check whether the js filesget afttected on  activation of lockerservice
 
heloo

Master object is opportunity . There is a button on Opportunity to merge fields of opportunity to a document using a conga composer. I also want to merge contact name which has role 'Decision Maker' . How to get this functionality
i have created a salespath which is assigned to the -Master- Record Type
 As does not have any Record Types of Opportunities
I need to use the angular 6 with salesforce visualforce . Is that possible
I need to export the contact details from salesforce in txt file to ftp locations . How can i do that . is there is any limitation for size

I want alternative other than jitterbit .
 
i have created a salespath which is assigned to the -Master- Record Type
 As does not have any Record Types of Opportunities

I only i have trailhead link with me . How can i recover my account

https://trailhead.com/me/{ID}
I need to use the angular 6 with salesforce visualforce . Is that possible
 say if we have 100 objects
[
{“ECN”:10001, “PCN”:”2131932199”, “RoleType”=”PNI”},
{“ECN”:10002, “PCN”:”2131932199”, “RoleType”=”PNI”},
.
.
.
{“ECN”:10099, “PCN”:”2131932199”, “RoleType”=”SNI”},
{“ECN”:10100, “PCN”:”2131932199”, “RoleType”=”SNI”}
]
 
If I want to take the object having the ECN value as 10099, how should I take it using single line of code instead of looping all the elements.
 
In JAVA, it can be done through lambda expression in one line of code. Please check the feasibility.
HOW WILL I DOWNLOAD A FILE  FROM DOCUMENT IN SALESFORCE APP
Hi everybody,

I have a visualforce page with a button. When clicked the pages simply reloads (this behaviour is only a test for more complex processes),
calling:  
sforce.one.navigateToURL('/apex/MyVFPage?param1=' + firstId+ '&param2=' + secondId);

Everything works fine in browser, Salesforce1 Simulator (app for Google Chrome), Salesforce1 for Android, but in the ios version, it works just the first time; after the pages reloads and the button is clicked a second time, the pages freezes.

Anyone knows how to solve this issue or to better debug it?

Thanks!
accountLIst = [querying Accounts here] 
 Map<String,Validation__c> mcs = R2_Validation__c.getAll();
            system.debug('mcs====>'+mcs);                              
            for(Account acc : accountList){
                          billingCountry = acc.BillingCountry;
            Validation__c mc = Validation__c.getValues(BillingCountry);
            system.debug('mc====>'+mc); 

Getting value on mc null. Please suggest
Hi Experts,

I have requirment in that i am preparing an page , mostly i used html but here issue is that i used an image from my system but its not working for other users so i am looking for alternative soluation so i thought  to call an image from static resource but i am not sure how to call from my html page or else in CSS also fine for me . kindly help me out. below is the code which i called in my html page.


 <header>
 <br></br>
   <img src="D:\Users\Logo-without-Tagline_Black.png"   style="width:100%;height:250px;"/>
    </header>
Kindly help me out.

Thanks in advance
I'm working a lightning component, which has a requirement of displaying a dynamic table.

For that, I need to iterate over a map (Map>) and display the values.

So, How can I retrieve map from apex controller and display values/key on the component ?

Apex Controller method signature –
public static Map<Id, Map<String, String>> getDataCollectionTableValues(Id dataCollectionId){
Apex method return value –
{  
   a0E0k000003aEKUEA2=   {  
      Field_10__c=test1,
      Field_1__c=test2,
      Field_2__c=test3,
      Field_3__c=test6,
      Field_4__c=null,
      Field_5__c=null,
      Field_6__c=test7,
      Field_7__c=null,
      Field_8__c=null,
      Field_9__c=test,
      ...
   }
}
Lightning helper – I’ve passed id parameter to controller method and set response to the map attribute.
 
({
    loadDataCollection: function(component) {

        var action = component.get("c.getDataCollectionTableValues");
        action.setParams({
            dataCollectionId : component.get("v.recordId")
        });

        action.setCallback(this, function(response)
        {
            var state = response.getState();
            if (state === "SUCCESS")
            {
                component.set("v.dataCollectionRecords", response.getReturnValue());
                 console.debug(response.getReturnValue());
            }else
            {
                console.debug(response.error[0].message);
            }
        });
        $A.enqueueAction(action);
    }
})

Component –
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" controller="DataCollectionTableController">
    <aura:attribute name="recordId" type="Id"/>
    <aura:attribute name="dataCollection" type="Data_Collection__c" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="dataCollectionRecords" type="Map"/>
    <aura:iteration items="{!v.dataCollectionRecords}" var="dcrRecord" indexVar="key">
        {!key}
        {!dcrRecord.key}
    </aura:iteration>

</aura:component>



 
I am trying to set a lightning input field as invalid through a controller method in a lightning component.
I set the validity as this
evt.getSource().set('v.validity',{valid:false, badInput :true});
this worked fine before Summer' 18 udate.
Awaiting response
1. I have created a Json file and uploaded into static resources in salesfoce. The file name is "xyz"
2. Converted the json file to apex class using - http://json2apex.herokuapp.com/.
3. I have the below structure of the class ... can someone validate this please ? it's not working for some reason .. pls give me the correct code.

basically 3 separate classes or ... do I need to nest these classes in the main class ? can you pls suggest on the structure of these classes.

global class preparemysandbox implements SandboxPostCopy {
     global void runApexClass(SanboxContext context) {
           Here I need to update the custom setting fields with the values from Json text files saved as static resource.
            e.g url (custom setting field) = (Here I need to assign value from static resource value)
      }
}

Public class JSON2Apex {
     Converted the json file to apex class using - http://json2apex.herokuapp.com/. I have all that here in this class.
}

Public static JSON2Apex parse(string cd) {
     StaticResource sr = [select id, body from StaticResource where name = 'xyz'; - I am getting error on Select, id and name on this line of code.
      cd = sr.ody.toString();
     return (JSON2Apex) System.JSON.deserialize(cd, JSON2Apex.class)
}
  • May 08, 2018
  • Like
  • 0
Hi All,

We have a code where we are using site templates. I have to add one more div in the VF page. The site template is used in VF Page. I am not able to figure out where to add the div code. We have code like this.
<apex:composition template="{!$Site.Template}">
  <apex:define name="headerNav">
    <c:HeaderComponent id="headerComponent" displayContactUs="true" displayMyCases="true" displayMyProfile="true"/>
  </apex:define>
  <apex:define name="maincolumn">
        <a name="mainContent" id="mainContent"></a>
                           <div id="rn_dashboardwrapper">
                               <div id="rn_dashboard">
                                   <div style="padding-bottom: 10px;">
                                   <apex:outputLink value="{!$Page.InstantAnswers}"><apex:image alt="CertificationSupport" url="{!URLFOR($Resource.CiscoPortalResource, 'images/skin/CertificationsSupport.PNG')}" /></apex:outputLink>
                            <!-- banner start here on 7/21/2017 -->

I am not able to find where {$Site.Template} is used. I need to add the div code.

Thanks,
Anuj
 
Hi, Still my Trigger is getting 72 % code coverage.

Please let me know where am doing wrong?

My Trigger :

trigger v2_QuoteLineItemTaxUpdate on QuoteLineItem (Before Insert, after insert) {

    list<QuoteLineItem> lstUpdateQLI = new list<QuoteLineItem>();
    set<id> setQuoteId = new set<id>();
    set<id> setQLIId = new set<id>();
    set<string> setdiscount = new set<string>();
    set<String> setHSNCode = new set<String>();    
    map<string, list<Tax_Master__c>>mapTaxMasToTaxKey = new map<string, list<Tax_Master__c>>();    
        
    for(QuoteLineItem iQLI : Trigger.New){    
    
        setQLIId.add(iQLI.id);
        setQuoteId.add(iQLI.QuoteId);
        system.debug('****setQLIId'+setQLIId); 
            
    }
    
    if(setQuoteId.size() > 0){
    
        for(Quote iQuot : [SELECT id,(SELECT id, Product2.HSN_Code__c FROM QuoteLineItems WHERE ID IN: setQLIId) 
            FROM Quote WHERE Id IN :setQuoteId]){
        
            for(QuoteLineItem iQLI : iQuot.QuoteLineItems){
                  
                    if(iQLI.Product2.HSN_Code__c != ''){
                    
                        setHSNCode.add(iQLI.Product2.HSN_Code__c);
                    }    
            }   
            system.debug('****setHSNCode'+setHSNCode);                    
        }
        
        if(setHSNCode.size() > 0){
        
            if(setHSNCode.size() > 0){ 
            
                for(Tax_Master__c iTM : [SELECT id, Product_Family__c,Product_Sub_Family__c,HSN_Code__c, IGST__c, CGST__c, SGST__c, Active__c,Start_Date__c,End_date__c  FROM Tax_Master__c 
                    WHERE HSN_Code__c IN :setHSNCode]){
                
                    String ikey = iTM.HSN_Code__c;
                    if(!String.isblank(iTM.Product_Family__c))
                    {
                        ikey = ikey + iTM.Product_Family__c;                         
                    } 
                    if(!String.isblank(iTM.Product_Sub_Family__c))
                    {
                        ikey = ikey + iTM.Product_Sub_Family__c;                         
                    } 
                    list<Tax_Master__c> lstTax = new list<Tax_Master__c>();
                    lstTax.add(iTM);
                    if(mapTaxMasToTaxKey.containskey(ikey))
                    {
                        lstTax.addall(mapTaxMasToTaxKey.get(ikey));
                    }
                    mapTaxMasToTaxKey.put(ikey, lstTax);   
                 }    
                 
                         system.debug('****mapTaxMasToTaxKey'+mapTaxMasToTaxKey);       

            }  
                   
            
            for(Quote iQuot : [SELECT id, Tax_Classification__c, Discount_Amount__c, Anki_total_Amt__c,
                (SELECT Product2.family,Q_Discount__c, Product2.HSN_Code__c, Product2.Sub_Family__c,Tax_Master__c, 
                    IGST__c, CGST__c, SGST__c FROM QuoteLineItems WHERE ID IN: setQLIId) FROM Quote WHERE Id IN :setQuoteId]){
            
                for(QuoteLineItem iQLI : iQuot.QuoteLineItems){  
                         
                   
                       system.debug('****iQuot.Discount_Amount__c'+iQuot.Discount_Amount__c); 
                       
                       system.debug('****iQuot.Anki_total_Amt__c'+iQuot.Anki_total_Amt__c); 
                          
                         
                        if(iQuot.Discount_Amount__c <= 0){
                                iQLI.Q_Discount__c = 0;    
                          
                            } else {
                                if(iQuot.Discount_Amount__c != null && iQuot.Discount_Amount__c != 0 && iQuot.Anki_total_Amt__c !=null && iQuot.Anki_total_Amt__c !=0){
                                iQLI.Q_Discount__c =(iQuot.Discount_Amount__c/iQuot.Anki_total_Amt__c) * 100;
                                
                                }
                            }                               
                        system.debug('****Q_Discount__c'+iQLI.Q_Discount__c);
                        Tax_Master__c itax = new Tax_Master__c();
                        if(mapTaxMasToTaxKey.containsKey(iQLI.Product2.HSN_Code__c+iQLI.Product2.Family+iQLI.Product2.Sub_Family__c)){
                            for(Tax_Master__c irow : mapTaxMasToTaxKey.get(iQLI.Product2.HSN_Code__c+iQLI.Product2.Family+iQLI.Product2.Sub_Family__c))
                            {
                                if(irow.Start_Date__c <= System.today() && irow.End_Date__c  >= System.today())
                                {
                                
                                    itax = irow;
                                    break;
                                }
                            }
                        }
                        else if(mapTaxMasToTaxKey.containsKey(iQLI.Product2.HSN_Code__c+iQLI.Product2.Family) ){
                            
                            for(Tax_Master__c irow : mapTaxMasToTaxKey.get(iQLI.Product2.HSN_Code__c+iQLI.Product2.Family))
                            {
                                if(irow.Start_Date__c <= System.today() && irow.End_Date__c  >= System.today())
                                {
                                
                                    itax = irow;
                                    break;
                                }
                            }
                        }else if(mapTaxMasToTaxKey.containsKey(iQLI.Product2.HSN_Code__c))
                        {
                            for(Tax_Master__c irow : mapTaxMasToTaxKey.get(iQLI.Product2.HSN_Code__c))
                            {
                                if(irow.Start_Date__c <= System.today() && irow.End_Date__c  >= System.today())
                                {
                                
                                    itax = irow;
                                    break;
                                }
                            }
                        }
                        
                    if(!String.isblank(itax.id)){
                    
                        iQLI.Tax_Master__c = itax.id;
                        
                        
                        
                        if(iQuot.Tax_Classification__c == 'IGST'){
                        
                            iQLI.IGST__c = itax.IGST__c;
                            iQLI.SGST__c = 0; 
                            iQLI.CGST__c = 0;
                            
                        } 
                        
                         
                        if(iQuot.Tax_Classification__c == NUll){
                        
                            iQLI.IGST__c = 0;
                            iQLI.SGST__c = 0; 
                            iQLI.CGST__c = 0;
                            
                        } 
                        
                        if(iQuot.Tax_Classification__c == 'SGST'){
                        
                            iQLI.SGST__c = itax.SGST__c;
                            iQLI.CGST__c = itax.CGST__c;    
                            iQLI.IGST__c = 0;  
                                                 
                        }                       
                        
                        lstUpdateQLI.add(iQLI);                            
                    }                                         
                }    
            }  
            
            if(lstUpdateQLI.size() > 0){
            
                update lstUpdateQLI;
            }          
        }
    }
}


My Tess Class:

@isTest(seealldata=true)
Public class v2_QuoteLineItemTaxUpdate_Test{
    static testMethod void Testv2_QLITaxUpdate(){
        
        GetInitialData Getdata = new GetInitialData();
        list<Account> acc = Getdata.getAccount();
        list<Product2> lstprod = Getdata.getProd();
        list<Opportunity> Opp = Getdata.getOpp();
        list<Pricebook2> lstPB = Getdata.getpricebook();
        list<Pricebookentry> lststdPbe = Getdata.getstdpbe();
        list<Pricebookentry> lstPbentry = new list<Pricebookentry>();
        insert lstprod; 
        
        Integer indexvalue = 0;
        if(lstprod.size()>0)
        {
            for(pricebookentry irow :lststdPbe)
            {
                irow.product2id = lstprod[indexvalue].id;
                
                indexvalue++;
            }
        }
        
        
        insert lststdPbe;
        
        insert lstPB; 
        
        
        if(lstprod.size()>0)
        {
            for(pricebook2 irow :lstPB)
            {
                for(Product2 ipro : lstprod ){
                    Pricebookentry pbe = new Pricebookentry();
                    pbe.product2id = ipro.id;
                    pbe.pricebook2id = irow.id;
                    pbe.unitprice = 3000;
                    pbe.isActive = true;
                    lstPbentry.add(pbe);
                }
            }
        }

        insert lstPbentry;
        insert acc[0];
        
        Opp[0].accountId = acc[0].id;
        insert Opp[0]; 
        
        Opp[0].Pricebook2Id = lstPB[0].id;
        update Opp[0];
        
        OpportunityLineItem OL = new OpportunityLineItem(opportunityid=Opp[0].id, Quantity=1, unitprice=8000,  
            pricebookentryid=lstPbentry[0].id);
        insert OL; 
        
        Tax_Master__c   txm= new Tax_Master__c(CGST__c=14.00,HSN_Code__c=lstprod[0].HSN_Code__c,IGST__c=28.00,SGST__c=14.00, Start_Date__c =  Date.newInstance(2017, 07, 06), End_Date__c = System.today()+2);
        insert txm;  
            
        Quote Q = new Quote();
        Q.Name = 'QuoteOrbit';
        Q.OpportunityId = Opp[0].id; 
        Q.Quote_Count__c = 00000000;
        Q.Quote_Number__c ='000000';
        Q.Approved__c = false;
        Q.Quotation_Date__c = date.newinstance(2013,3,5);
        Q.Pricebook2Id = lstPB[0].id;
        Q.Tax_Classification__c='IGST';
        Q.Discount_Amount__c = 100;
        
        insert Q;  
        
          Q.Tax_Classification__c='IGST';
          Q.Discount_Amount__c = 100; 
          update Q ; 
        
        
        
      
       
        
        Quotelineitem QL = new Quotelineitem(quoteId=Q.id,SGST__c=6, CGST__c=6,IGST__c =0,Quantity =1, Unitprice=8000,pricebookentryid=lstPbentry[0].id);
        insert QL;  
        
           Opp[0].SyncedQuoteId = Q.id;
           update Opp[0];
           
            Q.Approved__c = true;   
          Update Q;
          
          Q.Approved__c = true;           
           update Opp[0];
        
        
          QuoteLineitem qli = [Select Id From QuoteLineItem where quoteId=:Q.id limit 1]; 
          Q.Tax_Classification__c='IGST';
          qli.SGST__c =6;
          QLI.CGST__c=6;
          QLI.IGST__c =0;          
          update qli;     
          
           
        
                
         
         
           
               
       
         Quote Q1 = new Quote();
        Q1 .Name = 'QuoteOrbit';
        Q1 .OpportunityId = Opp[0].id; 
        Q1 .Quote_Count__c = 00000000;
        Q1 .Quote_Number__c ='000000';
        Q1 .Approved__c = false;
        Q1 .Quotation_Date__c = date.newinstance(2013,3,5);
        Q1 .Pricebook2Id = lstPB[0].id;
        Q1 .Tax_Classification__c='IGST';
        Q1 .Discount_Amount__c = 100;
        
        insert Q1 ;    
        
        
        Q1 .Tax_Classification__c='SGST';  
        UPdate Q1;
                 
       
        
   
        
    }
    }