+ Start a Discussion
farah sheriffarah sherif 
the trigger should be on account to check the assets and if ALL Assets where product family = "bla bla "  and their status was "Canceled" the trigger should update bla bla Account stage (API Name = Account_Status__c )  to "Cancel".
Best Answer chosen by farah sherif
Abdul KhatriAbdul Khatri
Can you try the below
trigger AccountUpdateFromAssetProduct on Asset (after insert, after update) {
    List<Asset> assetList = Trigger.new;

	List<Id> idAccountList = new List<Id>();    
    for(Asset asset : assetList) {
        if(Trigger.isUpdate && asset.Product2.Family == Trigger.oldMap.get(asset.Id).Product2.Family && asset.Status == Trigger.oldMap.get(asset.Id).Status) continue;
        if(asset.AccountId == null) continue;
    if(idAccountList.isEmpty()) return;
    List<Account> acctList = [SELECT Id, (SELECT Id FROM Assets WHERE Product2.Family = 'bla bla' AND Status = 'Canceled') FROM Account LIMIT 50];
    for(Account acct : acctList)
        if(acct.Assets.isEmpty()) continue;
        acct.Account_Status__c = 'Cancel';

    update acctList;

Nilesh Borse 9Nilesh Borse 9 
I am littile bit confuse about <lightnign:input /> & <ui:input /> when to use which and what differences does it makes?
Best Answer chosen by Nilesh Borse 9
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Nilesh,

You can find base Lightning components in the lightning namespace to complement the existing ui namespace components. In instances where there are matching ui and lightning namespace components, we recommend that you use the lightning namespace component. The lightning namespace components are optimized for common use cases. Beyond being equipped with the Lightning Design System styling, they handle accessibility, real-time interaction, and enhanced error messages.

Please refer the below link for reference. hope it will help.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Rahul Kumar
Amit Singh1989Amit Singh1989 

Hi friend,

i have created an visualforce page where i have used <apex:inputFile /> to take any CSV file as input

then i am displaying that CSV file's data into the same vf page in tabular format...


but i want that selected CSV's data should be displayed in another vf page. (so by setting attribute renderas="pdf" i can view CSV's data in a PDF format)



how can i do this?



here is my code...


<apex:page controller="uploadCSVcontroller">
  <apex:form >
  <apex:pageMessages id="pm"/>
  <apex:inputFile value="{!contentFile}" filename="{!nameFile}"/>
  <apex:commandButton value="Display" id="theButton"/>  
  <apex:pageBlock >
  <apex:outputPanel id="results">
  <p>nameFile: {!nameFile}</p>
  <p>rowCount: {!rowCount}</p>
  <p>colCount: {!colCount}</p>
    <table title="CSV Output" border="1" width="100%">
       <apex:repeat value="{!results}" var="row">
               <apex:repeat value="{!row}" var="cell">
                   <td> {!cell} </td>


public class uploadCSVcontroller 

    public Blob contentFile { get; set; }
    public String nameFile { get; set; }
    public Integer rowCount { get; set; }
    public Integer colCount { get; set; }
    public List<List<String>> getResults() 
        List<List<String>> parsedCSV = new List<List<String>>();
        rowCount = 0;
        colCount = 0;
        if (contentFile != null)
            String fileString = contentFile.toString();
            parsedCSV = parseCSV(fileString, False);
            rowCount = parsedCSV.size();
            for (List<String> row : parsedCSV)
                if (row.size() > colCount)
                    colCount = row.size();
        return parsedCSV;
    public Pagereference CreatePDF()
      pagereference pr = new pagereference('/apex/FinalReport1');
      return pr;
    public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) 
        List<List<String>> allFields = new List<List<String>>();
        contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
        contents = contents.replaceAll('""','DBLQT');
        List<String> lines = new List<String>();
          lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
        catch (System.ListException e) 
            System.debug('Limits exceeded?' + e.getMessage());
        Integer num = 0;
        for(String line: lines) 
           if (line.replaceAll(',','').trim().length() == 0) break;
            List<String> fields = line.split(',');  
            List<String> cleanFields = new List<String>();
            String compositeField;
            Boolean makeCompositeField = false;
            for(String field: fields) 
                if (field.startsWith('"') && field.endsWith('"')) 
                else if (field.startsWith('"')) 
                    makeCompositeField = true;
                    compositeField = field;
                else if (field.endsWith('"')) 
                    compositeField += ',' + field;
                    makeCompositeField = false;
                else if (makeCompositeField) 
                    compositeField +=  ',' + field;
        if (skipHeaders) allFields.remove(0);
        return allFields;       






Amit Singh

Best Answer chosen by Admin (Salesforce Developers) 


hi amit singh1989,


Better read the CSV file and store in the document object in first VF page. give a button as "View and Convert to PDF" in the first VF Page. 


When clicking the button, just redirect them to the second VF page and just show the content of the CSV page by querying the file from the Document object and put "RenderAs" attribute in that page itself.


What i think is, upload the file and show the content in the first page itself and provide a button as "Convert to PDF". while clicking the button, u just redirect to the second page. in that second page controller class, retrieve the same CSV file and convert to PDF by adding the "RenderAs" attribute in the second page. 


Accept as solution if u find this post is useful for you..






sheila srivatsavsheila srivatsav 
I have a piece of code in my lightning component as follows

pCodeShortDesc = pCodeShortDesc.subtring(0,28);

this return a string like "Nebuent    Inh 300 mg"

I want to remove the two extra white spaces in the above.

Please let me know urgent how to do.

Best Answer chosen by sheila srivatsav
NagendraNagendra (Salesforce Developers) 

I would suggest using the trim() function followed by a regex replacement using replaceAll() that matches instances of the space characters i.e. (\\s+) and replaces them with a single space.

String str = ' how is the weather today '; str = str.trim(); str = str.replaceAll('(\\s+)', ' '); return 


Hope this helps.

Kindly mark this as solved if the reply was helpful.

Abhilash Mishra 13Abhilash Mishra 13 
can i get all the values of a picklist field in a list some how?

I have picklist type custom field in the product. having some options.
In my apex class i want to use these options. can I get them some how throught code? 
Best Answer chosen by Abhilash Mishra 13
Hi Abhilash,

If you want to display pick list values in your custom page through dyanamic apex .You can check below link it will help  .


If you want in a string array or list then you can use below code .
public List<String> getPickListValuesIntoList(){
       List<String> pickListValuesList= new List<String>();
		Schema.DescribeFieldResult fieldResult = ObjectApiName.FieldApiName.getDescribe();
		List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
		for( Schema.PicklistEntry pickListVal : ple){
		return pickListValuesList;
Let us know if it helps !!

I got following error on step 3.

Challenge Not yet complete... here's what's wrong: 
Couldn’t find Agency records from the Account object.

Can anyone pass this step?
Thanks in advance.

Best Answer chosen by LinThaw
Hi Jennifer and ankita,

Please refer below, I passed this step 3.

fig 1.
User-added image

fig 2.
User-added image

and create Top 5 Agencies lenses.

Arun ChaubeyArun Chaubey 
create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null?
The Apex class must be called 'AccountHandler' and be in the public scope.
The Apex class must have a public static method called 'insertNewAccount'.
The 'insertNewAccount' method must accept an incoming string as a parameter, name the account after the parameter, insert it into the system and then return the account record.
The 'insertNewAccount' method must also accept an empty string, catch the failed DML and return null.
Best Answer chosen by Arun Chaubey
NagaNaga (Salesforce Developers) 
Hi Arun,

Can you please let me know if the code below helps you

public class AccountHandler {
public static Account insertNewAccount(String name) {
Account a = new Account();
a.Name = name;
insert a;
} catch (Exception e) {
return null;
return a;
This method takes name string parameter and makes a new Account. Then it tries to insert it, but if insert fails then it returns null. If insert succeeds, it will return that account object.

Best Regards
Naga Kiran
Arundhati DebArundhati Deb 

I have a scenario where the account currency and opportunity currency can be different. The opportunity currency should be the same as opportunity owner currency. I have to write a trigger for it. Can anyone help me with it.
Highly appreciated.
Best Answer chosen by Arundhati Deb
Abdul KhatriAbdul Khatri

I see some issues with your code so here is your code with some corrections.
public static void Opportunitycurrency (List<Opportunity> newOptyList) {
        List<Id> oppOwnerIds = new List<Id>();
        for(Opportunity opp: newOptyList)
            if(opp.OwnerId != null)
        Map<Id, User> userList = new Map<Id, User>([SELECT Id, Name, CurrencyIsoCode FROM User WHERE Id IN :oppOwnerIds]);
        for(Opportunity opp: newOptyList)
            if(opp.type != 'Renewal')


When somone gives a swagger, What else do we need to do to do testing in Postman.

is there any authentcation key i should ask ?

I imported the swagger and i directly clicked on send
I get below error
    "code": "500",
    "name": "Internal Gateway Error",
    "message": "error unknown
Best Answer chosen by Sandrine
v varaprasadv varaprasad
Hi Sandrine,

Please check once below link it may help you.


Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: varaprasad4sfdc@gmail.com

Salesforce latest interview questions and training videos :


Anil Rao 17Anil Rao 17 
I have added few custom fields in the OP Object. When I look at a O, I want to view the custom fields in the OP associated to a O.

I get a list of the Products in the O page & when I click the link for the Product, it takes me to the Product page & there is no way that I amable to see the OP Records.

How can I see a list of all OP records associated to a O from the O Page?
Best Answer chosen by Anil Rao 17
Anil Rao 17Anil Rao 17
I was able to get this. I just had to change the page layout to add the desired columns